-const char jcc_rcs[] = "$Id: jcc.c,v 1.205 2008/11/16 12:43:49 fabiankeil Exp $";
+const char jcc_rcs[] = "$Id: jcc.c,v 1.210 2008/12/02 22:03:18 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/jcc.c,v $
*
* Revisions :
* $Log: jcc.c,v $
+ * Revision 1.210 2008/12/02 22:03:18 fabiankeil
+ * Don't miscalculate byte_count if we don't get all the
+ * server headers with one read_socket() call. With keep-alive
+ * support enabled, this caused delays until the server closed
+ * the connection.
+ *
+ * Revision 1.209 2008/11/27 09:44:04 fabiankeil
+ * Cosmetics for the last commit: Don't watch out for
+ * the last chunk if the content isn't chunk-encoded or
+ * if we already determined the content length previously.
+ *
+ * Revision 1.208 2008/11/26 18:24:17 fabiankeil
+ * Recognize that the server response is complete if the
+ * last chunk is read together with the server headers.
+ * Reported by Lee.
+ *
+ * Revision 1.207 2008/11/25 17:25:16 fabiankeil
+ * Don't convert the client-header list to text until we need to.
+ *
+ * Revision 1.206 2008/11/23 17:00:11 fabiankeil
+ * Some more chat() cosmetics.
+ *
* Revision 1.205 2008/11/16 12:43:49 fabiankeil
* Turn keep-alive support into a runtime feature
* that is disabled by setting keep-alive-timeout
build_request_line(csp, fwd, &csp->headers->first->str);
}
- hdr = list_to_text(csp->headers);
- if (hdr == NULL)
- {
- /* FIXME Should handle error properly */
- log_error(LOG_LEVEL_FATAL, "Out of memory parsing client header");
- }
-
/*
* We have a request. Check if one of the crunchers wants it.
*/
* Yes. The client got the crunch response
* and we are done here after cleaning up.
*/
- freez(hdr);
+ /* XXX: why list_remove_all()? */
list_remove_all(csp->headers);
return;
}
- /*
- * The headers can't be removed earlier because
- * they were still needed for the referrer check
- * in case of CGI crunches.
- *
- * XXX: Would it be worth to move the referrer check
- * into client_referrer() and set a flag if it's trusted?
- */
- list_remove_all(csp->headers);
-
log_error(LOG_LEVEL_GPC, "%s%s", http->hostport, http->path);
if (fwd->forward_host)
send_crunch_response(csp, rsp);
}
- freez(hdr);
return;
}
+ hdr = list_to_text(csp->headers);
+ if (hdr == NULL)
+ {
+ /* FIXME Should handle error properly */
+ log_error(LOG_LEVEL_FATAL, "Out of memory parsing client header");
+ }
+ list_remove_all(csp->headers);
+
if (fwd->forward_host || (http->ssl == 0))
{
/*
FD_SET(csp->sfd, &rfds);
#ifdef FEATURE_CONNECTION_KEEP_ALIVE
+ if ((csp->flags & CSP_FLAG_CHUNKED)
+ && !(csp->flags & CSP_FLAG_CONTENT_LENGTH_SET)
+ && ((csp->iob->eod - csp->iob->cur) >= 5)
+ && !memcmp(csp->iob->eod-5, "0\r\n\r\n", 5))
+ {
+ log_error(LOG_LEVEL_CONNECT,
+ "Looks like we read the last chunk together with "
+ "the server headers. We better stop reading.");
+ byte_count = (size_t)(csp->iob->eod - csp->iob->cur);
+ csp->expected_content_length = byte_count;
+ csp->flags |= CSP_FLAG_CONTENT_LENGTH_SET;
+ }
if (server_body && server_response_is_complete(csp, byte_count))
{
log_error(LOG_LEVEL_CONNECT,
* Since we have to wait for more from the server before
* we can parse the headers we just continue here.
*/
+ int header_offset = csp->iob->cur - header_start;
+ assert(csp->iob->cur >= header_start);
+ byte_count += (size_t)(len - header_offset);
+ log_error(LOG_LEVEL_CONNECT, "Continuing buffering headers. "
+ "byte_count: %d. header_offset: %d. len: %d.",
+ byte_count, header_offset, len);
continue;
}
}
if ((csp->flags & CSP_FLAG_CONTENT_LENGTH_SET)
&& (csp->expected_content_length != byte_count))
{
- log_error(LOG_LEVEL_ERROR,
+ log_error(LOG_LEVEL_CONNECT,
"Received %d bytes while expecting %d.",
byte_count, csp->expected_content_length);
mark_server_socket_tainted(csp);