"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "htmldoc/http.c" between
htmldoc-1.9.11-source.tar.gz and htmldoc-1.9.12-source.tar.gz

About: HTMLDOC converts HTML and Markdown source files into indexed HTML, EPUB, PostScript, or PDF files (but doesn’t support CSS).

http.c  (htmldoc-1.9.11-source):http.c  (htmldoc-1.9.12-source)
/* /*
* HTTP routines for HTMLDOC. * HTTP routines for HTMLDOC.
* *
* Copyright © 2020 by Michael R Sweet * Copyright © 2020-2021 by Michael R Sweet
* Copyright © 2007-2019 by Apple Inc. * Copyright © 2007-2019 by Apple Inc.
* Copyright © 1997-2007 by Easy Software Products, all rights reserved. * Copyright © 1997-2007 by Easy Software Products, all rights reserved.
* *
* This file contains Kerberos support code, copyright 2006 by * This file contains Kerberos support code, copyright 2006 by
* Jelmer Vernooij. * Jelmer Vernooij.
* *
* Licensed under Apache License v2.0. See the file "LICENSE" for more * Licensed under Apache License v2.0. See the file "LICENSE" for more
* information. * information.
*/ */
skipping to change at line 3130 skipping to change at line 3130
} }
else else
#endif /* HAVE_LIBZ */ #endif /* HAVE_LIBZ */
if (length > 0) if (length > 0)
{ {
if (http->wused && (length + (size_t)http->wused) > sizeof(http->wbuffer)) if (http->wused && (length + (size_t)http->wused) > sizeof(http->wbuffer))
{ {
DEBUG_printf(("2httpWrite2: Flushing buffer (wused=%d, length=" DEBUG_printf(("2httpWrite2: Flushing buffer (wused=%d, length="
HTMLDOC_LLFMT ")", http->wused, HTMLDOC_LLCAST length)); HTMLDOC_LLFMT ")", http->wused, HTMLDOC_LLCAST length));
httpFlushWrite(http); if (httpFlushWrite(http) < 0)
return (-1);
} }
if ((length + (size_t)http->wused) <= sizeof(http->wbuffer) && length < size of(http->wbuffer)) if ((length + (size_t)http->wused) <= sizeof(http->wbuffer) && length < size of(http->wbuffer))
{ {
/* /*
* Write to buffer... * Write to buffer...
*/ */
DEBUG_printf(("2httpWrite2: Copying " HTMLDOC_LLFMT " bytes to wbuffer..." , DEBUG_printf(("2httpWrite2: Copying " HTMLDOC_LLFMT " bytes to wbuffer..." ,
HTMLDOC_LLCAST length)); HTMLDOC_LLCAST length));
skipping to change at line 3512 skipping to change at line 3513
if (http->fields[field] != http->_fields[field]) if (http->fields[field] != http->_fields[field])
free(http->fields[field]); free(http->fields[field]);
http->fields[field] = NULL; http->fields[field] = NULL;
} }
valuelen = strlen(value); valuelen = strlen(value);
if (!valuelen) if (!valuelen)
{ {
http->_fields[field][0] = '\0'; if (field < HTTP_FIELD_ACCEPT_ENCODING)
http->_fields[field][0] = '\0';
return; return;
} }
if (http->fields[field]) if (http->fields[field])
{ {
fieldlen = strlen(http->fields[field]); fieldlen = strlen(http->fields[field]);
total = fieldlen + 2 + valuelen; total = fieldlen + 2 + valuelen;
} }
else else
{ {
fieldlen = 0; fieldlen = 0;
total = valuelen; total = valuelen;
} }
if (total < HTTP_MAX_VALUE && field < HTTP_FIELD_ACCEPT_ENCODING) if (total < HTTP_MAX_VALUE && field < HTTP_FIELD_ACCEPT_ENCODING)
{ {
char combined[HTTP_MAX_VALUE]; /* Combined value string */
/* /*
* Copy short values to legacy char arrays (maintained for binary * Copy short values to legacy char arrays (maintained for binary
* compatibility with CUPS 1.2.x and earlier applications...) * compatibility with CUPS 1.2.x and earlier applications...)
*/ */
if (fieldlen) if (fieldlen)
{ {
char combined[HTTP_MAX_VALUE];
/* Combined value string */
snprintf(combined, sizeof(combined), "%s, %s", http->_fields[field], value ); snprintf(combined, sizeof(combined), "%s, %s", http->_fields[field], value );
value = combined; value = combined;
} }
strlcpy(http->_fields[field], value, sizeof(http->_fields[field])); strlcpy(http->_fields[field], value, sizeof(http->_fields[field]));
http->fields[field] = http->_fields[field]; http->fields[field] = http->_fields[field];
} }
else if (fieldlen) else if (fieldlen)
{ {
/* /*
skipping to change at line 4041 skipping to change at line 4042
http->error = errno; http->error = errno;
return (-1); return (-1);
} }
#endif /* _WIN32 */ #endif /* _WIN32 */
} }
} }
while (bytes < 0); while (bytes < 0);
DEBUG_printf(("2http_read: Read " HTMLDOC_LLFMT " bytes into buffer.", DEBUG_printf(("2http_read: Read " HTMLDOC_LLFMT " bytes into buffer.",
HTMLDOC_LLCAST bytes)); HTMLDOC_LLCAST bytes));
#ifdef DEBUG
if (bytes > 0)
http_debug_hex("http_read", buffer, (int)bytes);
#endif /* DEBUG */
if (bytes < 0) if (bytes == 0)
{
#ifdef _WIN32
if (WSAGetLastError() == WSAEINTR)
bytes = 0;
else
http->error = WSAGetLastError();
#else
if (errno == EINTR || (errno == EAGAIN && !http->timeout_cb))
bytes = 0;
else
http->error = errno;
#endif /* _WIN32 */
}
else if (bytes == 0)
{ {
http->error = EPIPE; http->error = EPIPE;
return (0); return (0);
} }
#ifdef DEBUG
http_debug_hex("http_read", buffer, (int)bytes);
#endif /* DEBUG */
return (bytes); return (bytes);
} }
/* /*
* 'http_read_buffered()' - Do a buffered read from a HTTP connection. * 'http_read_buffered()' - Do a buffered read from a HTTP connection.
* *
* This function reads data from the HTTP buffer or from the socket, as needed. * This function reads data from the HTTP buffer or from the socket, as needed.
*/ */
static ssize_t /* O - Number of bytes read or -1 on erro r */ static ssize_t /* O - Number of bytes read or -1 on erro r */
 End of changes. 8 change blocks. 
25 lines changed or deleted 12 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)