mirror of
https://github.com/darlinghq/darling-libxml2.git
synced 2025-03-09 05:20:53 +00:00
- 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
This commit is contained in:
parent
6278fb5b30
commit
9403a0495d
@ -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
|
||||
|
2
SAX.c
2
SAX.c
@ -201,7 +201,7 @@ externalSubset(void *ctx, const xmlChar *name,
|
||||
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.
|
||||
|
6
TODO
6
TODO
@ -11,8 +11,6 @@ TODO:
|
||||
|
||||
- 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 @@ EXTENSIONS:
|
||||
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
|
||||
|
58
encoding.c
58
encoding.c
@ -1690,43 +1690,43 @@ xmlFindCharEncodingHandler(const char *name) {
|
||||
*/
|
||||
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 */
|
||||
|
||||
|
@ -26,8 +26,17 @@ void * xmlNanoHTTPMethod (const char *URL,
|
||||
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,
|
||||
|
@ -675,8 +675,6 @@ xmlAttrPtr xmlSetProp (xmlNodePtr node,
|
||||
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 @@ xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
|
||||
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 @@ void xmlNodeSetBase (xmlNodePtr cur,
|
||||
*/
|
||||
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
|
||||
|
71
nanohttp.c
71
nanohttp.c
@ -814,7 +814,28 @@ xmlNanoHTTPConnectHost(const char *host, int port)
|
||||
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 @@ xmlNanoHTTPClose(void *ctx) {
|
||||
}
|
||||
|
||||
/**
|
||||
* 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 @@ xmlNanoHTTPClose(void *ctx) {
|
||||
* 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 @@ retry:
|
||||
ctxt = xmlNanoHTTPNewCtxt(URL);
|
||||
else {
|
||||
ctxt = xmlNanoHTTPNewCtxt(redirURL);
|
||||
xmlFree(redirURL);
|
||||
redirURL = NULL;
|
||||
}
|
||||
|
||||
if ((ctxt->protocol == NULL) || (strcmp(ctxt->protocol, "http"))) {
|
||||
@ -909,6 +929,7 @@ retry:
|
||||
}
|
||||
if (ctxt->hostname == NULL) {
|
||||
xmlNanoHTTPFreeCtxt(ctxt);
|
||||
if (redirURL != NULL) xmlFree(redirURL);
|
||||
return(NULL);
|
||||
}
|
||||
if (proxy) {
|
||||
@ -921,6 +942,7 @@ retry:
|
||||
}
|
||||
if (ret < 0) {
|
||||
xmlNanoHTTPFreeCtxt(ctxt);
|
||||
if (redirURL != NULL) xmlFree(redirURL);
|
||||
return(NULL);
|
||||
}
|
||||
ctxt->fd = ret;
|
||||
@ -999,11 +1021,14 @@ retry:
|
||||
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 @@ retry:
|
||||
*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,
|
||||
@ -1033,6 +1067,29 @@ retry:
|
||||
return((void *) ctxt);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
@ -26,8 +26,17 @@ void * xmlNanoHTTPMethod (const char *URL,
|
||||
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,
|
||||
|
10
tree.h
10
tree.h
@ -675,8 +675,6 @@ xmlAttrPtr xmlSetProp (xmlNodePtr node,
|
||||
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 @@ xmlAttrPtr xmlSetNsProp (xmlNodePtr node,
|
||||
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 @@ void xmlNodeSetBase (xmlNodePtr cur,
|
||||
*/
|
||||
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
|
||||
|
Loading…
x
Reference in New Issue
Block a user