DEBUG_printf(("4httpGets: read %d bytes...", bytes));
+#ifdef DEBUG
+ http_debug_hex("httpGets", http->buffer + http->used, bytes);
+#endif /* DEBUG */
+
if (bytes < 0)
{
/*
}
while (bytes < 0);
- DEBUG_printf(("2httpRead2: Read %d bytes into buffer.", (int)bytes));
+ DEBUG_printf(("2httpRead2: Read " CUPS_LLFMT " bytes into buffer.",
+ CUPS_LLCAST bytes));
+#ifdef DEBUG
+ http_debug_hex("httpRead2", http->buffer, (int)bytes);
+#endif /* DEBUG */
http->used = bytes;
}
DEBUG_printf(("2httpRead2: read " CUPS_LLFMT " bytes from socket...",
CUPS_LLCAST bytes));
+#ifdef DEBUG
+ http_debug_hex("httpRead2", buffer, (int)bytes);
+#endif /* DEBUG */
}
if (bytes > 0)
}
}
-#ifdef DEBUG
- http_debug_hex("httpRead2", buffer, (int)bytes);
-#endif /* DEBUG */
-
return (bytes);
}
{
DEBUG_printf(("httpReconnect(http=%p)", http));
- return (httpReconnect2(http, 30, NULL));
+ return (httpReconnect2(http, 30000, NULL));
}
#endif /* DEBUG */
- DEBUG_printf(("httpReconnect(http=%p, msec=%d, cancel=%p)", http, msec,
+ DEBUG_printf(("httpReconnect2(http=%p, msec=%d, cancel=%p)", http, msec,
cancel));
if (!http)
#ifdef HAVE_SSL
if (http->tls)
{
- DEBUG_puts("2httpReconnect: Shutting down SSL/TLS...");
+ DEBUG_puts("2httpReconnect2: Shutting down SSL/TLS...");
http_shutdown_ssl(http);
}
#endif /* HAVE_SSL */
if (http->fd >= 0)
{
- DEBUG_printf(("2httpReconnect: Closing socket %d...", http->fd));
+ DEBUG_printf(("2httpReconnect2: Closing socket %d...", http->fd));
#ifdef WIN32
closesocket(http->fd);
#ifdef DEBUG
for (current = http->addrlist; current; current = current->next)
- DEBUG_printf(("2httpReconnect: Address %s:%d",
+ DEBUG_printf(("2httpReconnect2: Address %s:%d",
httpAddrString(&(current->addr), temp, sizeof(temp)),
_httpAddrPort(&(current->addr))));
#endif /* DEBUG */
#endif /* WIN32 */
http->status = HTTP_ERROR;
- DEBUG_printf(("1httpReconnect: httpAddrConnect failed: %s",
+ DEBUG_printf(("1httpReconnect2: httpAddrConnect failed: %s",
strerror(http->error)));
return (-1);
}
- DEBUG_printf(("2httpReconnect: New socket=%d", http->fd));
+ DEBUG_printf(("2httpReconnect2: New socket=%d", http->fd));
if (http->timeout_value > 0)
http_set_timeout(http->fd, http->timeout_value);
return (http_upgrade(http));
#endif /* HAVE_SSL */
- DEBUG_printf(("1httpReconnect: Connected to %s:%d...",
+ DEBUG_printf(("1httpReconnect2: Connected to %s:%d...",
httpAddrString(http->hostaddr, temp, sizeof(temp)),
_httpAddrPort(http->hostaddr)));
_cups_globals_t *cg = _cupsGlobals();
/* Pointer to library globals */
int any_root; /* Allow any root */
- char *hostname; /* Hostname */
+ char hostname[256], /* Hostname */
+ *hostptr; /* Pointer into hostname */
# ifdef HAVE_LIBSSL
SSL_CTX *context; /* Context for encryption */
*/
if (httpAddrLocalhost(http->hostaddr))
+ {
any_root = 1;
+ strlcpy(hostname, "localhost", sizeof(hostname));
+ }
else
+ {
+ /*
+ * Otherwise use the system-wide setting and make sure the hostname we have
+ * does not end in a trailing dot.
+ */
+
any_root = cg->any_root;
- hostname = httpAddrLocalhost(http->hostaddr) ? "localhost" : http->hostname;
+ strlcpy(hostname, http->hostname, sizeof(hostname));
+ if ((hostptr = hostname + strlen(hostname) - 1) >= hostname &&
+ *hostptr == '.')
+ *hostptr = '\0';
+ }
# ifdef HAVE_LIBSSL
(void)any_root;
while (length > 0)
{
+ DEBUG_printf(("3http_write: About to write %d bytes.", (int)length));
+
if (http->timeout_cb)
{
#ifdef HAVE_POLL
#endif /* HAVE_SSL */
bytes = send(http->fd, buffer, length, 0);
+ DEBUG_printf(("3http_write: Write of %d bytes returned %d.", (int)length,
+ (int)bytes));
+
if (bytes < 0)
{
#ifdef WIN32