summaryrefslogtreecommitdiff
path: root/nanohttp.c
diff options
context:
space:
mode:
authorMike Hommey <glandium@debian.org>2005-07-12 19:58:48 +0000
committerMike Hommey <glandium@debian.org>2005-07-12 19:58:48 +0000
commit112cb5bb5475afec1c1cbf1d6728ce4880d0fee8 (patch)
tree6c34596134f8665ebc180f29b50915dc70bbe5c1 /nanohttp.c
parent0fc063df3ab2ad380d532d210dd1001de473e51b (diff)
downloadlibxml2-112cb5bb5475afec1c1cbf1d6728ce4880d0fee8.tar.gz
Load /tmp/tmp.zfIyNk/libxml2-2.6.20 intoupstream/2.6.20
packages/libxml2/branches/upstream/current.
Diffstat (limited to 'nanohttp.c')
-rw-r--r--nanohttp.c13
1 files changed, 13 insertions, 0 deletions
diff --git a/nanohttp.c b/nanohttp.c
index 9897c14..de89ab7 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -134,6 +134,7 @@ typedef struct xmlNanoHTTPCtxt {
char *hostname; /* the host name */
int port; /* the port */
char *path; /* the path within the URL */
+ char *query; /* the query string */
SOCKET fd; /* the file descriptor for the socket */
int state; /* WRITE / READ / CLOSED */
char *out; /* buffer sent (zero terminated) */
@@ -284,6 +285,10 @@ xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) {
xmlFree(ctxt->path);
ctxt->path = NULL;
}
+ if (ctxt->query != NULL) {
+ xmlFree(ctxt->query);
+ ctxt->query = NULL;
+ }
if (URL == NULL) return;
uri = xmlParseURI(URL);
@@ -301,6 +306,8 @@ xmlNanoHTTPScanURL(xmlNanoHTTPCtxtPtr ctxt, const char *URL) {
ctxt->path = xmlMemStrdup(uri->path);
else
ctxt->path = xmlMemStrdup("/");
+ if (uri->query != NULL)
+ ctxt->query = xmlMemStrdup(uri->query);
if (uri->port != 0)
ctxt->port = uri->port;
@@ -396,6 +403,7 @@ xmlNanoHTTPFreeCtxt(xmlNanoHTTPCtxtPtr ctxt) {
if (ctxt->hostname != NULL) xmlFree(ctxt->hostname);
if (ctxt->protocol != NULL) xmlFree(ctxt->protocol);
if (ctxt->path != NULL) xmlFree(ctxt->path);
+ if (ctxt->query != NULL) xmlFree(ctxt->query);
if (ctxt->out != NULL) xmlFree(ctxt->out);
if (ctxt->in != NULL) xmlFree(ctxt->in);
if (ctxt->contentType != NULL) xmlFree(ctxt->contentType);
@@ -1229,6 +1237,8 @@ retry:
blen += strlen(headers) + 2;
if (contentType && *contentType)
blen += strlen(*contentType) + 16;
+ if (ctxt->query != NULL)
+ blen += strlen(ctxt->query) + 1;
blen += strlen(method) + strlen(ctxt->path) + 24;
bp = (char*)xmlMallocAtomic(blen);
if ( bp == NULL ) {
@@ -1252,6 +1262,9 @@ retry:
else
p += snprintf( p, blen - (p - bp), "%s %s", method, ctxt->path);
+ if (ctxt->query != NULL)
+ p += snprintf( p, blen - (p - bp), "?%s", ctxt->query);
+
p += snprintf( p, blen - (p - bp), " HTTP/1.0\r\nHost: %s\r\n",
ctxt->hostname);