struct hostent *hostaddr; /* Host address data */
- DEBUG_printf(("httpConnectEncrypt(host=\"%s\", port=%d, encrypt=%d)\n",
- host ? host : "(null)", port, encrypt));
+ DEBUG_printf(("httpConnectEncrypt(host=\"%s\", port=%d, encryption=%d)\n",
+ host ? host : "(null)", port, encryption));
if (!host)
return (NULL);
DEBUG_printf(("httpPrintf: %s", buf));
if (http->wused)
- httpFlushWrite(http);
+ {
+ DEBUG_puts(" flushing existing data...");
+
+ if (httpFlushWrite(http) < 0)
+ return (-1);
+ }
return (http_write(http, buf, bytes));
}
*/
if (http->wused)
- httpFlushWrite(http);
+ {
+ DEBUG_puts(" flushing buffer...");
+
+ if (httpFlushWrite(http) < 0)
+ return (HTTP_ERROR);
+ }
/*
* If we haven't issued any commands, then there is nothing to "update"...
int bytes; /* Bytes written */
+ DEBUG_printf(("httpWrite(http=%p, buffer=%p, length=%d)\n", http,
+ buffer, length));
+
/*
* Range check input...
*/
if (length > 0)
{
- if ((length + http->wused) > sizeof(http->wbuffer))
+ if (http->wused && (length + http->wused) > sizeof(http->wbuffer))
+ {
+ DEBUG_printf((" flushing buffer (wused=%d, length=%d)\n",
+ http->wused, length));
+
httpFlushWrite(http);
+ }
if ((length + http->wused) <= sizeof(http->wbuffer))
{
* Write to buffer...
*/
+ DEBUG_printf((" copying %d bytes to wbuffer...\n", length));
+
memcpy(http->wbuffer + http->wused, buffer, length);
http->wused += length;
bytes = length;
* Otherwise write the data directly...
*/
+ DEBUG_printf((" writing %d bytes to socket...\n", length));
+
if (http->data_encoding == HTTP_ENCODE_CHUNKED)
- length = http_write_chunk(http, buffer, length);
+ bytes = http_write_chunk(http, buffer, length);
else
- length = http_write(http, buffer, length);
+ bytes = http_write(http, buffer, length);
+
+ DEBUG_printf((" wrote %d bytes...\n", bytes));
}
if (http->data_encoding == HTTP_ENCODE_LENGTH)
sprintf(header, "%x\r\n", length);
if (http_write(http, header, strlen(header)) < 0)
+ {
+ DEBUG_puts(" http_write of length failed!");
return (-1);
+ }
if ((bytes = http_write(http, buffer, length)) < 0)
+ {
+ DEBUG_puts(" http_write of buffer failed!");
return (-1);
+ }
if (http_write(http, "\r\n", 2) < 0)
+ {
+ DEBUG_puts(" http_write of CR LF failed!");
return (-1);
+ }
return (bytes);
}
}
#endif /* HAVE_SSL */
+ if (con->pipe_pid != 0)
+ {
+ /*
+ * Stop any CGI process...
+ */
+
+ LogMessage(L_DEBUG2, "CloseClient: %d Killing process ID %d...",
+ con->http.fd, con->pipe_pid);
+ cupsdEndProcess(con->pipe_pid, 1);
+ }
+
+ if (con->file >= 0)
+ {
+ if (FD_ISSET(con->file, InputSet))
+ {
+ LogMessage(L_DEBUG2, "CloseClient: %d Removing fd %d from InputSet...",
+ con->http.fd, con->file);
+ FD_CLR(con->file, InputSet);
+ }
+
+ LogMessage(L_DEBUG2, "CloseClient: %d Closing data file %d.",
+ con->http.fd, con->file);
+
+ close(con->file);
+ con->file = -1;
+ }
+
/*
* Close the socket and clear the file from the input set for select()...
*/
}
}
- if (con->pipe_pid != 0)
- {
- /*
- * Stop any CGI process...
- */
-
- LogMessage(L_DEBUG2, "CloseClient: %d Killing process ID %d...",
- con->http.fd, con->pipe_pid);
- cupsdEndProcess(con->pipe_pid, 1);
- }
-
- if (con->file >= 0)
- {
- if (FD_ISSET(con->file, InputSet))
- {
- LogMessage(L_DEBUG2, "CloseClient: %d Removing fd %d from InputSet...",
- con->http.fd, con->file);
- FD_CLR(con->file, InputSet);
- }
-
- LogMessage(L_DEBUG2, "CloseClient: %d Closing data file %d.",
- con->http.fd, con->file);
-
- close(con->file);
- con->file = -1;
- }
-
if (!partial)
{
/*
}
else if ((bytes = read(con->file, buf, sizeof(buf) - 1)) > 0)
{
-#ifdef DEBUG
LogMessage(L_DEBUG2, "WriteClient: Read %d bytes from file %d...",
bytes, con->file);
-#endif /* DEBUG */
if (con->pipe_pid && !con->got_fields)
{
else if (*bufptr != '\r')
con->field_col ++;
+ LogMessage(L_DEBUG2, "WriteClient: %d bytes=%d, got_fields=%d",
+ con->http.fd, bytes, con->got_fields);
+
if (bytes > 0 && !con->got_fields)
{
/*
if (httpWrite(HTTP(con), buf, bytes) < 0)
{
+ LogMessage(L_DEBUG2, "WriteClient: %d Write of %d bytes failed!",
+ con->http.fd, bytes);
+
CloseClient(con);
return (0);
}
if (bytes <= 0)
{
+ LogMessage(L_DEBUG2, "WriteClient: %d bytes < 0", con->http.fd);
+
LogRequest(con, HTTP_OK);
httpFlushWrite(HTTP(con));