X-Git-Url: http://www.privoxy.org/gitweb/?a=blobdiff_plain;f=jcc.c;h=06ce04ae5524522cb898560d105cbf063ad42be0;hb=80c69e79035306553c98dce23cd15fc42b6697fe;hp=f58152c01bbff3fc4fe15c47d0c2354b4a8cae38;hpb=58279559e84318ec74d0d08f5bef4a5df803ab4e;p=privoxy.git diff --git a/jcc.c b/jcc.c index f58152c0..06ce04ae 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.174 2008/05/07 18:05:53 fabiankeil Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.177 2008/05/10 11:51:12 fabiankeil Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -33,6 +33,16 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.174 2008/05/07 18:05:53 fabiankeil Exp $" * * Revisions : * $Log: jcc.c,v $ + * Revision 1.177 2008/05/10 11:51:12 fabiankeil + * Make the "read the rest of the headers" loop a bit more readable. + * + * Revision 1.176 2008/05/10 11:37:57 fabiankeil + * - Instead of logging when the IIS5 hack is enabled, log when it fails. + * - Remove useless comment. + * + * Revision 1.175 2008/05/09 18:53:59 fabiankeil + * Fix comment grammar. + * * Revision 1.174 2008/05/07 18:05:53 fabiankeil * Remove the pointless buffer in client_protocol_is_unsupported(). * @@ -1470,7 +1480,7 @@ static jb_err get_server_headers(struct client_state *csp) int continue_hack_in_da_house = 0; char * header; - while (((header = get_header(csp)) != NULL) || continue_hack_in_da_house) + while (((header = get_header(csp->iob)) != NULL) || continue_hack_in_da_house) { if (header == NULL) { @@ -1521,7 +1531,6 @@ static jb_err get_server_headers(struct client_state *csp) return JB_ERR_PARSE; } - /* Enlist header */ if (JB_ERR_MEMORY == enlist(csp->headers, header)) { /* @@ -1979,7 +1988,7 @@ static void chat(struct client_state *csp) return; } - req = get_header(csp); + req = get_header(csp->iob); } while ((NULL != req) && ('\0' == *req)); @@ -2067,8 +2076,20 @@ static void chat(struct client_state *csp) init_list(headers); for (;;) { - if ( ( ( p = get_header(csp) ) != NULL) && ( *p == '\0' ) ) + p = get_header(csp->iob); + + if (p == NULL) + { + /* There are no additional headers to read. */ + break; + } + + if (*p == '\0') { + /* + * We didn't receive a complete header + * line yet, get the rest of it. + */ len = read_socket(csp->cfd, buf, sizeof(buf) - 1); if (len <= 0) { @@ -2077,23 +2098,25 @@ static void chat(struct client_state *csp) return; } - /* - * If there is no memory left for buffering the - * request, there is nothing we can do but hang up - */ if (add_to_iob(csp, buf, len)) { + /* + * If there is no memory left for buffering the + * request, there is nothing we can do but hang up + */ destroy_list(headers); return; } - continue; } - - if (p == NULL) break; - - enlist(headers, p); - freez(p); - + else + { + /* + * We were able to read a complete + * header and can finaly enlist it. + */ + enlist(headers, p); + freez(p); + } } if (http->host == NULL) @@ -2547,9 +2570,6 @@ static void chat(struct client_state *csp) * This is NOT the body, so * Let's pretend the server just sent us a blank line. */ - log_error(LOG_LEVEL_INFO, - "Malformerd HTTP headers detected and MS IIS5 hack enabled. " - "Expect an invalid response or even no response at all."); snprintf(buf, sizeof(buf), "\r\n"); len = (int)strlen(buf); @@ -2662,6 +2682,8 @@ static void chat(struct client_state *csp) * and there isn't anything * we can do about it. */ + log_error(LOG_LEVEL_INFO, + "MS IIS5 hack didn't produce valid headers."); break; } else @@ -2777,6 +2799,8 @@ static void chat(struct client_state *csp) */ if (ms_iis5_hack) { + log_error(LOG_LEVEL_INFO, + "Closed server connection detected with MS IIS5 hack enabled."); break; } }