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
diff --git a/xmlIO.c b/xmlIO.c
index 67d9c41..d8508cd 100644
--- a/xmlIO.c
+++ b/xmlIO.c
@@ -2108,6 +2108,7 @@
xmlParserInputBufferPtr
xmlParserInputBufferCreateFilename(const char *URI, xmlCharEncoding enc) {
xmlParserInputBufferPtr ret;
+ int is_http = 0;
int i = 0;
void *context = NULL;
@@ -2125,8 +2126,11 @@
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 @@
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);