]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
It looks like int httpState->reply_hdr_state is always either 0 or 2.
authorwessels <>
Fri, 19 Aug 2005 22:49:26 +0000 (22:49 +0000)
committerwessels <>
Fri, 19 Aug 2005 22:49:26 +0000 (22:49 +0000)
I'm replacing it with the single-bit http_state_flags.headers_parsed.

src/http.cc
src/http.h
src/structs.h

index afb71336b3b8d5f36bfae7ea319092dc347813a8..c809719e7c37a3c6253d909283711dfd080a6388 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.cc,v 1.452 2005/08/17 15:57:26 wessels Exp $
+ * $Id: http.cc,v 1.453 2005/08/19 16:49:26 wessels Exp $
  *
  * DEBUG: section 11    Hypertext Transfer Protocol (HTTP)
  * AUTHOR: Harvest Derived
@@ -662,7 +662,7 @@ HttpStateData::processReplyHeader(const char *buf, int size)
     if (memBufIsNull(&reply_hdr))
         memBufDefInit(&reply_hdr);
 
-    assert(reply_hdr_state == 0);
+    assert(!flags.headers_parsed);
 
     memBufAppend(&reply_hdr, buf, size);
 
@@ -670,7 +670,7 @@ HttpStateData::processReplyHeader(const char *buf, int size)
 
     if (hdr_len > 4 && strncmp(reply_hdr.buf, "HTTP/", 5)) {
         debugs(11, 3, "httpProcessReplyHeader: Non-HTTP-compliant header: '" <<  reply_hdr.buf << "'");
-        reply_hdr_state += 2;
+        flags.headers_parsed = 1;
         memBufClean(&reply_hdr);
         failReply (reply, HTTP_INVALID_HEADER);
         ctx_exit(ctx);
@@ -690,7 +690,7 @@ HttpStateData::processReplyHeader(const char *buf, int size)
 
         failReply (reply, HTTP_HEADER_TOO_LARGE);
 
-        reply_hdr_state += 2;
+        flags.headers_parsed = 1;
 
         ctx_exit(ctx);
 
@@ -712,11 +712,7 @@ HttpStateData::processReplyHeader(const char *buf, int size)
 
     reply_hdr.buf[hdr_size] = '\0';
 
-    reply_hdr_state++;
-
-    assert(reply_hdr_state == 1);
-
-    reply_hdr_state++;
+    flags.headers_parsed = 1;
 
     debug(11, 9) ("GOT HTTP REPLY HDR:\n---------\n%s\n----------\n",
                   reply_hdr.buf);
@@ -897,7 +893,7 @@ HttpStateData::persistentConnStatus() const
                   reply->content_length);
     /* If we haven't seen the end of reply headers, we are not done */
 
-    if (reply_hdr_state < 2)
+    if (!flags.headers_parsed)
         return INCOMPLETE_MSG;
 
     clen = httpReplyBodySize(request->method, reply);
@@ -985,7 +981,7 @@ HttpStateData::readReply (int fd, char *readBuf, size_t len, comm_err_t flag, in
      * not allowing connection reuse in the first place.
      */
 #if DONT_DO_THIS
-    if (reply_hdr_state == 0 && flag == COMM_OK && len > 0 && fd_table[fd].uses > 1) {
+    if (!flags.headers_parsed && flag == COMM_OK && len > 0 && fd_table[fd].uses > 1) {
         /* Skip whitespace between replies */
 
         while (len > 0 && isspace(*buf))
@@ -1033,14 +1029,13 @@ HttpStateData::readReply (int fd, char *readBuf, size_t len, comm_err_t flag, in
         /* Connection closed; retrieval done. */
         eof = 1;
 
-        if (reply_hdr_state < 2)
+        if (!flags.headers_parsed)
             /*
-             * Yes Henrik, there is a point to doing this.  When we
-             * called httpProcessReplyHeader() before, we didn't find
-             * the end of headers, but now we are definately at EOF, so
-             * we want to process the reply headers.
+            * When we called httpProcessReplyHeader() before, we
+            * didn't find the end of headers, but now we are
+            * definately at EOF, so we want to process the reply
+            * headers.
              */
-            /* doesn't return */
             processReplyHeader(buf, len);
         else if (entry->getReply()->sline.status == HTTP_INVALID_HEADER && HttpVersion(0,9) != entry->getReply()->sline.version) {
             ErrorState *err;
@@ -1064,10 +1059,10 @@ HttpStateData::readReply (int fd, char *readBuf, size_t len, comm_err_t flag, in
             comm_close(fd);
         }
     } else {
-        if (reply_hdr_state < 2) {
+        if (!flags.headers_parsed) {
             processReplyHeader(buf, len);
 
-            if (reply_hdr_state == 2) {
+            if (flags.headers_parsed) {
                 http_status s = entry->getReply()->sline.status;
                 HttpVersion httpver = entry->getReply()->sline.version;
 
@@ -1105,7 +1100,7 @@ HttpStateData::readReply (int fd, char *readBuf, size_t len, comm_err_t flag, in
 void
 HttpStateData::processReplyData(const char *buf, size_t len)
 {
-    if (reply_hdr_state < 2) {
+    if (!flags.headers_parsed) {
         do_next_read = 1;
         maybeReadData();
         return;
@@ -1140,7 +1135,7 @@ HttpStateData::processReplyData(const char *buf, size_t len)
 
     if (EBIT_TEST(entry->flags, ENTRY_ABORTED)) {
         /*
-         * the above storeAppend() call could ABORT this entry,
+         * the above entry->write() call could ABORT this entry,
          * in that case, the server FD should already be closed.
          * there's nothing for us to do.
          */
@@ -1844,7 +1839,7 @@ httpRequestBodyHandler(char *buf, ssize_t size, void *data)
     httpState->body_buf = NULL;
 
     if (size > 0) {
-        if (httpState->reply_hdr_state >= 2 && !httpState->flags.abuse_detected) {
+        if (httpState->flags.headers_parsed && !httpState->flags.abuse_detected) {
             httpState->flags.abuse_detected = 1;
             debug(11, 1) ("httpSendRequestEntryDone: Likely proxy abuse detected '%s' -> '%s'\n",
                           inet_ntoa(httpState->orig_request->client_addr),
index 5332c20af81203bdda93d24628bc6b86b829d2c5..dfedb43d4c9dce62210ee0dbaf20b218086fab8d 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: http.h,v 1.11 2005/03/06 21:08:13 serassio Exp $
+ * $Id: http.h,v 1.12 2005/08/19 16:49:27 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -52,7 +52,6 @@ public:
     StoreEntry *entry;
     HttpRequest *request;
     MemBuf reply_hdr;
-    int reply_hdr_state;
     peer *_peer;               /* peer request made to */
     int eof;                   /* reached end-of-object? */
     HttpRequest *orig_request;
index c8a52ae0bad9fa7dbcc416e625e9067e56563464..e9fb1246ab53e85e7c5da2d5c93538bc5aedfe3c 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: structs.h,v 1.521 2005/08/14 18:43:41 serassio Exp $
+ * $Id: structs.h,v 1.522 2005/08/19 16:49:27 wessels Exp $
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
@@ -969,6 +969,9 @@ unsigned int keepalive:
 unsigned int only_if_cached:
     1;
 
+unsigned int headers_parsed:
+    1;
+
 unsigned int headers_pushed:
     1;