linuxdcpp-team team mailing list archive
-
linuxdcpp-team team
-
Mailing list archive
-
Message #02744
[Branch ~dcplusplus-team/dcplusplus/trunk] Rev 2344: Update MiniUPnPc
------------------------------------------------------------
revno: 2344
committer: poy <poy@xxxxxxxxxx>
branch nick: trunk
timestamp: Sun 2010-12-12 22:16:33 +0100
message:
Update MiniUPnPc
added:
miniupnpc/Changelog.txt
miniupnpc/VERSION
modified:
changelog.txt
miniupnpc/miniupnpc.c
miniupnpc/miniwget.c
miniupnpc/miniwget.h
--
lp:dcplusplus
https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk
Your team Dcplusplus-team is subscribed to branch lp:dcplusplus.
To unsubscribe from this branch go to https://code.launchpad.net/~dcplusplus-team/dcplusplus/trunk/+edit-subscription
=== modified file 'changelog.txt'
--- changelog.txt 2010-12-11 23:50:40 +0000
+++ changelog.txt 2010-12-12 21:16:33 +0000
@@ -56,6 +56,7 @@
* Display full country names rather than abbreviations (poy)
* Select a better default font (poy)
* [L#681754] Fonts and dialogs respect DPI settings - mark DC++ as DPI aware (poy)
+* Update MiniUPnPc (poy)
-- 0.770 2010-07-05 --
* [L#550300] Catch more potential file corruptions (thanks bigmuscle)
=== added file 'miniupnpc/Changelog.txt'
--- miniupnpc/Changelog.txt 1970-01-01 00:00:00 +0000
+++ miniupnpc/Changelog.txt 2010-12-12 21:16:33 +0000
@@ -0,0 +1,364 @@
+$Id: Changelog.txt,v 1.122 2010/12/09 16:11:31 nanard Exp $
+miniUPnP client Changelog.
+
+2010/12/09:
+ new code for miniwget that handle Chunked transfer encoding
+ using getHTTPResponse() in SOAP call code
+
+2010/11/25:
+ changes to minissdpc.c to compile under Win32.
+ see http://miniupnp.tuxfamily.org/forum/viewtopic.php?t=729
+
+2010/09/17:
+ Various improvement to Makefile from MichaŠGórny
+
+2010/08/05:
+ Adding the script "external-ip.sh" from Reuben Hawkins
+
+2010/06/09:
+ update to python module to match modification made on 2010/04/05
+ update to Java test code to match modification made on 2010/04/05
+ all UPNP_* function now return an error if the SOAP request failed
+ at HTTP level.
+
+2010/04/17:
+ Using GetBestRoute() under win32 in order to find the
+ right interface to use.
+
+2010/04/12:
+ Retrying with HTTP/1.1 if HTTP/1.0 failed. see
+ http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1703
+
+2010/04/07:
+ avoid returning duplicates in upnpDiscover()
+
+2010/04/05:
+ Create a connecthostport.h/.c with connecthostport() function
+ and use it in miniwget and miniupnpc.
+ Use getnameinfo() instead of inet_ntop or inet_ntoa
+ Work to make miniupnpc IPV6 compatible...
+ Add java test code.
+ Big changes in order to support device having both WANIPConnection
+ and WANPPPConnection.
+
+2010/04/04:
+ Use getaddrinfo() instead of gethostbyname() in miniwget.
+
+2010/01/06:
+ #define _DARWIN_C_SOURCE for Mac OS X
+
+2009/12/19:
+ Improve MinGW32 build
+
+2009/12/11:
+ adding a MSVC9 project to build the static library and executable
+
+2009/12/10:
+ Fixing some compilation stuff for Windows/MinGW
+
+2009/12/07:
+ adaptations in Makefile and updateminiupnpcstring.sh for AmigaOS
+ some fixes for Windows when using virtual ethernet adapters (it is the
+ case with VMWare installed).
+
+2009/12/04:
+ some fixes for AmigaOS compilation
+ Changed HTTP version to HTTP/1.0 for Soap too (to prevent chunked
+ transfer encoding)
+
+2009/12/03:
+ updating printIDG and testigddescparse.c for debug.
+ modifications to compile under AmigaOS
+ adding a testminiwget program
+ Changed miniwget to advertise itself as HTTP/1.0 to prevent chunked
+ transfer encoding
+
+2009/11/26:
+ fixing updateminiupnpcstrings.sh to take into account
+ which command that does not return an error code.
+
+VERSION 1.4 : released 2009/10/30
+
+2009/10/16:
+ using Py_BEGIN_ALLOW_THREADS and Py_END_ALLOW_THREADS in python module.
+
+2009/10/10:
+ Some fixes for compilation under Solaris
+ compilation fixes : http://miniupnp.tuxfamily.org/forum/viewtopic.php?p=1464
+
+2009/09/21:
+ fixing the code to ignore EINTR during connect() calls.
+
+2009/08/07:
+ Set socket timeout for connect()
+ Some cleanup in miniwget.c
+
+2009/08/04:
+ remove multiple redirections with -d in upnpc.c
+ Print textual error code in upnpc.c
+ Ignore EINTR during the connect() and poll() calls.
+
+2009/07/29:
+ fix in updateminiupnpcstrings.sh if OS name contains "/"
+ Sending a correct value for MX: field in SSDP request
+
+2009/07/20:
+ Change the Makefile to compile under Mac OS X
+ Fixed a stackoverflow in getDevicesFromMiniSSDPD()
+
+2009/07/09:
+ Compile under Haiku
+ generate miniupnpcstrings.h.in from miniupnpcstrings.h
+
+2009/06/04:
+ patching to compile under CygWin and cross compile for minGW
+
+VERSION 1.3 :
+
+2009/04/17:
+ updating python module
+ Use strtoull() when using C99
+
+2009/02/28:
+ Fixed miniwget.c for compiling under sun
+
+2008/12/18:
+ cleanup in Makefile (thanks to Paul de Weerd)
+ minissdpc.c : win32 compatibility
+ miniupnpc.c : changed xmlns prefix from 'm' to 'u'
+ Removed NDEBUG (using DEBUG)
+
+2008/10/14:
+ Added the ExternalHost argument to DeletePortMapping()
+
+2008/10/11:
+ Added the ExternalHost argument to AddPortMapping()
+ Put a correct User-Agent: header in HTTP requests.
+
+VERSION 1.2 :
+
+2008/10/07:
+ Update docs
+
+2008/09/25:
+ Integrated sameport patch from Dario Meloni : Added a "sameport"
+ argument to upnpDiscover().
+
+2008/07/18:
+ small modif to make Clang happy :)
+
+2008/07/17:
+ #define SOAPPREFIX "s" in miniupnpc.c in order to remove SOAP-ENV...
+
+2008/07/14:
+ include declspec.h in installation (to /usr/include/miniupnpc)
+
+VERSION 1.1 :
+
+2008/07/04:
+ standard options for install/ln instead of gnu-specific stuff.
+
+2008/07/03:
+ now builds a .dll and .lib with win32. (mingw32)
+
+2008/04/28:
+ make install now install the binary of the upnpc tool
+
+2008/04/27:
+ added testupnpigd.py
+ added error strings for miniupnpc "internal" errors
+ improved python module error/exception reporting.
+
+2008/04/23:
+ Completely rewrite igd_desc_parse.c in order to be compatible with
+ Linksys WAG200G
+ Added testigddescparse
+ updated python module
+
+VERSION 1.0 :
+
+2008/02/21:
+ put some #ifdef DEBUG around DisplayNameValueList()
+
+2008/02/18:
+ Improved error reporting in upnpcommands.c
+ UPNP_GetStatusInfo() returns LastConnectionError
+
+2008/02/16:
+ better error handling in minisoap.c
+ improving display of "valid IGD found" in upnpc.c
+
+2008/02/03:
+ Fixing UPNP_GetValidIGD()
+ improved make install :)
+
+2007/12/22:
+ Adding upnperrors.c/h to provide a strupnperror() function
+ used to translate UPnP error codes to string.
+
+2007/12/19:
+ Fixing getDevicesFromMiniSSDPD()
+ improved error reporting of UPnP functions
+
+2007/12/18:
+ It is now possible to specify a different location for MiniSSDPd socket.
+ working with MiniSSDPd is now more efficient.
+ python module improved.
+
+2007/12/16:
+ improving error reporting
+
+2007/12/13:
+ Try to improve compatibility by using HTTP/1.0 instead of 1.1 and
+ XML a bit different for SOAP.
+
+2007/11/25:
+ fixed select() call for linux
+
+2007/11/15:
+ Added -fPIC to CFLAG for better shared library code.
+
+2007/11/02:
+ Fixed a potential socket leak in miniwget2()
+
+2007/10/16:
+ added a parameter to upnpDiscover() in order to allow the use of another
+ interface than the default multicast interface.
+
+2007/10/12:
+ Fixed the creation of symbolic link in Makefile
+
+2007/10/08:
+ Added man page
+
+2007/10/02:
+ fixed memory bug in GetUPNPUrls()
+
+2007/10/01:
+ fixes in the Makefile
+ Added UPNP_GetIGDFromUrl() and adapted the sample program accordingly.
+ Added SONAME in the shared library to please debian :)
+ fixed MS Windows compilation (minissdpd is not available under MS Windows).
+
+2007/09/25:
+ small change to Makefile to be able to install in a different location
+ (default is /usr)
+
+2007/09/24:
+ now compiling both shared and static library
+
+2007/09/19:
+ Cosmetic changes on upnpc.c
+
+2007/09/02:
+ adapting to new miniSSDPd (release version ?)
+
+2007/08/31:
+ Usage of miniSSDPd to skip discovery process.
+
+2007/08/27:
+ fixed python module to allow compilation with Python older than Python 2.4
+
+2007/06/12:
+ Added a python module.
+
+2007/05/19:
+ Fixed compilation under MinGW
+
+2007/05/15:
+ fixed a memory leak in AddPortMapping()
+ Added testupnpreplyparse executable to check the parsing of
+ upnp soap messages
+ minixml now ignore namespace prefixes.
+
+2007/04/26:
+ upnpc now displays external ip address with -s or -l
+
+2007/04/11:
+ changed MINIUPNPC_URL_MAXSIZE to 128 to accomodate the "BT Voyager 210"
+
+2007/03/19:
+ cleanup in miniwget.c
+
+2007/03/01:
+ Small typo fix...
+
+2007/01/30:
+ Now parsing the HTTP header from SOAP responses in order to
+ get content-length value.
+
+2007/01/29:
+ Fixed the Soap Query to speedup the HTTP request.
+ added some Win32 DLL stuff...
+
+2007/01/27:
+ Fixed some WIN32 compatibility issues
+
+2006/12/14:
+ Added UPNPIGD_IsConnected() function in miniupnp.c/.h
+ Added UPNP_GetValidIGD() in miniupnp.c/.h
+ cleaned upnpc.c main(). now using UPNP_GetValidIGD()
+
+2006/12/07:
+ Version 1.0-RC1 released
+
+2006/12/03:
+ Minor changes to compile under SunOS/Solaris
+
+2006/11/30:
+ made a minixml parser validator program
+ updated minixml to handle attributes correctly
+
+2006/11/22:
+ Added a -r option to the upnpc sample thanks to Alexander Hubmann.
+
+2006/11/19:
+ Cleanup code to make it more ANSI C compliant
+
+2006/11/10:
+ detect and display local lan address.
+
+2006/11/04:
+ Packets and Bytes Sent/Received are now unsigned int.
+
+2006/11/01:
+ Bug fix thanks to Giuseppe D'Angelo
+
+2006/10/31:
+ C++ compatibility for .h files.
+ Added a way to get ip Address on the LAN used to reach the IGD.
+
+2006/10/25:
+ Added M-SEARCH to the services in the discovery process.
+
+2006/10/22:
+ updated the Makefile to use makedepend, added a "make install"
+ update Makefile
+
+2006/10/20:
+ fixing the description url parsing thanks to patch sent by
+ Wayne Dawe.
+ Fixed/translated some comments.
+ Implemented a better discover process, first looking
+ for IGD then for root devices (as some devices only reply to
+ M-SEARCH for root devices).
+
+2006/09/02:
+ added freeUPNPDevlist() function.
+
+2006/08/04:
+ More command line arguments checking
+
+2006/08/01:
+ Added the .bat file to compile under Win32 with minGW32
+
+2006/07/31:
+ Fixed the rootdesc parser (igd_desc_parse.c)
+
+2006/07/20:
+ parseMSEARCHReply() is now returning the ST: line as well
+ starting changes to detect several UPnP devices on the network
+
+2006/07/19:
+ using GetCommonLinkProperties to get down/upload bitrate
+
=== added file 'miniupnpc/VERSION'
--- miniupnpc/VERSION 1970-01-01 00:00:00 +0000
+++ miniupnpc/VERSION 2010-12-12 21:16:33 +0000
@@ -0,0 +1,1 @@
+1.4
=== modified file 'miniupnpc/miniupnpc.c'
--- miniupnpc/miniupnpc.c 2010-10-05 21:48:07 +0000
+++ miniupnpc/miniupnpc.c 2010-12-12 21:16:33 +0000
@@ -1,4 +1,4 @@
-/* $Id: miniupnpc.c,v 1.81 2010/04/17 22:07:59 nanard Exp $ */
+/* $Id: miniupnpc.c,v 1.83 2010/12/09 16:11:32 nanard Exp $ */
/* Project : miniupnp
* Author : Thomas BERNARD
* copyright (c) 2005-2010 Thomas Bernard
@@ -26,6 +26,9 @@
#include <io.h>
#include <iphlpapi.h>
#define snprintf _snprintf
+#ifdef strncasecmp
+#undef strncasecmp
+#endif
#if defined(_MSC_VER) && (_MSC_VER >= 1400)
#define strncasecmp _memicmp
#else /* defined(_MSC_VER) && (_MSC_VER >= 1400) */
@@ -99,6 +102,7 @@
#endif
}
+#if 0
/* getcontentlenfromline() : parse the Content-Length HTTP header line.
* Content-length: nnn */
static int getcontentlenfromline(const char * p, int n)
@@ -167,6 +171,7 @@
}
}
}
+#endif
/* simpleUPnPcommand2 :
* not so simple !
@@ -183,9 +188,9 @@
char soapact[128];
char soapbody[2048];
char * buf;
- int buffree;
+ /*int buffree;*/
int n;
- int contentlen, headerlen; /* for the response */
+ /*int contentlen, headerlen;*/ /* for the response */
snprintf(soapact, sizeof(soapact), "%s#%s", service, action);
if(args==NULL)
@@ -272,6 +277,7 @@
return -1;
}
+#if 0
contentlen = -1;
headerlen = -1;
buf = buffer;
@@ -291,7 +297,22 @@
if(contentlen > 0 && headerlen > 0 && *bufsize >= contentlen+headerlen)
break;
}
-
+#endif
+ buf = getHTTPResponse(s, &n);
+ if(n > 0 && buf)
+ {
+ if(*bufsize > n)
+ {
+ memcpy(buffer, buf, n);
+ *bufsize = n;
+ }
+ else
+ {
+ memcpy(buffer, buf, *bufsize);
+ }
+ free(buf);
+ buf = 0;
+ }
closesocket(s);
return 0;
}
@@ -306,8 +327,10 @@
char * buffer, int * bufsize)
{
int result;
- int origbufsize = *bufsize;
+ /*int origbufsize = *bufsize;*/
+ result = simpleUPnPcommand2(s, url, service, action, args, buffer, bufsize, "1.1");
+/*
result = simpleUPnPcommand2(s, url, service, action, args, buffer, bufsize, "1.0");
if (result < 0 || *bufsize == 0)
{
@@ -317,6 +340,7 @@
*bufsize = origbufsize;
result = simpleUPnPcommand2(s, url, service, action, args, buffer, bufsize, "1.1");
}
+*/
return result;
}
=== modified file 'miniupnpc/miniwget.c'
--- miniupnpc/miniwget.c 2010-06-18 12:09:55 +0000
+++ miniupnpc/miniwget.c 2010-12-12 21:16:33 +0000
@@ -1,4 +1,4 @@
-/* $Id: miniwget.c,v 1.37 2010/04/12 20:39:42 nanard Exp $ */
+/* $Id: miniwget.c,v 1.38 2010/12/09 15:54:25 nanard Exp $ */
/* Project : miniupnp
* Author : Thomas Bernard
* Copyright (c) 2005-2010 Thomas Bernard
@@ -8,6 +8,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <ctype.h>
#include "miniupnpc.h"
#ifdef WIN32
#include <winsock2.h>
@@ -16,6 +17,14 @@
#define MAXHOSTNAMELEN 64
#define MIN(x,y) (((x)<(y))?(x):(y))
#define snprintf _snprintf
+#ifdef strncasecmp
+#undef strncasecmp
+#endif
+#if defined(_MSC_VER) && (_MSC_VER >= 1400)
+#define strncasecmp _memicmp
+#else /* defined(_MSC_VER) && (_MSC_VER >= 1400) */
+#define strncasecmp memicmp
+#endif /* defined(_MSC_VER) && (_MSC_VER >= 1400) */
#define socklen_t int
#else /* #ifdef WIN32 */
#include <unistd.h>
@@ -41,6 +50,227 @@
#include "miniwget.h"
#include "connecthostport.h"
+/*
+ * Read a HTTP response from a socket.
+ * Process Content-Length and Transfer-encoding headers.
+ */
+void *
+getHTTPResponse(int s, int * size)
+{
+ char buf[2048];
+ int n;
+ int headers = 1;
+ int chunked = 0;
+ int content_length = -1;
+ unsigned int chunksize = 0;
+ /* buffers : */
+ char * header_buf;
+ int header_buf_len = 2048;
+ int header_buf_used = 0;
+ char * content_buf;
+ int content_buf_len = 2048;
+ int content_buf_used = 0;
+
+ header_buf = malloc(header_buf_len);
+ content_buf = malloc(content_buf_len);
+
+ while((n = ReceiveData(s, buf, 2048, 5000)) > 0)
+ {
+ if(headers)
+ {
+ int i;
+ int linestart=0;
+ int colon=0;
+ int valuestart=0;
+ if(header_buf_used + n > header_buf_len) {
+ header_buf = realloc(header_buf, header_buf_used + n);
+ header_buf_len = header_buf_used + n;
+ }
+ memcpy(header_buf + header_buf_used, buf, n);
+ header_buf_used += n;
+ for(i = 0; i < (header_buf_used-3); i++) {
+ if(colon <= linestart && header_buf[i]==':')
+ {
+ colon = i;
+ while(i < (n-3)
+ && (header_buf[i+1] == ' ' || header_buf[i+1] == '\t'))
+ i++;
+ valuestart = i + 1;
+ }
+ /* detecting end of line */
+ else if(header_buf[i]=='\r' && header_buf[i+1]=='\n')
+ {
+ if(colon > linestart && valuestart > colon)
+ {
+#ifdef DEBUG
+ printf("header='%.*s', value='%.*s'\n",
+ colon-linestart, header_buf+linestart,
+ i-valuestart, header_buf+valuestart);
+#endif
+ if(0==strncasecmp(header_buf+linestart, "content-length", colon-linestart))
+ {
+ content_length = atoi(header_buf+valuestart);
+#ifdef DEBUG
+ printf("Content-Length: %d\n", content_length);
+#endif
+ }
+ else if(0==strncasecmp(header_buf+linestart, "transfer-encoding", colon-linestart)
+ && 0==strncasecmp(buf+valuestart, "chunked", 7))
+ {
+#ifdef DEBUG
+ printf("chunked transfer-encoding!\n");
+#endif
+ chunked = 1;
+ }
+ }
+ linestart = i+2;
+ colon = linestart;
+ valuestart = 0;
+ }
+ /* searching for the end of the HTTP headers */
+ if(header_buf[i]=='\r' && header_buf[i+1]=='\n'
+ && header_buf[i+2]=='\r' && header_buf[i+3]=='\n')
+ {
+ headers = 0; /* end */
+ i += 4;
+ if(i < header_buf_used)
+ {
+ if(chunked)
+ {
+ while(i<header_buf_used && isxdigit(header_buf[i]))
+ {
+ if(header_buf[i] >= '0' && header_buf[i] <= '9')
+ chunksize = (chunksize << 4) + (header_buf[i] - '0');
+ else
+ chunksize = (chunksize << 4) + ((header_buf[i] | 32) - 'a' + 10);
+ i++;
+ }
+ /* discarding chunk-extension */
+ while(i < header_buf_used && header_buf[i] != '\r') i++;
+ if(i < header_buf_used && header_buf[i] == '\r') i++;
+ if(i < header_buf_used && header_buf[i] == '\n') i++;
+#ifdef DEBUG
+ printf("chunksize = %u (%x)\n", chunksize, chunksize);
+#endif
+ if(chunksize == 0)
+ {
+#ifdef DEBUG
+ printf("end of stream !\n");
+#endif
+ goto end_of_stream;
+ }
+ if(header_buf_used - i <= chunksize)
+ {
+ if(content_buf_len < header_buf_used - i)
+ {
+ content_buf = realloc(content_buf, header_buf_used - i);
+ content_buf_len = header_buf_used - i;
+ }
+ memcpy(content_buf, header_buf + i, header_buf_used - i);
+ content_buf_used = header_buf_used - i;
+ chunksize -= (header_buf_used - i);
+ i = header_buf_used;
+ }
+ else
+ {
+ printf("arg ! chunksize < (header_buf_used - i)\n");
+ }
+ }
+ else
+ {
+ if(content_buf_len < header_buf_used - i)
+ {
+ content_buf = realloc(content_buf, header_buf_used - i);
+ content_buf_len = header_buf_used - i;
+ }
+ memcpy(content_buf, header_buf + i, header_buf_used - i);
+ content_buf_used = header_buf_used - i;
+ }
+ }
+ }
+ }
+ }
+ else
+ {
+ /* content */
+ if(chunked)
+ {
+ int i = 0;
+ unsigned bytestocopy;
+ while(i < n)
+ {
+ if(chunksize == 0)
+ {
+ /* reading chunk size */
+ if(i<n && buf[i] == '\r') i++;
+ if(i<n && buf[i] == '\n') i++;
+ while(i<n && isxdigit(buf[i]))
+ {
+ if(buf[i] >= '0' && buf[i] <= '9')
+ chunksize = (chunksize << 4) + (buf[i] - '0');
+ else
+ chunksize = (chunksize << 4) + ((buf[i] | 32) - 'a' + 10);
+ i++;
+ }
+ while(i<n && buf[i] != '\r') i++; /* discarding chunk-extension */
+ if(i<n && buf[i] == '\r') i++;
+ if(i<n && buf[i] == '\n') i++;
+#ifdef DEBUG
+ printf("chunksize = %u (%x)\n", chunksize, chunksize);
+#endif
+ if(chunksize == 0)
+ {
+#ifdef DEBUG
+ printf("end of stream - %d %d\n", i, n);
+ /*printf("'%.*s'\n", n-i, buf+i);*/
+#endif
+ goto end_of_stream;
+ }
+ }
+ bytestocopy = (chunksize < n - i)?chunksize:(n - i);
+ if(content_buf_used + bytestocopy > content_buf_len)
+ {
+ content_buf = (char *)realloc((void *)content_buf,
+ content_buf_used + bytestocopy);
+ content_buf_len = content_buf_used + bytestocopy;
+ }
+ memcpy(content_buf + content_buf_used, buf + i, bytestocopy);
+ content_buf_used += bytestocopy;
+ i += bytestocopy;
+ chunksize -= bytestocopy;
+ }
+ }
+ else
+ {
+ if(content_buf_used + n > content_buf_len)
+ {
+ content_buf = (char *)realloc((void *)content_buf,
+ content_buf_used + n);
+ content_buf_len = content_buf_used + n;
+ }
+ memcpy(content_buf + content_buf_used, buf, n);
+ content_buf_used += n;
+ }
+ }
+ if(content_length > 0 && content_buf_used >= content_length)
+ {
+#ifdef DEBUG
+ printf("termine!\n");
+#endif
+ break;
+ }
+ }
+end_of_stream:
+ free(header_buf); header_buf = NULL;
+ *size = content_buf_used;
+ if(content_buf_used == 0)
+ {
+ free(content_buf);
+ content_buf = NULL;
+ }
+ return content_buf;
+}
+
/* miniwget3() :
* do all the work.
* Return NULL if something failed. */
@@ -126,54 +356,7 @@
sent += n;
}
}
- {
- /* TODO : in order to support HTTP/1.1, chunked transfer encoding
- * must be supported. That means parsing of headers must be
- * added. */
- int headers=1;
- char * respbuffer = NULL;
- int allreadyread = 0;
- /*while((n = recv(s, buf, 2048, 0)) > 0)*/
- while((n = ReceiveData(s, buf, 2048, 5000)) > 0)
- {
- if(headers)
- {
- int i=0;
- while(i<n-3)
- {
- /* searching for the end of the HTTP headers */
- if(buf[i]=='\r' && buf[i+1]=='\n'
- && buf[i+2]=='\r' && buf[i+3]=='\n')
- {
- headers = 0; /* end */
- if(i<n-4)
- {
- /* Copy the content into respbuffet */
- respbuffer = (char *)realloc((void *)respbuffer,
- allreadyread+(n-i-4));
- memcpy(respbuffer+allreadyread, buf + i + 4, n-i-4);
- allreadyread += (n-i-4);
- }
- break;
- }
- i++;
- }
- }
- else
- {
- respbuffer = (char *)realloc((void *)respbuffer,
- allreadyread+n);
- memcpy(respbuffer+allreadyread, buf, n);
- allreadyread += n;
- }
- }
- *size = allreadyread;
-#ifdef DEBUG
- printf("%d bytes read\n", *size);
-#endif
- closesocket(s);
- return respbuffer;
- }
+ return getHTTPResponse(s, size);
}
/* miniwget2() :
@@ -185,6 +368,8 @@
{
char * respbuffer;
+ respbuffer = miniwget3(url, host, port, path, size, addr_str, addr_str_len, "1.1");
+/*
respbuffer = miniwget3(url, host, port, path, size, addr_str, addr_str_len, "1.0");
if (*size == 0)
{
@@ -194,6 +379,7 @@
free(respbuffer);
respbuffer = miniwget3(url, host, port, path, size, addr_str, addr_str_len, "1.1");
}
+*/
return respbuffer;
}
=== modified file 'miniupnpc/miniwget.h'
--- miniupnpc/miniwget.h 2009-12-06 18:07:44 +0000
+++ miniupnpc/miniwget.h 2010-12-12 21:16:33 +0000
@@ -1,4 +1,4 @@
-/* $Id: miniwget.h,v 1.5 2007/01/29 20:27:23 nanard Exp $ */
+/* $Id: miniwget.h,v 1.6 2010/12/09 16:11:33 nanard Exp $ */
/* Project : miniupnp
* Author : Thomas Bernard
* Copyright (c) 2005 Thomas Bernard
@@ -14,6 +14,8 @@
extern "C" {
#endif
+LIBSPEC void * getHTTPResponse(int s, int * size);
+
LIBSPEC void * miniwget(const char *, int *);
LIBSPEC void * miniwget_getaddr(const char *, int *, char *, int);