- TODO: updated - nanohttp.[ch] : started adding APIs to get the
- TODO: updated
- nanohttp.[ch] : started adding APIs to get the redirected URL
when this occurs (needed for further base computation
- tree.h: cleanup
- encoding.c: cleanup
- SAX.c: minor change around ctxt->loadsubset
Daniel
diff --git a/ChangeLog b/ChangeLog
index 002347a..65145b3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,12 @@
+Mon May 28 12:56:29 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
+
+ * TODO: updated
+ * nanohttp.[ch] : started adding APIs to get the redirected URL
+ when this occurs (needed for further base computation
+ * tree.h: cleanup
+ * encoding.c: cleanup
+ * SAX.c: minor change around ctxt->loadsubset
+
Fri May 25 09:36:26 CEST 2001 Daniel Veillard <Daniel.Veillard@imag.fr>
* Makefile.am include/Makefile.am: small change to have
diff --git a/SAX.c b/SAX.c
index ca5ae0f..03f3988 100644
--- a/SAX.c
+++ b/SAX.c
@@ -201,7 +201,7 @@
name, ExternalID, SystemID);
#endif
if (((ExternalID != NULL) || (SystemID != NULL)) &&
- (((ctxt->validate) || (ctxt->loadsubset)) &&
+ (((ctxt->validate) || (ctxt->loadsubset != 0)) &&
(ctxt->wellFormed && ctxt->myDoc))) {
/*
* Try to fetch and parse the external subset.
diff --git a/TODO b/TODO
index 2225635..1f4ce25 100644
--- a/TODO
+++ b/TODO
@@ -11,8 +11,6 @@
- Computation of base when HTTP redirect occurs, might affect HTTP
interfaces.
-- DOM needs
- int xmlPruneProp(xmlNodePtr node, xmlAtttrPtr attr);
- listing all attributes in a node.
- Correct standalone checking/emitting (hard)
2.9 Standalone Document Declaration
@@ -108,6 +106,10 @@
Done:
=====
+- DOM needs
+ int xmlPruneProp(xmlNodePtr node, xmlAtttrPtr attr);
+ => done it's actually xmlRemoveProp xmlUnsetProp xmlUnsetNsProp
+
- HTML: handling of Script and style data elements, need special code in
the parser and saving functions (handling of < > " ' ...):
http://www.w3.org/TR/html4/types.html#type-script
diff --git a/encoding.c b/encoding.c
index f03285d..020f4de 100644
--- a/encoding.c
+++ b/encoding.c
@@ -1690,43 +1690,43 @@
*/
static int
xmlIconvWrapper(iconv_t cd,
- unsigned char *out, int *outlen,
- const unsigned char *in, int *inlen) {
+ unsigned char *out, int *outlen,
+ const unsigned char *in, int *inlen) {
- size_t icv_inlen = *inlen, icv_outlen = *outlen;
- const char *icv_in = (const char *) in;
- char *icv_out = (char *) out;
- int ret;
+ size_t icv_inlen = *inlen, icv_outlen = *outlen;
+ const char *icv_in = (const char *) in;
+ char *icv_out = (char *) out;
+ int ret;
- ret = iconv(cd, &icv_in, &icv_inlen, &icv_out, &icv_outlen);
- if (in != NULL) {
- *inlen -= icv_inlen;
- *outlen -= icv_outlen;
- } else {
- *inlen = 0;
- *outlen = 0;
- }
- if ((icv_inlen != 0) || (ret == -1)) {
+ ret = iconv(cd, &icv_in, &icv_inlen, &icv_out, &icv_outlen);
+ if (in != NULL) {
+ *inlen -= icv_inlen;
+ *outlen -= icv_outlen;
+ } else {
+ *inlen = 0;
+ *outlen = 0;
+ }
+ if ((icv_inlen != 0) || (ret == -1)) {
#ifdef EILSEQ
- if (errno == EILSEQ) {
- return -2;
- } else
+ if (errno == EILSEQ) {
+ return -2;
+ } else
#endif
#ifdef E2BIG
- if (errno == E2BIG) {
- return -1;
- } else
+ if (errno == E2BIG) {
+ return -1;
+ } else
#endif
#ifdef EINVAL
- if (errno == EINVAL) {
- return -3;
- } else
+ if (errno == EINVAL) {
+ return -3;
+ } else
#endif
- {
- return -3;
- }
- }
- return 0;
+ {
+ return -3;
+ }
+ }
+ return 0;
}
#endif /* LIBXML_ICONV_ENABLED */
diff --git a/include/libxml/nanohttp.h b/include/libxml/nanohttp.h
index 78d1c44..6738f8a 100644
--- a/include/libxml/nanohttp.h
+++ b/include/libxml/nanohttp.h
@@ -26,8 +26,17 @@
const char *input,
char **contentType,
const char *headers);
+void * xmlNanoHTTPMethodRedir (const char *URL,
+ const char *method,
+ const char *input,
+ char **contentType,
+ char **redir,
+ const char *headers);
void * xmlNanoHTTPOpen (const char *URL,
char **contentType);
+void * xmlNanoHTTPOpenRedir (const char *URL,
+ char **contentType,
+ char **redir);
int xmlNanoHTTPReturnCode (void *ctx);
const char * xmlNanoHTTPAuthHeader(void *ctx);
int xmlNanoHTTPRead (void *ctx,
diff --git a/include/libxml/tree.h b/include/libxml/tree.h
index 463daaa..f272b99 100644
--- a/include/libxml/tree.h
+++ b/include/libxml/tree.h
@@ -675,8 +675,6 @@
const xmlChar *value);
xmlChar * xmlGetProp (xmlNodePtr node,
const xmlChar *name);
-int xmlUnsetProp (xmlNodePtr node,
- const xmlChar *name);
xmlAttrPtr xmlHasProp (xmlNodePtr node,
const xmlChar *name);
xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
@@ -686,9 +684,6 @@
xmlChar * xmlGetNsProp (xmlNodePtr node,
const xmlChar *name,
const xmlChar *nameSpace);
-int xmlUnsetNsProp (xmlNodePtr node,
- xmlNsPtr ns,
- const xmlChar *name);
xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc,
const xmlChar *value);
xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc,
@@ -727,6 +722,11 @@
*/
int xmlRemoveProp (xmlAttrPtr attr);
int xmlRemoveNode (xmlNodePtr node); /* TODO */
+int xmlUnsetProp (xmlNodePtr node,
+ const xmlChar *name);
+int xmlUnsetNsProp (xmlNodePtr node,
+ xmlNsPtr ns,
+ const xmlChar *name);
/*
* Internal, don't use
diff --git a/nanohttp.c b/nanohttp.c
index 00b7fde..31ed07c 100644
--- a/nanohttp.c
+++ b/nanohttp.c
@@ -814,7 +814,28 @@
void*
xmlNanoHTTPOpen(const char *URL, char **contentType) {
if (contentType != NULL) *contentType = NULL;
- return xmlNanoHTTPMethod(URL, NULL, NULL, contentType, NULL);
+ return(xmlNanoHTTPMethod(URL, NULL, NULL, contentType, NULL));
+}
+
+/**
+ * xmlNanoHTTPOpenRedir:
+ * @URL: The URL to load
+ * @contentType: if available the Content-Type information will be
+ * returned at that location
+ * @redir: if availble the redirected URL will be returned
+ *
+ * This function try to open a connection to the indicated resource
+ * via HTTP GET.
+ *
+ * Returns NULL in case of failure, otherwise a request handler.
+ * The contentType, if provided must be freed by the caller
+ */
+
+void*
+xmlNanoHTTPOpenRedir(const char *URL, char **contentType, char **redir) {
+ if (contentType != NULL) *contentType = NULL;
+ if (redir != NULL) *redir = NULL;
+ return(xmlNanoHTTPMethodRedir(URL, NULL, NULL, contentType, redir, NULL));
}
/**
@@ -864,11 +885,12 @@
}
/**
- * xmlNanoHTTPMethod:
+ * xmlNanoHTTPMethodRedir:
* @URL: The URL to load
* @method: the HTTP method to use
* @input: the input string if any
* @contentType: the Content-Type information IN and OUT
+ * @redir: the redirected URL OUT
* @headers: the extra headers
*
* This function try to open a connection to the indicated resource
@@ -876,12 +898,12 @@
* and the input buffer for the request content.
*
* Returns NULL in case of failure, otherwise a request handler.
- * The contentType, if provided must be freed by the caller
+ * The contentType, or redir, if provided must be freed by the caller
*/
void*
-xmlNanoHTTPMethod(const char *URL, const char *method, const char *input,
- char **contentType, const char *headers) {
+xmlNanoHTTPMethodRedir(const char *URL, const char *method, const char *input,
+ char **contentType, char **redir, const char *headers) {
xmlNanoHTTPCtxtPtr ctxt;
char *bp, *p;
int blen, ilen, ret;
@@ -898,8 +920,6 @@
ctxt = xmlNanoHTTPNewCtxt(URL);
else {
ctxt = xmlNanoHTTPNewCtxt(redirURL);
- xmlFree(redirURL);
- redirURL = NULL;
}
if ((ctxt->protocol == NULL) || (strcmp(ctxt->protocol, "http"))) {
@@ -909,6 +929,7 @@
}
if (ctxt->hostname == NULL) {
xmlNanoHTTPFreeCtxt(ctxt);
+ if (redirURL != NULL) xmlFree(redirURL);
return(NULL);
}
if (proxy) {
@@ -921,6 +942,7 @@
}
if (ret < 0) {
xmlNanoHTTPFreeCtxt(ctxt);
+ if (redirURL != NULL) xmlFree(redirURL);
return(NULL);
}
ctxt->fd = ret;
@@ -999,11 +1021,14 @@
while (xmlNanoHTTPRecv(ctxt)) ;
if (nbRedirects < XML_NANO_HTTP_MAX_REDIR) {
nbRedirects++;
+ if (redirURL != NULL)
+ xmlFree(redirURL);
redirURL = xmlMemStrdup(ctxt->location);
xmlNanoHTTPFreeCtxt(ctxt);
goto retry;
}
xmlNanoHTTPFreeCtxt(ctxt);
+ if (redirURL != NULL) xmlFree(redirURL);
#ifdef DEBUG_HTTP
xmlGenericError(xmlGenericErrorContext,
"Too many redirects, aborting ...\n");
@@ -1019,6 +1044,15 @@
*contentType = NULL;
}
+ if ((redir != NULL) && (redirURL != NULL)) {
+ *redir = redirURL;
+ } else {
+ if (redirURL != NULL)
+ xmlFree(redirURL);
+ if (redir != NULL)
+ *redir = NULL;
+ }
+
#ifdef DEBUG_HTTP
if (ctxt->contentType != NULL)
xmlGenericError(xmlGenericErrorContext,
@@ -1034,6 +1068,29 @@
}
/**
+ * xmlNanoHTTPMethod:
+ * @URL: The URL to load
+ * @method: the HTTP method to use
+ * @input: the input string if any
+ * @contentType: the Content-Type information IN and OUT
+ * @headers: the extra headers
+ *
+ * This function try to open a connection to the indicated resource
+ * via HTTP using the given @method, adding the given extra headers
+ * and the input buffer for the request content.
+ *
+ * Returns NULL in case of failure, otherwise a request handler.
+ * The contentType, if provided must be freed by the caller
+ */
+
+void*
+xmlNanoHTTPMethod(const char *URL, const char *method, const char *input,
+ char **contentType, const char *headers) {
+ return(xmlNanoHTTPMethodRedir(URL, method, input, contentType,
+ NULL, headers));
+}
+
+/**
* xmlNanoHTTPFetch:
* @URL: The URL to load
* @filename: the filename where the content should be saved
diff --git a/nanohttp.h b/nanohttp.h
index 78d1c44..6738f8a 100644
--- a/nanohttp.h
+++ b/nanohttp.h
@@ -26,8 +26,17 @@
const char *input,
char **contentType,
const char *headers);
+void * xmlNanoHTTPMethodRedir (const char *URL,
+ const char *method,
+ const char *input,
+ char **contentType,
+ char **redir,
+ const char *headers);
void * xmlNanoHTTPOpen (const char *URL,
char **contentType);
+void * xmlNanoHTTPOpenRedir (const char *URL,
+ char **contentType,
+ char **redir);
int xmlNanoHTTPReturnCode (void *ctx);
const char * xmlNanoHTTPAuthHeader(void *ctx);
int xmlNanoHTTPRead (void *ctx,
diff --git a/tree.h b/tree.h
index 463daaa..f272b99 100644
--- a/tree.h
+++ b/tree.h
@@ -675,8 +675,6 @@
const xmlChar *value);
xmlChar * xmlGetProp (xmlNodePtr node,
const xmlChar *name);
-int xmlUnsetProp (xmlNodePtr node,
- const xmlChar *name);
xmlAttrPtr xmlHasProp (xmlNodePtr node,
const xmlChar *name);
xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
@@ -686,9 +684,6 @@
xmlChar * xmlGetNsProp (xmlNodePtr node,
const xmlChar *name,
const xmlChar *nameSpace);
-int xmlUnsetNsProp (xmlNodePtr node,
- xmlNsPtr ns,
- const xmlChar *name);
xmlNodePtr xmlStringGetNodeList (xmlDocPtr doc,
const xmlChar *value);
xmlNodePtr xmlStringLenGetNodeList (xmlDocPtr doc,
@@ -727,6 +722,11 @@
*/
int xmlRemoveProp (xmlAttrPtr attr);
int xmlRemoveNode (xmlNodePtr node); /* TODO */
+int xmlUnsetProp (xmlNodePtr node,
+ const xmlChar *name);
+int xmlUnsetNsProp (xmlNodePtr node,
+ xmlNsPtr ns,
+ const xmlChar *name);
/*
* Internal, don't use