MCPcopy Create free account
hub / github.com/Kitware/VTK / xmlCheckHTTPInput

Function xmlCheckHTTPInput

ThirdParty/libxml2/vtklibxml2/parserInternals.c:2001–2047  ·  view source on GitHub ↗

* xmlCheckHTTPInput: * @ctxt: an XML parser context * @ret: an XML parser input * * DEPRECATED: Internal function, don't use. * * Check an input in case it was created from an HTTP stream, in that * case it will handle encoding and update of the base URL in case of * redirection. It also checks for HTTP errors in which case the input * is cleanly freed up and an appropriate error is raise

Source from the content-addressed store, hash-verified

1999 * Returns the input or NULL in case of HTTP error.
2000 */
2001xmlParserInputPtr
2002xmlCheckHTTPInput(xmlParserCtxtPtr ctxt, xmlParserInputPtr ret) {
2003 /* Avoid unused variable warning if features are disabled. */
2004 (void) ctxt;
2005
2006#ifdef LIBXML_HTTP_ENABLED
2007 if ((ret != NULL) && (ret->buf != NULL) &&
2008 (ret->buf->readcallback == xmlIOHTTPRead) &&
2009 (ret->buf->context != NULL)) {
2010 const char *encoding;
2011 const char *redir;
2012 const char *mime;
2013 int code;
2014
2015 code = xmlNanoHTTPReturnCode(ret->buf->context);
2016 if (code >= 400) {
2017 /* fatal error */
2018 if (ret->filename != NULL)
2019 xmlCtxtErrIO(ctxt, XML_IO_LOAD_ERROR, ret->filename);
2020 else
2021 xmlCtxtErrIO(ctxt, XML_IO_LOAD_ERROR, "<null>");
2022 xmlFreeInputStream(ret);
2023 ret = NULL;
2024 } else {
2025
2026 mime = xmlNanoHTTPMimeType(ret->buf->context);
2027 if ((xmlStrstr(BAD_CAST mime, BAD_CAST "/xml")) ||
2028 (xmlStrstr(BAD_CAST mime, BAD_CAST "+xml"))) {
2029 encoding = xmlNanoHTTPEncoding(ret->buf->context);
2030 if (encoding != NULL)
2031 xmlSwitchEncodingName(ctxt, encoding);
2032#if 0
2033 } else if (xmlStrstr(BAD_CAST mime, BAD_CAST "html")) {
2034#endif
2035 }
2036 redir = xmlNanoHTTPRedir(ret->buf->context);
2037 if (redir != NULL) {
2038 if (ret->filename != NULL)
2039 xmlFree((xmlChar *) ret->filename);
2040 ret->filename =
2041 (char *) xmlStrdup((const xmlChar *) redir);
2042 }
2043 }
2044 }
2045#endif
2046 return(ret);
2047}
2048
2049/**
2050 * xmlNewInputFromFile:

Callers 1

xmlNewInputFromFileFunction · 0.85

Calls 8

xmlNanoHTTPReturnCodeFunction · 0.85
xmlCtxtErrIOFunction · 0.85
xmlFreeInputStreamFunction · 0.85
xmlNanoHTTPMimeTypeFunction · 0.85
xmlNanoHTTPEncodingFunction · 0.85
xmlSwitchEncodingNameFunction · 0.85
xmlNanoHTTPRedirFunction · 0.85
xmlStrdupFunction · 0.85

Tested by

no test coverage detected