mirror of
https://github.com/darlinghq/darling-libxml2.git
synced 2025-01-27 05:23:51 +00: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:
parent
fc8dc355da
commit
847332a0da
@ -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>
|
||||
|
||||
* xmlreader.c include/libxml/xmlreader.h: added new APIs
|
||||
|
@ -51,7 +51,11 @@ XMLPUBFUN void * XMLCALL
|
||||
XMLPUBFUN int XMLCALL
|
||||
xmlNanoHTTPReturnCode (void *ctx);
|
||||
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
|
||||
xmlNanoHTTPRead (void *ctx,
|
||||
void *dest,
|
||||
|
32
nanohttp.c
32
nanohttp.c
@ -149,6 +149,7 @@ typedef struct xmlNanoHTTPCtxt {
|
||||
char *contentType; /* the MIME type for the input */
|
||||
char *location; /* the new URL in case of redirect */
|
||||
char *authHeader; /* contents of {WWW,Proxy}-Authenticate header */
|
||||
char *encoding; /* encoding extracted from the contentType */
|
||||
} xmlNanoHTTPCtxt, *xmlNanoHTTPCtxtPtr;
|
||||
|
||||
static int initialized = 0;
|
||||
@ -528,6 +529,7 @@ xmlNanoHTTPFreeCtxt(xmlNanoHTTPCtxtPtr ctxt) {
|
||||
if (ctxt->out != NULL) xmlFree(ctxt->out);
|
||||
if (ctxt->in != NULL) xmlFree(ctxt->in);
|
||||
if (ctxt->contentType != NULL) xmlFree(ctxt->contentType);
|
||||
if (ctxt->encoding != NULL) xmlFree(ctxt->encoding);
|
||||
if (ctxt->location != NULL) xmlFree(ctxt->location);
|
||||
if (ctxt->authHeader != NULL) xmlFree(ctxt->authHeader);
|
||||
ctxt->state = XML_NANO_HTTP_NONE;
|
||||
@ -1576,6 +1578,36 @@ xmlNanoHTTPContentLength( void * ctx ) {
|
||||
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:
|
||||
* @ctx: the HTTP context
|
||||
|
22
xmlIO.c
22
xmlIO.c
@ -2108,6 +2108,7 @@ xmlOutputBufferClose(xmlOutputBufferPtr out)
|
||||
xmlParserInputBufferPtr
|
||||
xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
|
||||
xmlParserInputBufferPtr ret;
|
||||
int is_http = 0;
|
||||
int i = 0;
|
||||
void *context = NULL;
|
||||
|
||||
@ -2125,8 +2126,11 @@ xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
|
||||
if ((xmlInputCallbackTable[i].matchcallback != NULL) &&
|
||||
(xmlInputCallbackTable[i].matchcallback(URI) != 0)) {
|
||||
context = xmlInputCallbackTable[i].opencallback(URI);
|
||||
if (context != NULL)
|
||||
if (context != NULL) {
|
||||
if (xmlInputCallbackTable[i].opencallback == xmlIOHTTPOpen)
|
||||
is_http = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -3080,6 +3084,22 @@ xmlDefaultExternalEntityLoader(const char *URL, const char *ID,
|
||||
xmlLoaderErr(ctxt, "failed to load external entity \"%s\"\n",
|
||||
(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))
|
||||
xmlFree(resource);
|
||||
return(ret);
|
||||
|
Loading…
x
Reference in New Issue
Block a user