#endif /* HAVE_GSSAPI */
- DEBUG_printf(("httpClose(http=%p)\n", http));
+ DEBUG_printf(("httpClose(http=%p)", http));
if (!http)
return;
http_t *http; /* New HTTP connection */
- DEBUG_printf(("httpConnectEncrypt(host=\"%s\", port=%d, encryption=%d)\n",
+ DEBUG_printf(("httpConnectEncrypt(host=\"%s\", port=%d, encryption=%d)",
host, port, encryption));
/*
char service[255]; /* Service name */
- DEBUG_printf(("_httpCreate(host=\"%s\", port=%d, encryption=%d)\n",
+ DEBUG_printf(("4_httpCreate(host=\"%s\", port=%d, encryption=%d)",
host, port, encryption));
if (!host)
httpEncryption(http_t *http, /* I - Connection to server */
http_encryption_t e) /* I - New encryption preference */
{
- DEBUG_printf(("httpEncryption(http=%p, e=%d)\n", http, e));
+ DEBUG_printf(("httpEncryption(http=%p, e=%d)", http, e));
#ifdef HAVE_SSL
if (!http)
int blocking; /* To block or not to block */
- DEBUG_printf(("httpFlush(http=%p), state=%d\n", http, http->state));
+ DEBUG_printf(("httpFlush(http=%p), state=%d", http, http->state));
/*
* Temporarily set non-blocking mode so we don't get stuck in httpRead()...
int bytes; /* Bytes written */
- DEBUG_printf(("httpFlushWrite(http=%p)\n", http));
+ DEBUG_printf(("httpFlushWrite(http=%p)", http));
if (!http || !http->wused)
return (0);
off_t /* O - Content length */
httpGetLength2(http_t *http) /* I - Connection to server */
{
- DEBUG_printf(("httpGetLength2(http=%p), state=%d\n", http, http->state));
+ DEBUG_printf(("2httpGetLength2(http=%p), state=%d", http, http->state));
if (!http)
return (-1);
if (!strcasecmp(http->fields[HTTP_FIELD_TRANSFER_ENCODING], "chunked"))
{
- DEBUG_puts("httpGetLength2: chunked request!");
+ DEBUG_puts("4httpGetLength2: chunked request!");
http->data_encoding = HTTP_ENCODE_CHUNKED;
http->data_remaining = 0;
http->data_remaining = strtoll(http->fields[HTTP_FIELD_CONTENT_LENGTH],
NULL, 10);
- DEBUG_printf(("httpGetLength2: content_length=" CUPS_LLFMT "\n",
+ DEBUG_printf(("4httpGetLength2: content_length=" CUPS_LLFMT,
CUPS_LLCAST http->data_remaining));
}
*ptr, /* Pointer into string buffer */
*end; /* End of value buffer */
- DEBUG_printf(("httpGetSubField2(http=%p, field=%d, name=\"%s\", value=%p, valuelen=%d)\n",
- http, field, name, value, valuelen));
+ DEBUG_printf(("2httpGetSubField2(http=%p, field=%d, name=\"%s\", value=%p, "
+ "valuelen=%d)", http, field, name, value, valuelen));
if (!http || !name || !value || valuelen < 2 ||
field <= HTTP_FIELD_UNKNOWN || field >= HTTP_FIELD_MAX)
*ptr = '\0';
- DEBUG_printf(("httpGetSubField: name=\"%s\"\n", temp));
+ DEBUG_printf(("4httpGetSubField2: name=\"%s\"", temp));
/*
* Skip trailing chars up to the '='...
fptr ++;
}
- DEBUG_printf(("httpGetSubField: value=\"%s\"\n", value));
+ DEBUG_printf(("4httpGetSubField2: value=\"%s\"", value));
/*
* See if this is the one...
*/
if (!strcmp(name, temp))
+ {
+ DEBUG_printf(("3httpGetSubField2: Returning \"%s\"", value));
return (value);
+ }
}
value[0] = '\0';
+ DEBUG_puts("3httpGetSubField2: Returning NULL");
+
return (NULL);
}
eol; /* End-of-line? */
- DEBUG_printf(("httpGets(line=%p, length=%d, http=%p)\n", line, length, http));
+ DEBUG_printf(("2httpGets(line=%p, length=%d, http=%p)", line, length, http));
if (http == NULL || line == NULL)
return (NULL);
if (!http->blocking && !_httpWait(http, 10000, 1))
{
- DEBUG_puts("httpGets: Timed out!");
+ DEBUG_puts("3httpGets: Timed out!");
#ifdef WIN32
http->error = WSAETIMEDOUT;
#else
bytes = recv(http->fd, http->buffer + http->used,
HTTP_MAX_BUFFER - http->used, 0);
- DEBUG_printf(("httpGets: read %d bytes...\n", bytes));
+ DEBUG_printf(("4httpGets: read %d bytes...", bytes));
if (bytes < 0)
{
continue;
}
- DEBUG_printf(("httpGets: recv() error %d!\n", WSAGetLastError()));
+ DEBUG_printf(("3httpGets: recv() error %d!", WSAGetLastError()));
#else
- DEBUG_printf(("httpGets: recv() error %d!\n", errno));
+ DEBUG_printf(("3httpGets: recv() error %d!", errno));
if (errno == EINTR || errno == EAGAIN)
continue;
*lineptr = '\0';
- DEBUG_printf(("httpGets: Returning \"%s\"\n", line));
+ DEBUG_printf(("3httpGets: Returning \"%s\"", line));
return (line);
}
}
- DEBUG_puts("httpGets: No new line available!");
+ DEBUG_puts("3httpGets: No new line available!");
return (NULL);
}
httpHead(http_t *http, /* I - Connection to server */
const char *uri) /* I - URI for head */
{
+ DEBUG_printf(("httpHead(http=%p, uri=\"%s\")", http, uri));
return (http_send(http, HTTP_HEAD, uri));
}
va_list ap; /* Variable argument pointer */
- DEBUG_printf(("httpPrintf(http=%p, format=\"%s\", ...)\n", http, format));
+ DEBUG_printf(("2httpPrintf(http=%p, format=\"%s\", ...)", http, format));
va_start(ap, format);
bytes = vsnprintf(buf, sizeof(buf), format, ap);
va_end(ap);
- DEBUG_printf(("httpPrintf: %s", buf));
+ DEBUG_printf(("3httpPrintf: %s", buf));
if (http->data_encoding == HTTP_ENCODE_FIELDS)
return (httpWrite2(http, buf, bytes));
{
if (http->wused)
{
- DEBUG_puts(" flushing existing data...");
+ DEBUG_puts("4httpPrintf: flushing existing data...");
if (httpFlushWrite(http) < 0)
return (-1);
httpPut(http_t *http, /* I - Connection to server */
const char *uri) /* I - URI to put */
{
+ DEBUG_printf(("httpPut(http=%p, uri=\"%s\")", http, uri));
return (http_send(http, HTTP_PUT, uri));
}
char len[32]; /* Length string */
- DEBUG_printf(("httpRead2(http=%p, buffer=%p, length=" CUPS_LLFMT ")\n",
+ DEBUG_printf(("httpRead2(http=%p, buffer=%p, length=" CUPS_LLFMT ")",
http, buffer, CUPS_LLCAST length));
if (http == NULL || buffer == NULL)
if (http->data_encoding == HTTP_ENCODE_CHUNKED &&
http->data_remaining <= 0)
{
- DEBUG_puts("httpRead2: Getting chunk length...");
+ DEBUG_puts("2httpRead2: Getting chunk length...");
if (httpGets(len, sizeof(len), http) == NULL)
{
- DEBUG_puts("httpRead2: Could not get length!");
+ DEBUG_puts("1httpRead2: Could not get length!");
return (0);
}
http->data_remaining = strtoll(len, NULL, 16);
if (http->data_remaining < 0)
{
- DEBUG_puts("httpRead2: Negative chunk length!");
+ DEBUG_puts("1httpRead2: Negative chunk length!");
return (0);
}
}
- DEBUG_printf(("httpRead2: data_remaining=" CUPS_LLFMT "\n",
+ DEBUG_printf(("2httpRead2: data_remaining=" CUPS_LLFMT,
CUPS_LLCAST http->data_remaining));
if (http->data_remaining <= 0)
else
#endif /* HAVE_SSL */
{
- DEBUG_printf(("httpRead2: reading %d bytes from socket into buffer...\n",
+ DEBUG_printf(("2httpRead2: reading %d bytes from socket into buffer...",
(int)bytes));
bytes = recv(http->fd, http->buffer, bytes, 0);
- DEBUG_printf(("httpRead2: read %d bytes from socket into buffer...\n",
+ DEBUG_printf(("2httpRead2: read %d bytes from socket into buffer...",
(int)bytes));
}
bytes = (ssize_t)length;
- DEBUG_printf(("httpRead2: grabbing %d bytes from input buffer...\n",
+ DEBUG_printf(("2httpRead2: grabbing %d bytes from input buffer...",
(int)bytes));
memcpy(buffer, http->buffer, length);
if (!http->blocking && !httpWait(http, 10000))
return (0);
- DEBUG_printf(("httpRead2: reading " CUPS_LLFMT " bytes from socket...\n",
+ DEBUG_printf(("2httpRead2: reading " CUPS_LLFMT " bytes from socket...",
CUPS_LLCAST length));
#ifdef WIN32
break;
#endif /* WIN32 */
- DEBUG_printf(("httpRead2: read " CUPS_LLFMT " bytes from socket...\n",
+ DEBUG_printf(("2httpRead2: read " CUPS_LLFMT " bytes from socket...",
CUPS_LLCAST bytes));
}
#endif /* DEBUG */
- DEBUG_printf(("httpReconnect(http=%p)\n", http));
+ DEBUG_printf(("httpReconnect(http=%p)", http));
if (!http)
return (-1);
#ifdef HAVE_SSL
if (http->tls)
{
- DEBUG_puts("httpReconnect: Shutting down SSL/TLS...");
+ DEBUG_puts("2httpReconnect: Shutting down SSL/TLS...");
http_shutdown_ssl(http);
}
#endif /* HAVE_SSL */
if (http->fd >= 0)
{
- DEBUG_printf(("httpReconnect: Closing socket %d...\n", http->fd));
+ DEBUG_printf(("2httpReconnect: Closing socket %d...", http->fd));
#ifdef WIN32
closesocket(http->fd);
#ifdef DEBUG
for (current = http->addrlist; current; current = current->next)
- DEBUG_printf(("httpReconnect: Address %s:%d\n",
+ DEBUG_printf(("2httpReconnect: Address %s:%d",
httpAddrString(&(current->addr), temp, sizeof(temp)),
_httpAddrPort(&(current->addr))));
#endif /* DEBUG */
#endif /* WIN32 */
http->status = HTTP_ERROR;
- DEBUG_printf(("httpReconnect: httpAddrConnect failed: %s\n",
+ DEBUG_printf(("1httpReconnect: httpAddrConnect failed: %s",
strerror(http->error)));
return (-1);
}
- DEBUG_printf(("httpReconnect: New socket=%d\n", http->fd));
+ DEBUG_printf(("2httpReconnect: New socket=%d", http->fd));
http->hostaddr = &(addr->addr);
http->error = 0;
return (http_upgrade(http));
#endif /* HAVE_SSL */
- DEBUG_printf(("httpReconnect: Connected to %s:%d...\n",
+ DEBUG_printf(("1httpReconnect: Connected to %s:%d...",
httpAddrString(http->hostaddr, temp, sizeof(temp)),
_httpAddrPort(http->hostaddr)));
status; /* Request status */
- DEBUG_printf(("httpUpdate(http=%p), state=%d\n", http, http->state));
+ DEBUG_printf(("httpUpdate(http=%p), state=%d", http, http->state));
/*
* Flush pending data, if any...
if (http->wused)
{
- DEBUG_puts(" flushing buffer...");
+ DEBUG_puts("2httpUpdate: flushing buffer...");
if (httpFlushWrite(http) < 0)
return (HTTP_ERROR);
while (httpGets(line, sizeof(line), http) != NULL)
{
- DEBUG_printf(("httpUpdate: Got \"%s\"\n", line));
+ DEBUG_printf(("2httpUpdate: Got \"%s\"", line));
if (line[0] == '\0')
{
return (http->status);
}
- else if (strncmp(line, "HTTP/", 5) == 0)
+ else if (!strncmp(line, "HTTP/", 5))
{
/*
* Got the beginning of a response...
}
else if ((field = http_field(line)) == HTTP_FIELD_UNKNOWN)
{
- DEBUG_printf(("httpUpdate: unknown field %s seen!\n", line));
+ DEBUG_printf(("1httpUpdate: unknown field %s seen!", line));
continue;
}
else
}
else
{
+ DEBUG_printf(("1httpUpdate: Bad response line \"%s\"!", line));
http->status = HTTP_ERROR;
return (HTTP_ERROR);
}
*/
if (http->error == EPIPE && http->status > HTTP_CONTINUE)
+ {
+ DEBUG_printf(("1httpUpdate: Returning status %d...", http->status));
return (http->status);
+ }
if (http->error)
{
- DEBUG_printf(("httpUpdate: socket error %d - %s\n", http->error,
+ DEBUG_printf(("1httpUpdate: socket error %d - %s", http->error,
strerror(http->error)));
http->status = HTTP_ERROR;
return (HTTP_ERROR);
int nfds; /* Result from select()/poll() */
- DEBUG_printf(("_httpWait(http=%p, msec=%d, usessl=%d)\n", http, msec, usessl));
+ DEBUG_printf(("4_httpWait(http=%p, msec=%d, usessl=%d)", http, msec, usessl));
if (http->fd < 0)
return (0);
FD_ZERO(&input_set);
FD_SET(http->fd, &input_set);
- DEBUG_printf(("_httpWait: msec=%d, http->fd=%d\n", msec, http->fd));
+ DEBUG_printf(("6_httpWait: msec=%d, http->fd=%d", msec, http->fd));
if (msec >= 0)
{
else
nfds = select(http->fd + 1, &input_set, NULL, NULL, NULL);
- DEBUG_printf(("_httpWait: select() returned %d...\n", nfds));
+ DEBUG_printf(("6_httpWait: select() returned %d...", nfds));
}
# ifdef WIN32
while (nfds < 0 && WSAGetLastError() == WSAEINTR);
# endif /* WIN32 */
#endif /* HAVE_POLL */
- DEBUG_printf(("_httpWait: returning with nfds=%d...\n", nfds));
+ DEBUG_printf(("5_httpWait: returning with nfds=%d...", nfds));
return (nfds > 0);
}
ssize_t bytes; /* Bytes written */
- DEBUG_printf(("httpWrite2(http=%p, buffer=%p, length=" CUPS_LLFMT ")\n", http,
+ DEBUG_printf(("httpWrite2(http=%p, buffer=%p, length=" CUPS_LLFMT ")", http,
buffer, CUPS_LLCAST length));
/*
{
if (http->wused && (length + http->wused) > sizeof(http->wbuffer))
{
- DEBUG_printf(("httpWrite2: Flushing buffer (wused=%d, length="
- CUPS_LLFMT ")\n", http->wused, CUPS_LLCAST length));
+ DEBUG_printf(("2httpWrite2: Flushing buffer (wused=%d, length="
+ CUPS_LLFMT ")", http->wused, CUPS_LLCAST length));
httpFlushWrite(http);
}
* Write to buffer...
*/
- DEBUG_printf(("httpWrite2: Copying " CUPS_LLFMT " bytes to wbuffer...\n",
+ DEBUG_printf(("2httpWrite2: Copying " CUPS_LLFMT " bytes to wbuffer...",
CUPS_LLCAST length));
memcpy(http->wbuffer + http->wused, buffer, length);
* Otherwise write the data directly...
*/
- DEBUG_printf(("httpWrite2: Writing " CUPS_LLFMT " bytes to socket...\n",
+ DEBUG_printf(("2httpWrite2: Writing " CUPS_LLFMT " bytes to socket...",
CUPS_LLCAST length));
if (http->data_encoding == HTTP_ENCODE_CHUNKED)
else
bytes = (ssize_t)http_write(http, buffer, (int)length);
- DEBUG_printf(("httpWrite2: Wrote " CUPS_LLFMT " bytes...\n",
+ DEBUG_printf(("2httpWrite2: Wrote " CUPS_LLFMT " bytes...",
CUPS_LLCAST bytes));
}
* data, go idle...
*/
- DEBUG_puts("httpWrite: changing states...");
+ DEBUG_puts("2httpWrite: changing states...");
if (http->wused)
httpFlushWrite(http);
if (_cups_debug_fd < 0)
return;
- DEBUG_printf(("%s: %d bytes:\n", prefix, bytes));
+ DEBUG_printf(("6%s: %d bytes:\n", prefix, bytes));
snprintf(line, sizeof(line), "%s: ", prefix);
start = line + strlen(line);
};
- DEBUG_printf(("http_send(http=%p, request=HTTP_%s, uri=\"%s\")\n",
+ DEBUG_printf(("7http_send(http=%p, request=HTTP_%s, uri=\"%s\")",
http, codes[request], uri));
if (http == NULL || uri == NULL)
for (i = 0; i < HTTP_FIELD_MAX; i ++)
if (http->fields[i][0] != '\0')
{
- DEBUG_printf(("http_send: %s: %s\n", http_fields[i],
+ DEBUG_printf(("9http_send: %s: %s", http_fields[i],
httpGetField(http, i)));
if (httpPrintf(http, "%s: %s\r\n", http_fields[i],
# endif /* HAVE_LIBSSL */
- DEBUG_printf(("http_setup_ssl(http=%p)\n", http));
+ DEBUG_printf(("7http_setup_ssl(http=%p)", http));
# ifdef HAVE_LIBSSL
context = SSL_CTX_new(SSLv23_client_method());
unsigned long error; /* Error code */
while ((error = ERR_get_error()) != 0)
- printf("http_setup_ssl: %s\n", ERR_error_string(error, NULL));
+ DEBUG_printf(("8http_setup_ssl: %s", ERR_error_string(error, NULL)));
# endif /* DEBUG */
SSL_CTX_free(context);
http_t myhttp; /* Local copy of HTTP data */
- DEBUG_printf(("http_upgrade(%p)\n", http));
+ DEBUG_printf(("7http_upgrade(%p)", http));
/*
* Copy the HTTP data to a local variable so we can do the OPTIONS
* Server does not support HTTP upgrade...
*/
- DEBUG_puts("Server does not support HTTP upgrade!");
+ DEBUG_puts("8http_upgrade: Server does not support HTTP upgrade!");
# ifdef WIN32
closesocket(http->fd);
}
#endif /* WIN32 */
- DEBUG_puts("http_write: error writing data...\n");
+ DEBUG_puts("8http_write: error writing data...");
return (-1);
}
char header[255]; /* Chunk header */
int bytes; /* Bytes written */
- DEBUG_printf(("http_write_chunk(http=%p, buffer=%p, length=%d)\n",
+ DEBUG_printf(("7http_write_chunk(http=%p, buffer=%p, length=%d)",
http, buffer, length));
/*
sprintf(header, "%x\r\n", length);
if (http_write(http, header, (int)strlen(header)) < 0)
{
- DEBUG_puts(" http_write of length failed!");
+ DEBUG_puts("8http_write_chunk: http_write of length failed!");
return (-1);
}
if ((bytes = http_write(http, buffer, length)) < 0)
{
- DEBUG_puts(" http_write of buffer failed!");
+ DEBUG_puts("8http_write_chunk: http_write of buffer failed!");
return (-1);
}
if (http_write(http, "\r\n", 2) < 0)
{
- DEBUG_puts(" http_write of CR LF failed!");
+ DEBUG_puts("8http_write_chunk: http_write of CR LF failed!");
return (-1);
}