mirror of
https://gitlab.gnome.org/GNOME/libxml2.git
synced 2025-07-29 11:41:22 +03:00
io: Remove support for HTTP POST
This feature is unlikely to be used these days.
This commit is contained in:
@ -328,6 +328,7 @@ XMLPUBFUN void
|
|||||||
|
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
|
|
||||||
|
XML_DEPRECATED
|
||||||
XMLPUBFUN xmlParserInputPtr
|
XMLPUBFUN xmlParserInputPtr
|
||||||
xmlCheckHTTPInput (xmlParserCtxtPtr ctxt,
|
xmlCheckHTTPInput (xmlParserCtxtPtr ctxt,
|
||||||
xmlParserInputPtr ret);
|
xmlParserInputPtr ret);
|
||||||
@ -340,10 +341,7 @@ XMLPUBFUN xmlParserInputPtr
|
|||||||
const char *ID,
|
const char *ID,
|
||||||
xmlParserCtxtPtr ctxt);
|
xmlParserCtxtPtr ctxt);
|
||||||
|
|
||||||
/*
|
XML_DEPRECATED
|
||||||
* xmlNormalizeWindowsPath is obsolete, don't use it.
|
|
||||||
* Check xmlCanonicPath in uri.h for a better alternative.
|
|
||||||
*/
|
|
||||||
XMLPUBFUN xmlChar *
|
XMLPUBFUN xmlChar *
|
||||||
xmlNormalizeWindowsPath (const xmlChar *path);
|
xmlNormalizeWindowsPath (const xmlChar *path);
|
||||||
|
|
||||||
@ -372,19 +370,24 @@ XMLPUBFUN int
|
|||||||
* Default 'http://' protocol callbacks
|
* Default 'http://' protocol callbacks
|
||||||
*/
|
*/
|
||||||
#ifdef LIBXML_HTTP_ENABLED
|
#ifdef LIBXML_HTTP_ENABLED
|
||||||
|
XML_DEPRECATED
|
||||||
XMLPUBFUN int
|
XMLPUBFUN int
|
||||||
xmlIOHTTPMatch (const char *filename);
|
xmlIOHTTPMatch (const char *filename);
|
||||||
|
XML_DEPRECATED
|
||||||
XMLPUBFUN void *
|
XMLPUBFUN void *
|
||||||
xmlIOHTTPOpen (const char *filename);
|
xmlIOHTTPOpen (const char *filename);
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
#ifdef LIBXML_OUTPUT_ENABLED
|
||||||
|
XML_DEPRECATED
|
||||||
XMLPUBFUN void *
|
XMLPUBFUN void *
|
||||||
xmlIOHTTPOpenW (const char * post_uri,
|
xmlIOHTTPOpenW (const char * post_uri,
|
||||||
int compression );
|
int compression );
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
|
XML_DEPRECATED
|
||||||
XMLPUBFUN int
|
XMLPUBFUN int
|
||||||
xmlIOHTTPRead (void * context,
|
xmlIOHTTPRead (void * context,
|
||||||
char * buffer,
|
char * buffer,
|
||||||
int len);
|
int len);
|
||||||
|
XML_DEPRECATED
|
||||||
XMLPUBFUN int
|
XMLPUBFUN int
|
||||||
xmlIOHTTPClose (void * context);
|
xmlIOHTTPClose (void * context);
|
||||||
#endif /* LIBXML_HTTP_ENABLED */
|
#endif /* LIBXML_HTTP_ENABLED */
|
||||||
@ -393,14 +396,18 @@ XMLPUBFUN int
|
|||||||
* Default 'ftp://' protocol callbacks
|
* Default 'ftp://' protocol callbacks
|
||||||
*/
|
*/
|
||||||
#if defined(LIBXML_FTP_ENABLED)
|
#if defined(LIBXML_FTP_ENABLED)
|
||||||
|
XML_DEPRECATED
|
||||||
XMLPUBFUN int
|
XMLPUBFUN int
|
||||||
xmlIOFTPMatch (const char *filename);
|
xmlIOFTPMatch (const char *filename);
|
||||||
|
XML_DEPRECATED
|
||||||
XMLPUBFUN void *
|
XMLPUBFUN void *
|
||||||
xmlIOFTPOpen (const char *filename);
|
xmlIOFTPOpen (const char *filename);
|
||||||
|
XML_DEPRECATED
|
||||||
XMLPUBFUN int
|
XMLPUBFUN int
|
||||||
xmlIOFTPRead (void * context,
|
xmlIOFTPRead (void * context,
|
||||||
char * buffer,
|
char * buffer,
|
||||||
int len);
|
int len);
|
||||||
|
XML_DEPRECATED
|
||||||
XMLPUBFUN int
|
XMLPUBFUN int
|
||||||
xmlIOFTPClose (void * context);
|
xmlIOFTPClose (void * context);
|
||||||
#endif /* defined(LIBXML_FTP_ENABLED) */
|
#endif /* defined(LIBXML_FTP_ENABLED) */
|
||||||
|
@ -312,6 +312,8 @@ deprecated_funcs = {
|
|||||||
'xmlInitGlobals': True,
|
'xmlInitGlobals': True,
|
||||||
'xmlInitializeDict': True,
|
'xmlInitializeDict': True,
|
||||||
'xmlInitializePredefinedEntities': True,
|
'xmlInitializePredefinedEntities': True,
|
||||||
|
'xmlIOFTPMatch': True,
|
||||||
|
'xmlIOHTTPMatch': True,
|
||||||
'xmlIsRef': True,
|
'xmlIsRef': True,
|
||||||
'xmlKeepBlanksDefault': True,
|
'xmlKeepBlanksDefault': True,
|
||||||
'xmlLineNumbersDefault': True,
|
'xmlLineNumbersDefault': True,
|
||||||
@ -326,6 +328,7 @@ deprecated_funcs = {
|
|||||||
'xmlNanoHTTPScanProxy': True,
|
'xmlNanoHTTPScanProxy': True,
|
||||||
'xmlNewGlobalNs': True,
|
'xmlNewGlobalNs': True,
|
||||||
'xmlNextChar': True,
|
'xmlNextChar': True,
|
||||||
|
'xmlNormalizeWindowsPath': True,
|
||||||
'xmlParseAttValue': True,
|
'xmlParseAttValue': True,
|
||||||
'xmlParseAttributeListDecl': True,
|
'xmlParseAttributeListDecl': True,
|
||||||
'xmlParseCDSect': True,
|
'xmlParseCDSect': True,
|
||||||
|
597
xmlIO.c
597
xmlIO.c
@ -493,8 +493,7 @@ xmlWrapStatUtf8(const char *path, struct _stat *info) {
|
|||||||
* xmlNormalizeWindowsPath:
|
* xmlNormalizeWindowsPath:
|
||||||
* @path: the input file path
|
* @path: the input file path
|
||||||
*
|
*
|
||||||
* This function is obsolete. Please see xmlURIFromPath in uri.c for
|
* DEPRECATED: See xmlURIFromPath in uri.c for a better solution.
|
||||||
* a better solution.
|
|
||||||
*
|
*
|
||||||
* Returns a canonicalized version of the path
|
* Returns a canonicalized version of the path
|
||||||
*/
|
*/
|
||||||
@ -1305,371 +1304,19 @@ xmlXzfileClose (void * context) {
|
|||||||
}
|
}
|
||||||
#endif /* LIBXML_LZMA_ENABLED */
|
#endif /* LIBXML_LZMA_ENABLED */
|
||||||
|
|
||||||
#ifdef LIBXML_HTTP_ENABLED
|
|
||||||
/************************************************************************
|
/************************************************************************
|
||||||
* *
|
* *
|
||||||
* I/O for HTTP file accesses *
|
* I/O for HTTP file accesses *
|
||||||
* *
|
* *
|
||||||
************************************************************************/
|
************************************************************************/
|
||||||
|
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
#ifdef LIBXML_HTTP_ENABLED
|
||||||
typedef struct xmlIOHTTPWriteCtxt_
|
|
||||||
{
|
|
||||||
int compression;
|
|
||||||
|
|
||||||
char * uri;
|
|
||||||
|
|
||||||
void * doc_buff;
|
|
||||||
|
|
||||||
} xmlIOHTTPWriteCtxt, *xmlIOHTTPWriteCtxtPtr;
|
|
||||||
|
|
||||||
#ifdef LIBXML_ZLIB_ENABLED
|
|
||||||
|
|
||||||
#define DFLT_WBITS ( -15 )
|
|
||||||
#define DFLT_MEM_LVL ( 8 )
|
|
||||||
#define GZ_MAGIC1 ( 0x1f )
|
|
||||||
#define GZ_MAGIC2 ( 0x8b )
|
|
||||||
#define LXML_ZLIB_OS_CODE ( 0x03 )
|
|
||||||
#define INIT_HTTP_BUFF_SIZE ( 32768 )
|
|
||||||
#define DFLT_ZLIB_RATIO ( 5 )
|
|
||||||
|
|
||||||
/*
|
|
||||||
** Data structure and functions to work with sending compressed data
|
|
||||||
** via HTTP.
|
|
||||||
*/
|
|
||||||
|
|
||||||
typedef struct xmlZMemBuff_
|
|
||||||
{
|
|
||||||
unsigned long size;
|
|
||||||
unsigned long crc;
|
|
||||||
|
|
||||||
unsigned char * zbuff;
|
|
||||||
z_stream zctrl;
|
|
||||||
|
|
||||||
} xmlZMemBuff, *xmlZMemBuffPtr;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* append_reverse_ulong
|
|
||||||
* @buff: Compressed memory buffer
|
|
||||||
* @data: Unsigned long to append
|
|
||||||
*
|
|
||||||
* Append a unsigned long in reverse byte order to the end of the
|
|
||||||
* memory buffer.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
append_reverse_ulong( xmlZMemBuff * buff, unsigned long data ) {
|
|
||||||
|
|
||||||
int idx;
|
|
||||||
|
|
||||||
if ( buff == NULL )
|
|
||||||
return;
|
|
||||||
|
|
||||||
/*
|
|
||||||
** This is plagiarized from putLong in gzio.c (zlib source) where
|
|
||||||
** the number "4" is hardcoded. If zlib is ever patched to
|
|
||||||
** support 64 bit file sizes, this code would need to be patched
|
|
||||||
** as well.
|
|
||||||
*/
|
|
||||||
|
|
||||||
for ( idx = 0; idx < 4; idx++ ) {
|
|
||||||
*buff->zctrl.next_out = ( data & 0xff );
|
|
||||||
data >>= 8;
|
|
||||||
buff->zctrl.next_out++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* xmlFreeZMemBuff
|
|
||||||
* @buff: The memory buffer context to clear
|
|
||||||
*
|
|
||||||
* Release all the resources associated with the compressed memory buffer.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
xmlFreeZMemBuff( xmlZMemBuffPtr buff ) {
|
|
||||||
|
|
||||||
if ( buff == NULL )
|
|
||||||
return;
|
|
||||||
|
|
||||||
xmlFree( buff->zbuff );
|
|
||||||
deflateEnd( &buff->zctrl );
|
|
||||||
|
|
||||||
xmlFree( buff );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlCreateZMemBuff
|
|
||||||
*@compression: Compression value to use
|
|
||||||
*
|
|
||||||
* Create a memory buffer to hold the compressed XML document. The
|
|
||||||
* compressed document in memory will end up being identical to what
|
|
||||||
* would be created if gzopen/gzwrite/gzclose were being used to
|
|
||||||
* write the document to disk. The code for the header/trailer data to
|
|
||||||
* the compression is plagiarized from the zlib source files.
|
|
||||||
*/
|
|
||||||
static void *
|
|
||||||
xmlCreateZMemBuff( int compression ) {
|
|
||||||
|
|
||||||
int z_err;
|
|
||||||
int hdr_lgth;
|
|
||||||
xmlZMemBuffPtr buff = NULL;
|
|
||||||
|
|
||||||
if ( ( compression < 1 ) || ( compression > 9 ) )
|
|
||||||
return ( NULL );
|
|
||||||
|
|
||||||
/* Create the control and data areas */
|
|
||||||
|
|
||||||
buff = xmlMalloc( sizeof( xmlZMemBuff ) );
|
|
||||||
if ( buff == NULL ) {
|
|
||||||
xmlIOErrMemory();
|
|
||||||
return ( NULL );
|
|
||||||
}
|
|
||||||
|
|
||||||
(void)memset( buff, 0, sizeof( xmlZMemBuff ) );
|
|
||||||
buff->size = INIT_HTTP_BUFF_SIZE;
|
|
||||||
buff->zbuff = xmlMalloc( buff->size );
|
|
||||||
if ( buff->zbuff == NULL ) {
|
|
||||||
xmlFreeZMemBuff( buff );
|
|
||||||
xmlIOErrMemory();
|
|
||||||
return ( NULL );
|
|
||||||
}
|
|
||||||
|
|
||||||
z_err = deflateInit2( &buff->zctrl, compression, Z_DEFLATED,
|
|
||||||
DFLT_WBITS, DFLT_MEM_LVL, Z_DEFAULT_STRATEGY );
|
|
||||||
if ( z_err != Z_OK ) {
|
|
||||||
xmlChar msg[500];
|
|
||||||
xmlFreeZMemBuff( buff );
|
|
||||||
buff = NULL;
|
|
||||||
xmlStrPrintf(msg, 500,
|
|
||||||
"xmlCreateZMemBuff: %s %d\n",
|
|
||||||
"Error initializing compression context. ZLIB error:",
|
|
||||||
z_err );
|
|
||||||
xmlIOErr(XML_IO_WRITE, (const char *) msg);
|
|
||||||
return ( NULL );
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Set the header data. The CRC will be needed for the trailer */
|
|
||||||
buff->crc = crc32( 0L, NULL, 0 );
|
|
||||||
hdr_lgth = snprintf( (char *)buff->zbuff, buff->size,
|
|
||||||
"%c%c%c%c%c%c%c%c%c%c",
|
|
||||||
GZ_MAGIC1, GZ_MAGIC2, Z_DEFLATED,
|
|
||||||
0, 0, 0, 0, 0, 0, LXML_ZLIB_OS_CODE );
|
|
||||||
buff->zctrl.next_out = buff->zbuff + hdr_lgth;
|
|
||||||
buff->zctrl.avail_out = buff->size - hdr_lgth;
|
|
||||||
|
|
||||||
return ( buff );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlZMemBuffExtend
|
|
||||||
* @buff: Buffer used to compress and consolidate data.
|
|
||||||
* @ext_amt: Number of bytes to extend the buffer.
|
|
||||||
*
|
|
||||||
* Extend the internal buffer used to store the compressed data by the
|
|
||||||
* specified amount.
|
|
||||||
*
|
|
||||||
* Returns 0 on success or -1 on failure to extend the buffer. On failure
|
|
||||||
* the original buffer still exists at the original size.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
xmlZMemBuffExtend( xmlZMemBuffPtr buff, size_t ext_amt ) {
|
|
||||||
|
|
||||||
int rc = -1;
|
|
||||||
size_t new_size;
|
|
||||||
size_t cur_used;
|
|
||||||
|
|
||||||
unsigned char * tmp_ptr = NULL;
|
|
||||||
|
|
||||||
if ( buff == NULL )
|
|
||||||
return ( -1 );
|
|
||||||
|
|
||||||
else if ( ext_amt == 0 )
|
|
||||||
return ( 0 );
|
|
||||||
|
|
||||||
cur_used = buff->zctrl.next_out - buff->zbuff;
|
|
||||||
new_size = buff->size + ext_amt;
|
|
||||||
|
|
||||||
tmp_ptr = xmlRealloc( buff->zbuff, new_size );
|
|
||||||
if ( tmp_ptr != NULL ) {
|
|
||||||
rc = 0;
|
|
||||||
buff->size = new_size;
|
|
||||||
buff->zbuff = tmp_ptr;
|
|
||||||
buff->zctrl.next_out = tmp_ptr + cur_used;
|
|
||||||
buff->zctrl.avail_out = new_size - cur_used;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
xmlChar msg[500];
|
|
||||||
xmlStrPrintf(msg, 500,
|
|
||||||
"xmlZMemBuffExtend: %s %lu bytes.\n",
|
|
||||||
"Allocation failure extending output buffer to",
|
|
||||||
(unsigned long) new_size );
|
|
||||||
xmlIOErr(XML_IO_WRITE, (const char *) msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ( rc );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlZMemBuffAppend
|
|
||||||
* @buff: Buffer used to compress and consolidate data
|
|
||||||
* @src: Uncompressed source content to append to buffer
|
|
||||||
* @len: Length of source data to append to buffer
|
|
||||||
*
|
|
||||||
* Compress and append data to the internal buffer. The data buffer
|
|
||||||
* will be expanded if needed to store the additional data.
|
|
||||||
*
|
|
||||||
* Returns the number of bytes appended to the buffer or -1 on error.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
xmlZMemBuffAppend( xmlZMemBuffPtr buff, const char * src, int len ) {
|
|
||||||
|
|
||||||
int z_err;
|
|
||||||
size_t min_accept;
|
|
||||||
|
|
||||||
if ( ( buff == NULL ) || ( src == NULL ) )
|
|
||||||
return ( -1 );
|
|
||||||
|
|
||||||
buff->zctrl.avail_in = len;
|
|
||||||
buff->zctrl.next_in = (unsigned char *)src;
|
|
||||||
while ( buff->zctrl.avail_in > 0 ) {
|
|
||||||
/*
|
|
||||||
** Extend the buffer prior to deflate call if a reasonable amount
|
|
||||||
** of output buffer space is not available.
|
|
||||||
*/
|
|
||||||
min_accept = buff->zctrl.avail_in / DFLT_ZLIB_RATIO;
|
|
||||||
if ( buff->zctrl.avail_out <= min_accept ) {
|
|
||||||
if ( xmlZMemBuffExtend( buff, buff->size ) == -1 )
|
|
||||||
return ( -1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
z_err = deflate( &buff->zctrl, Z_NO_FLUSH );
|
|
||||||
if ( z_err != Z_OK ) {
|
|
||||||
xmlChar msg[500];
|
|
||||||
xmlStrPrintf(msg, 500,
|
|
||||||
"xmlZMemBuffAppend: %s %d %s - %d",
|
|
||||||
"Compression error while appending",
|
|
||||||
len, "bytes to buffer. ZLIB error", z_err );
|
|
||||||
xmlIOErr(XML_IO_WRITE, (const char *) msg);
|
|
||||||
return ( -1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
buff->crc = crc32( buff->crc, (unsigned char *)src, len );
|
|
||||||
|
|
||||||
return ( len );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlZMemBuffGetContent
|
|
||||||
* @buff: Compressed memory content buffer
|
|
||||||
* @data_ref: Pointer reference to point to compressed content
|
|
||||||
*
|
|
||||||
* Flushes the compression buffers, appends gzip file trailers and
|
|
||||||
* returns the compressed content and length of the compressed data.
|
|
||||||
* NOTE: The gzip trailer code here is plagiarized from zlib source.
|
|
||||||
*
|
|
||||||
* Returns the length of the compressed data or -1 on error.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
xmlZMemBuffGetContent( xmlZMemBuffPtr buff, char ** data_ref ) {
|
|
||||||
|
|
||||||
int zlgth = -1;
|
|
||||||
int z_err;
|
|
||||||
|
|
||||||
if ( ( buff == NULL ) || ( data_ref == NULL ) )
|
|
||||||
return ( -1 );
|
|
||||||
|
|
||||||
/* Need to loop until compression output buffers are flushed */
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
z_err = deflate( &buff->zctrl, Z_FINISH );
|
|
||||||
if ( z_err == Z_OK ) {
|
|
||||||
/* In this case Z_OK means more buffer space needed */
|
|
||||||
|
|
||||||
if ( xmlZMemBuffExtend( buff, buff->size ) == -1 )
|
|
||||||
return ( -1 );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
while ( z_err == Z_OK );
|
|
||||||
|
|
||||||
/* If the compression state is not Z_STREAM_END, some error occurred */
|
|
||||||
|
|
||||||
if ( z_err == Z_STREAM_END ) {
|
|
||||||
|
|
||||||
/* Need to append the gzip data trailer */
|
|
||||||
|
|
||||||
if ( buff->zctrl.avail_out < ( 2 * sizeof( unsigned long ) ) ) {
|
|
||||||
if ( xmlZMemBuffExtend(buff, (2 * sizeof(unsigned long))) == -1 )
|
|
||||||
return ( -1 );
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
** For whatever reason, the CRC and length data are pushed out
|
|
||||||
** in reverse byte order. So a memcpy can't be used here.
|
|
||||||
*/
|
|
||||||
|
|
||||||
append_reverse_ulong( buff, buff->crc );
|
|
||||||
append_reverse_ulong( buff, buff->zctrl.total_in );
|
|
||||||
|
|
||||||
zlgth = buff->zctrl.next_out - buff->zbuff;
|
|
||||||
*data_ref = (char *)buff->zbuff;
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
xmlChar msg[500];
|
|
||||||
xmlStrPrintf(msg, 500,
|
|
||||||
"xmlZMemBuffGetContent: %s - %d\n",
|
|
||||||
"Error flushing zlib buffers. Error code", z_err );
|
|
||||||
xmlIOErr(XML_IO_WRITE, (const char *) msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ( zlgth );
|
|
||||||
}
|
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
|
||||||
#endif /* LIBXML_ZLIB_ENABLED */
|
|
||||||
|
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
|
||||||
/**
|
|
||||||
* xmlFreeHTTPWriteCtxt
|
|
||||||
* @ctxt: Context to cleanup
|
|
||||||
*
|
|
||||||
* Free allocated memory and reclaim system resources.
|
|
||||||
*
|
|
||||||
* No return value.
|
|
||||||
*/
|
|
||||||
static void
|
|
||||||
xmlFreeHTTPWriteCtxt( xmlIOHTTPWriteCtxtPtr ctxt )
|
|
||||||
{
|
|
||||||
if ( ctxt->uri != NULL )
|
|
||||||
xmlFree( ctxt->uri );
|
|
||||||
|
|
||||||
if ( ctxt->doc_buff != NULL ) {
|
|
||||||
|
|
||||||
#ifdef LIBXML_ZLIB_ENABLED
|
|
||||||
if ( ctxt->compression > 0 ) {
|
|
||||||
xmlFreeZMemBuff( ctxt->doc_buff );
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
xmlOutputBufferClose( ctxt->doc_buff );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
xmlFree( ctxt );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlIOHTTPMatch:
|
* xmlIOHTTPMatch:
|
||||||
* @filename: the URI for matching
|
* @filename: the URI for matching
|
||||||
*
|
*
|
||||||
|
* DEPRECATED: Internal function, don't use.
|
||||||
|
*
|
||||||
* check if the URI matches an HTTP one
|
* check if the URI matches an HTTP one
|
||||||
*
|
*
|
||||||
* Returns 1 if matches, 0 otherwise
|
* Returns 1 if matches, 0 otherwise
|
||||||
@ -1685,6 +1332,8 @@ xmlIOHTTPMatch (const char *filename) {
|
|||||||
* xmlIOHTTPOpen:
|
* xmlIOHTTPOpen:
|
||||||
* @filename: the URI for matching
|
* @filename: the URI for matching
|
||||||
*
|
*
|
||||||
|
* DEPRECATED: Internal function, don't use.
|
||||||
|
*
|
||||||
* open an HTTP I/O channel
|
* open an HTTP I/O channel
|
||||||
*
|
*
|
||||||
* Returns an I/O context or NULL in case of error
|
* Returns an I/O context or NULL in case of error
|
||||||
@ -1700,63 +1349,15 @@ xmlIOHTTPOpen (const char *filename) {
|
|||||||
* @post_uri: The destination URI for the document
|
* @post_uri: The destination URI for the document
|
||||||
* @compression: The compression desired for the document.
|
* @compression: The compression desired for the document.
|
||||||
*
|
*
|
||||||
* Open a temporary buffer to collect the document for a subsequent HTTP POST
|
* DEPRECATED: Support for HTTP POST has been removed.
|
||||||
* request. Non-static as is called from the output buffer creation routine.
|
|
||||||
*
|
*
|
||||||
* Returns an I/O context or NULL in case of error.
|
* Returns NULL.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
void *
|
void *
|
||||||
xmlIOHTTPOpenW(const char *post_uri, int compression)
|
xmlIOHTTPOpenW(const char *post_uri ATTRIBUTE_UNUSED,
|
||||||
|
int compression ATTRIBUTE_UNUSED)
|
||||||
{
|
{
|
||||||
|
return(NULL);
|
||||||
xmlIOHTTPWriteCtxtPtr ctxt = NULL;
|
|
||||||
|
|
||||||
(void) compression;
|
|
||||||
|
|
||||||
if (post_uri == NULL)
|
|
||||||
return (NULL);
|
|
||||||
|
|
||||||
ctxt = xmlMalloc(sizeof(xmlIOHTTPWriteCtxt));
|
|
||||||
if (ctxt == NULL) {
|
|
||||||
xmlIOErrMemory();
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
(void) memset(ctxt, 0, sizeof(xmlIOHTTPWriteCtxt));
|
|
||||||
|
|
||||||
ctxt->uri = (char *) xmlStrdup((const xmlChar *)post_uri);
|
|
||||||
if (ctxt->uri == NULL) {
|
|
||||||
xmlIOErrMemory();
|
|
||||||
xmlFreeHTTPWriteCtxt(ctxt);
|
|
||||||
return (NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* ** Since the document length is required for an HTTP post,
|
|
||||||
* ** need to put the document into a buffer. A memory buffer
|
|
||||||
* ** is being used to avoid pushing the data to disk and back.
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifdef LIBXML_ZLIB_ENABLED
|
|
||||||
if ((compression > 0) && (compression <= 9)) {
|
|
||||||
|
|
||||||
ctxt->compression = compression;
|
|
||||||
ctxt->doc_buff = xmlCreateZMemBuff(compression);
|
|
||||||
} else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
/* Any character conversions should have been done before this */
|
|
||||||
|
|
||||||
ctxt->doc_buff = xmlAllocOutputBufferInternal(NULL);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ctxt->doc_buff == NULL) {
|
|
||||||
xmlFreeHTTPWriteCtxt(ctxt);
|
|
||||||
ctxt = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return (ctxt);
|
|
||||||
}
|
}
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
#endif /* LIBXML_OUTPUT_ENABLED */
|
||||||
|
|
||||||
@ -1766,6 +1367,8 @@ xmlIOHTTPOpenW(const char *post_uri, int compression)
|
|||||||
* @buffer: where to drop data
|
* @buffer: where to drop data
|
||||||
* @len: number of bytes to write
|
* @len: number of bytes to write
|
||||||
*
|
*
|
||||||
|
* DEPRECATED: Internal function, don't use.
|
||||||
|
*
|
||||||
* Read @len bytes to @buffer from the I/O channel.
|
* Read @len bytes to @buffer from the I/O channel.
|
||||||
*
|
*
|
||||||
* Returns the number of bytes written
|
* Returns the number of bytes written
|
||||||
@ -1776,59 +1379,12 @@ xmlIOHTTPRead(void * context, char * buffer, int len) {
|
|||||||
return(xmlNanoHTTPRead(context, &buffer[0], len));
|
return(xmlNanoHTTPRead(context, &buffer[0], len));
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
|
||||||
/**
|
|
||||||
* xmlIOHTTPWrite
|
|
||||||
* @context: previously opened writing context
|
|
||||||
* @buffer: data to output to temporary buffer
|
|
||||||
* @len: bytes to output
|
|
||||||
*
|
|
||||||
* Collect data from memory buffer into a temporary file for later
|
|
||||||
* processing.
|
|
||||||
*
|
|
||||||
* Returns number of bytes written.
|
|
||||||
*/
|
|
||||||
|
|
||||||
static int
|
|
||||||
xmlIOHTTPWrite( void * context, const char * buffer, int len ) {
|
|
||||||
|
|
||||||
xmlIOHTTPWriteCtxtPtr ctxt = context;
|
|
||||||
|
|
||||||
if ( ( ctxt == NULL ) || ( ctxt->doc_buff == NULL ) || ( buffer == NULL ) )
|
|
||||||
return ( -1 );
|
|
||||||
|
|
||||||
if ( len > 0 ) {
|
|
||||||
|
|
||||||
/* Use gzwrite or fwrite as previously setup in the open call */
|
|
||||||
|
|
||||||
#ifdef LIBXML_ZLIB_ENABLED
|
|
||||||
if ( ctxt->compression > 0 )
|
|
||||||
len = xmlZMemBuffAppend( ctxt->doc_buff, buffer, len );
|
|
||||||
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
len = xmlOutputBufferWrite( ctxt->doc_buff, len, buffer );
|
|
||||||
|
|
||||||
if ( len < 0 ) {
|
|
||||||
xmlChar msg[500];
|
|
||||||
xmlStrPrintf(msg, 500,
|
|
||||||
"xmlIOHTTPWrite: %s\n%s '%s'.\n",
|
|
||||||
"Error appending to internal buffer.",
|
|
||||||
"Error sending document to URI",
|
|
||||||
ctxt->uri );
|
|
||||||
xmlIOErr(XML_IO_WRITE, (const char *) msg);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return ( len );
|
|
||||||
}
|
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* xmlIOHTTPClose:
|
* xmlIOHTTPClose:
|
||||||
* @context: the I/O context
|
* @context: the I/O context
|
||||||
*
|
*
|
||||||
|
* DEPRECATED: Internal function, don't use.
|
||||||
|
*
|
||||||
* Close an HTTP I/O channel
|
* Close an HTTP I/O channel
|
||||||
*
|
*
|
||||||
* Returns 0
|
* Returns 0
|
||||||
@ -1838,105 +1394,6 @@ xmlIOHTTPClose (void * context) {
|
|||||||
xmlNanoHTTPClose(context);
|
xmlNanoHTTPClose(context);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef LIBXML_OUTPUT_ENABLED
|
|
||||||
/**
|
|
||||||
* xmlIOHTTCloseWrite
|
|
||||||
* @context: The I/O context
|
|
||||||
* @http_mthd: The HTTP method to be used when sending the data
|
|
||||||
*
|
|
||||||
* Close the transmit HTTP I/O channel and actually send the data.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
xmlIOHTTPCloseWrite( void * context, const char * http_mthd ) {
|
|
||||||
|
|
||||||
int close_rc = -1;
|
|
||||||
int http_rtn = 0;
|
|
||||||
int content_lgth = 0;
|
|
||||||
xmlIOHTTPWriteCtxtPtr ctxt = context;
|
|
||||||
|
|
||||||
char * http_content = NULL;
|
|
||||||
char * content_encoding = NULL;
|
|
||||||
char * content_type = (char *) "text/xml";
|
|
||||||
void * http_ctxt = NULL;
|
|
||||||
|
|
||||||
if ( ( ctxt == NULL ) || ( http_mthd == NULL ) )
|
|
||||||
return ( -1 );
|
|
||||||
|
|
||||||
/* Retrieve the content from the appropriate buffer */
|
|
||||||
|
|
||||||
#ifdef LIBXML_ZLIB_ENABLED
|
|
||||||
|
|
||||||
if ( ctxt->compression > 0 ) {
|
|
||||||
content_lgth = xmlZMemBuffGetContent( ctxt->doc_buff, &http_content );
|
|
||||||
content_encoding = (char *) "Content-Encoding: gzip";
|
|
||||||
}
|
|
||||||
else
|
|
||||||
#endif
|
|
||||||
{
|
|
||||||
/* Pull the data out of the memory output buffer */
|
|
||||||
|
|
||||||
xmlOutputBufferPtr dctxt = ctxt->doc_buff;
|
|
||||||
http_content = (char *) xmlBufContent(dctxt->buffer);
|
|
||||||
content_lgth = xmlBufUse(dctxt->buffer);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( http_content == NULL ) {
|
|
||||||
xmlChar msg[500];
|
|
||||||
xmlStrPrintf(msg, 500,
|
|
||||||
"xmlIOHTTPCloseWrite: %s '%s' %s '%s'.\n",
|
|
||||||
"Error retrieving content.\nUnable to",
|
|
||||||
http_mthd, "data to URI", ctxt->uri );
|
|
||||||
xmlIOErr(XML_IO_WRITE, (const char *) msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
else {
|
|
||||||
|
|
||||||
http_ctxt = xmlNanoHTTPMethod( ctxt->uri, http_mthd, http_content,
|
|
||||||
&content_type, content_encoding,
|
|
||||||
content_lgth );
|
|
||||||
|
|
||||||
if ( http_ctxt != NULL ) {
|
|
||||||
|
|
||||||
http_rtn = xmlNanoHTTPReturnCode( http_ctxt );
|
|
||||||
if ( ( http_rtn >= 200 ) && ( http_rtn < 300 ) )
|
|
||||||
close_rc = 0;
|
|
||||||
else {
|
|
||||||
xmlChar msg[500];
|
|
||||||
xmlStrPrintf(msg, 500,
|
|
||||||
"xmlIOHTTPCloseWrite: HTTP '%s' of %d %s\n'%s' %s %d\n",
|
|
||||||
http_mthd, content_lgth,
|
|
||||||
"bytes to URI", ctxt->uri,
|
|
||||||
"failed. HTTP return code:", http_rtn );
|
|
||||||
xmlIOErr(XML_IO_WRITE, (const char *) msg);
|
|
||||||
}
|
|
||||||
|
|
||||||
xmlNanoHTTPClose( http_ctxt );
|
|
||||||
xmlFree( content_type );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Final cleanups */
|
|
||||||
|
|
||||||
xmlFreeHTTPWriteCtxt( ctxt );
|
|
||||||
|
|
||||||
return ( close_rc );
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* xmlIOHTTPClosePut
|
|
||||||
*
|
|
||||||
* @context: The I/O context
|
|
||||||
*
|
|
||||||
* Close the transmit HTTP I/O channel and actually send data using a PUT
|
|
||||||
* HTTP method.
|
|
||||||
*/
|
|
||||||
static int
|
|
||||||
xmlIOHTTPClosePut( void * ctxt ) {
|
|
||||||
return ( xmlIOHTTPCloseWrite( ctxt, "PUT" ) );
|
|
||||||
}
|
|
||||||
#endif /* LIBXML_OUTPUT_ENABLED */
|
|
||||||
|
|
||||||
#endif /* LIBXML_HTTP_ENABLED */
|
#endif /* LIBXML_HTTP_ENABLED */
|
||||||
|
|
||||||
#ifdef LIBXML_FTP_ENABLED
|
#ifdef LIBXML_FTP_ENABLED
|
||||||
@ -1949,6 +1406,8 @@ xmlIOHTTPClosePut( void * ctxt ) {
|
|||||||
* xmlIOFTPMatch:
|
* xmlIOFTPMatch:
|
||||||
* @filename: the URI for matching
|
* @filename: the URI for matching
|
||||||
*
|
*
|
||||||
|
* DEPRECATED: Internal function, don't use.
|
||||||
|
*
|
||||||
* check if the URI matches an FTP one
|
* check if the URI matches an FTP one
|
||||||
*
|
*
|
||||||
* Returns 1 if matches, 0 otherwise
|
* Returns 1 if matches, 0 otherwise
|
||||||
@ -1964,6 +1423,8 @@ xmlIOFTPMatch (const char *filename) {
|
|||||||
* xmlIOFTPOpen:
|
* xmlIOFTPOpen:
|
||||||
* @filename: the URI for matching
|
* @filename: the URI for matching
|
||||||
*
|
*
|
||||||
|
* DEPRECATED: Internal function, don't use.
|
||||||
|
*
|
||||||
* open an FTP I/O channel
|
* open an FTP I/O channel
|
||||||
*
|
*
|
||||||
* Returns an I/O context or NULL in case of error
|
* Returns an I/O context or NULL in case of error
|
||||||
@ -1979,6 +1440,8 @@ xmlIOFTPOpen (const char *filename) {
|
|||||||
* @buffer: where to drop data
|
* @buffer: where to drop data
|
||||||
* @len: number of bytes to write
|
* @len: number of bytes to write
|
||||||
*
|
*
|
||||||
|
* DEPRECATED: Internal function, don't use.
|
||||||
|
*
|
||||||
* Read @len bytes to @buffer from the I/O channel.
|
* Read @len bytes to @buffer from the I/O channel.
|
||||||
*
|
*
|
||||||
* Returns the number of bytes written
|
* Returns the number of bytes written
|
||||||
@ -1993,6 +1456,8 @@ xmlIOFTPRead(void * context, char * buffer, int len) {
|
|||||||
* xmlIOFTPClose:
|
* xmlIOFTPClose:
|
||||||
* @context: the I/O context
|
* @context: the I/O context
|
||||||
*
|
*
|
||||||
|
* DEPRECATED: Internal function, don't use.
|
||||||
|
*
|
||||||
* Close an FTP I/O channel
|
* Close an FTP I/O channel
|
||||||
*
|
*
|
||||||
* Returns 0
|
* Returns 0
|
||||||
@ -2124,18 +1589,6 @@ xmlOutputDefaultOpen(xmlOutputBufferPtr buf, const char *filename,
|
|||||||
(void) compression;
|
(void) compression;
|
||||||
(void) is_file_uri;
|
(void) is_file_uri;
|
||||||
|
|
||||||
#ifdef LIBXML_HTTP_ENABLED
|
|
||||||
if (xmlIOHTTPMatch(filename)) {
|
|
||||||
buf->context = xmlIOHTTPOpenW(filename, compression);
|
|
||||||
|
|
||||||
if (buf->context != NULL) {
|
|
||||||
buf->writecallback = xmlIOHTTPWrite;
|
|
||||||
buf->closecallback = xmlIOHTTPClosePut;
|
|
||||||
return(XML_ERR_OK);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
#endif /* LIBXML_HTTP_ENABLED */
|
|
||||||
|
|
||||||
#ifdef LIBXML_ZLIB_ENABLED
|
#ifdef LIBXML_ZLIB_ENABLED
|
||||||
if ((compression > 0) && (compression <= 9) && (is_file_uri == 1)) {
|
if ((compression > 0) && (compression <= 9) && (is_file_uri == 1)) {
|
||||||
buf->context = xmlGzfileOpenW(filename, compression);
|
buf->context = xmlGzfileOpenW(filename, compression);
|
||||||
@ -3677,6 +3130,8 @@ xmlParserGetDirectory(const char *filename) {
|
|||||||
* @ctxt: an XML parser context
|
* @ctxt: an XML parser context
|
||||||
* @ret: an XML parser input
|
* @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
|
* 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
|
* 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
|
* redirection. It also checks for HTTP errors in which case the input
|
||||||
@ -4142,7 +3597,7 @@ xmlCleanupOutputCallbacks(void)
|
|||||||
/**
|
/**
|
||||||
* xmlRegisterHTTPPostCallbacks:
|
* xmlRegisterHTTPPostCallbacks:
|
||||||
*
|
*
|
||||||
* DEPRECATED: Has no effect.
|
* DEPRECATED: Support for HTTP POST has been removed.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
xmlRegisterHTTPPostCallbacks(void) {
|
xmlRegisterHTTPPostCallbacks(void) {
|
||||||
|
Reference in New Issue
Block a user