mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-08-07 06:43:02 +03:00
starting work to fix the HTTP/XML parser integration. Daniel
* nanohttp.c xmlIO.c include/libxml/nanohttp.h: starting work to fix the HTTP/XML parser integration. Daniel
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
Sat Oct 18 07:28:25 EDT 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
|
* nanohttp.c xmlIO.c include/libxml/nanohttp.h: starting work
|
||||||
|
to fix the HTTP/XML parser integration.
|
||||||
|
|
||||||
Sat Oct 18 11:04:32 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
Sat Oct 18 11:04:32 CEST 2003 Daniel Veillard <daniel@veillard.com>
|
||||||
|
|
||||||
* xmlreader.c include/libxml/xmlreader.h: added new APIs
|
* xmlreader.c include/libxml/xmlreader.h: added new APIs
|
||||||
|
@@ -52,6 +52,10 @@ XMLPUBFUN int XMLCALL
|
|||||||
xmlNanoHTTPReturnCode (void *ctx);
|
xmlNanoHTTPReturnCode (void *ctx);
|
||||||
XMLPUBFUN const char * XMLCALL
|
XMLPUBFUN const char * XMLCALL
|
||||||
xmlNanoHTTPAuthHeader (void *ctx);
|
xmlNanoHTTPAuthHeader (void *ctx);
|
||||||
|
XMLPUBFUN const char * XMLCALL
|
||||||
|
xmlNanoHTTPRedir (void * ctx);
|
||||||
|
XMLPUBFUN const char * XMLCALL
|
||||||
|
xmlNanoHTTPEncoding (void * ctx);
|
||||||
XMLPUBFUN int XMLCALL
|
XMLPUBFUN int XMLCALL
|
||||||
xmlNanoHTTPRead (void *ctx,
|
xmlNanoHTTPRead (void *ctx,
|
||||||
void *dest,
|
void *dest,
|
||||||
|
32
nanohttp.c
32
nanohttp.c
@@ -149,6 +149,7 @@ typedef struct xmlNanoHTTPCtxt {
|
|||||||
char *contentType; /* the MIME type for the input */
|
char *contentType; /* the MIME type for the input */
|
||||||
char *location; /* the new URL in case of redirect */
|
char *location; /* the new URL in case of redirect */
|
||||||
char *authHeader; /* contents of {WWW,Proxy}-Authenticate header */
|
char *authHeader; /* contents of {WWW,Proxy}-Authenticate header */
|
||||||
|
char *encoding; /* encoding extracted from the contentType */
|
||||||
} xmlNanoHTTPCtxt, *xmlNanoHTTPCtxtPtr;
|
} xmlNanoHTTPCtxt, *xmlNanoHTTPCtxtPtr;
|
||||||
|
|
||||||
static int initialized = 0;
|
static int initialized = 0;
|
||||||
@@ -528,6 +529,7 @@ xmlNanoHTTPFreeCtxt(xmlNanoHTTPCtxtPtr ctxt) {
|
|||||||
if (ctxt->out != NULL) xmlFree(ctxt->out);
|
if (ctxt->out != NULL) xmlFree(ctxt->out);
|
||||||
if (ctxt->in != NULL) xmlFree(ctxt->in);
|
if (ctxt->in != NULL) xmlFree(ctxt->in);
|
||||||
if (ctxt->contentType != NULL) xmlFree(ctxt->contentType);
|
if (ctxt->contentType != NULL) xmlFree(ctxt->contentType);
|
||||||
|
if (ctxt->encoding != NULL) xmlFree(ctxt->encoding);
|
||||||
if (ctxt->location != NULL) xmlFree(ctxt->location);
|
if (ctxt->location != NULL) xmlFree(ctxt->location);
|
||||||
if (ctxt->authHeader != NULL) xmlFree(ctxt->authHeader);
|
if (ctxt->authHeader != NULL) xmlFree(ctxt->authHeader);
|
||||||
ctxt->state = XML_NANO_HTTP_NONE;
|
ctxt->state = XML_NANO_HTTP_NONE;
|
||||||
@@ -1576,6 +1578,36 @@ xmlNanoHTTPContentLength( void * ctx ) {
|
|||||||
return ( ( ctxt == NULL ) ? -1 : ctxt->ContentLength );
|
return ( ( ctxt == NULL ) ? -1 : ctxt->ContentLength );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlNanoHTTPRedir:
|
||||||
|
* @ctx: the HTTP context
|
||||||
|
*
|
||||||
|
* Provides the specified redirection URL if available from the HTTP header.
|
||||||
|
*
|
||||||
|
* Return the specified redirection URL or NULL if not redirected.
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
xmlNanoHTTPRedir( void * ctx ) {
|
||||||
|
xmlNanoHTTPCtxtPtr ctxt = ctx;
|
||||||
|
|
||||||
|
return ( ( ctxt == NULL ) ? NULL : ctxt->location );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* xmlNanoHTTPEncoding:
|
||||||
|
* @ctx: the HTTP context
|
||||||
|
*
|
||||||
|
* Provides the specified encoding if specified in the HTTP headers.
|
||||||
|
*
|
||||||
|
* Return the specified encoding or NULL if not available
|
||||||
|
*/
|
||||||
|
const char *
|
||||||
|
xmlNanoHTTPEncoding( void * ctx ) {
|
||||||
|
xmlNanoHTTPCtxtPtr ctxt = ctx;
|
||||||
|
|
||||||
|
return ( ( ctxt == NULL ) ? NULL : ctxt->encoding );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlNanoHTTPFetchContent:
|
* xmlNanoHTTPFetchContent:
|
||||||
* @ctx: the HTTP context
|
* @ctx: the HTTP context
|
||||||
|
22
xmlIO.c
22
xmlIO.c
@@ -2108,6 +2108,7 @@ xmlOutputBufferClose(xmlOutputBufferPtr out)
|
|||||||
xmlParserInputBufferPtr
|
xmlParserInputBufferPtr
|
||||||
xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
|
xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
|
||||||
xmlParserInputBufferPtr ret;
|
xmlParserInputBufferPtr ret;
|
||||||
|
int is_http = 0;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
void *context = NULL;
|
void *context = NULL;
|
||||||
|
|
||||||
@@ -2125,11 +2126,14 @@ xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
|
|||||||
if ((xmlInputCallbackTable[i].matchcallback != NULL) &&
|
if ((xmlInputCallbackTable[i].matchcallback != NULL) &&
|
||||||
(xmlInputCallbackTable[i].matchcallback(URI) != 0)) {
|
(xmlInputCallbackTable[i].matchcallback(URI) != 0)) {
|
||||||
context = xmlInputCallbackTable[i].opencallback(URI);
|
context = xmlInputCallbackTable[i].opencallback(URI);
|
||||||
if (context != NULL)
|
if (context != NULL) {
|
||||||
|
if (xmlInputCallbackTable[i].opencallback == xmlIOHTTPOpen)
|
||||||
|
is_http = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
if (context == NULL) {
|
if (context == NULL) {
|
||||||
return(NULL);
|
return(NULL);
|
||||||
}
|
}
|
||||||
@@ -3080,6 +3084,22 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID,
|
|||||||
xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n",
|
xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n",
|
||||||
(const char *) resource);
|
(const char *) resource);
|
||||||
}
|
}
|
||||||
|
if ((ret->buf != NULL) && (ret->buf->readcallback == xmlIOHTTPRead)) {
|
||||||
|
const char *encoding;
|
||||||
|
const char *redir;
|
||||||
|
|
||||||
|
encoding = xmlNanoHTTPEncoding(ret->buf->context);
|
||||||
|
redir = xmlNanoHTTPRedir(ret->buf->context);
|
||||||
|
if (redir != NULL) {
|
||||||
|
if (ret->filename != NULL)
|
||||||
|
xmlFree((xmlChar *) ret->filename);
|
||||||
|
if (ret->directory != NULL) {
|
||||||
|
xmlFree((xmlChar *) ret->directory);
|
||||||
|
ret->directory = NULL;
|
||||||
|
}
|
||||||
|
ret->filename = (char *) xmlStrdup((const xmlChar *)redir);
|
||||||
|
}
|
||||||
|
}
|
||||||
if ((resource != NULL) && (resource != (xmlChar *) URL))
|
if ((resource != NULL) && (resource != (xmlChar *) URL))
|
||||||
xmlFree(resource);
|
xmlFree(resource);
|
||||||
return(ret);
|
return(ret);
|
||||||
|
Reference in New Issue
Block a user