]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
renamed http_state_flags to HttpStateFlags and moved to own header file.
authorFrancesco Chemolli <kinkie@squid-cache.org>
Sat, 22 Sep 2012 14:21:59 +0000 (16:21 +0200)
committerFrancesco Chemolli <kinkie@squid-cache.org>
Sat, 22 Sep 2012 14:21:59 +0000 (16:21 +0200)
Changed all boolean flags to bool type.

src/HttpStateFlags.h [new file with mode: 0644]
src/Makefile.am
src/htcp.cc
src/http.cc
src/http.h
src/structs.h
src/tunnel.cc

diff --git a/src/HttpStateFlags.h b/src/HttpStateFlags.h
new file mode 100644 (file)
index 0000000..c57ab16
--- /dev/null
@@ -0,0 +1,53 @@
+#ifndef SQUID_HTTPSTATEFLAGS_H_
+#define SQUID_HTTPSTATEFLAGS_H_
+/*
+ * SQUID Web Proxy Cache          http://www.squid-cache.org/
+ * ----------------------------------------------------------
+ *
+ *  Squid is the result of efforts by numerous individuals from
+ *  the Internet community; see the CONTRIBUTORS file for full
+ *  details.   Many organizations have provided support for Squid's
+ *  development; see the SPONSORS file for full details.  Squid is
+ *  Copyrighted (C) 2001 by the Regents of the University of
+ *  California; see the COPYRIGHT file for full details.  Squid
+ *  incorporates software developed and/or copyrighted by other
+ *  sources; see the CREDITS file for full details.
+ *
+ *  This program is free software; you can redistribute it and/or modify
+ *  it under the terms of the GNU General Public License as published by
+ *  the Free Software Foundation; either version 2 of the License, or
+ *  (at your option) any later version.
+ *
+ *  This program is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with this program; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111, USA.
+ *
+ */
+
+// POD
+class HttpStateFlags
+{
+public:
+    bool proxying:1;
+    bool keepalive:1;
+    bool only_if_cached:1;
+    bool handling1xx:1; ///< we are ignoring or forwarding 1xx response
+    bool headers_parsed:1;
+    unsigned int front_end_https:2; //XXX: huh?
+    bool originpeer:1;
+    bool keepalive_broken:1;
+    bool abuse_detected:1;
+    bool request_sent:1;
+    bool do_next_read:1;
+    bool consume_body_data:1; //XXX: seems unused
+    bool chunked:1; ///< reading a chunked response; TODO: rename
+    bool chunked_request:1; ///< writing a chunked request
+    bool sentLastChunk:1; ///< do not try to write last-chunk again
+};
+
+#endif /* SQUID_HTTPSTATEFLAGS_H_ */
index 7ef917f55d9b62dc658a670376730e024d59be91..90ce339d4dc644d52d8586cf24075b9cfaf565a5 100644 (file)
@@ -364,6 +364,7 @@ squid_SOURCES = \
        hier_code.h \
        HierarchyLogEntry.h \
        $(HTCPSOURCE) \
+       HttpStateFlags.h \
        http.cc \
        http.h \
        HttpStatusCode.h \
@@ -1440,6 +1441,7 @@ tests_testCacheManager_SOURCES = \
        HelperChildConfig.h \
        HelperChildConfig.cc \
        $(HTCPSOURCE) \
+       HttpStateFlags.h \
        http.cc \
        HttpBody.h \
        HttpBody.cc \
index 43e7720798286a2c8488c45bf1e7ecb423a91f01..26c4ca6831d537aac1bdc1ab34bed4b85074da61 100644 (file)
@@ -45,6 +45,7 @@
 #include "htcp.h"
 #include "http.h"
 #include "HttpRequest.h"
+#include "HttpStateFlags.h"
 #include "icmp/net_db.h"
 #include "ip/tools.h"
 #include "md5.h"
@@ -1562,7 +1563,7 @@ htcpQuery(StoreEntry * e, HttpRequest * req, CachePeer * p)
     HttpHeader hdr(hoRequest);
     Packer pa;
     MemBuf mb;
-    http_state_flags flags;
+    HttpStateFlags flags;
 
     if (!Comm::IsConnOpen(htcpIncomingConn))
         return 0;
@@ -1617,7 +1618,7 @@ htcpClear(StoreEntry * e, const char *uri, HttpRequest * req, const HttpRequestM
     HttpHeader hdr(hoRequest);
     Packer pa;
     MemBuf mb;
-    http_state_flags flags;
+    HttpStateFlags flags;
 
     if (!Comm::IsConnOpen(htcpIncomingConn))
         return;
index 0122d6bf21ecec64318e5d7a54e0fb23ae8ea1f8..33082c3159b26f863ac68f0afc652ba6e0b2f7f1 100644 (file)
@@ -58,6 +58,7 @@
 #include "HttpHeaderTools.h"
 #include "HttpReply.h"
 #include "HttpRequest.h"
+#include "HttpStateFlags.h"
 #include "log/access_log.h"
 #include "MemBuf.h"
 #include "MemObject.h"
@@ -98,7 +99,7 @@ static const char *const crlf = "\r\n";
 
 static void httpMaybeRemovePublic(StoreEntry *, http_status);
 static void copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, const String strConnection, const HttpRequest * request,
-        HttpHeader * hdr_out, const int we_do_ranges, const http_state_flags);
+        HttpHeader * hdr_out, const int we_do_ranges, const HttpStateFlags &);
 //Declared in HttpHeaderTools.cc
 void httpHdrAdd(HttpHeader *heads, HttpRequest *request, const AccessLogEntryPointer &al, HeaderWithAclList &headers_add);
 
@@ -622,7 +623,7 @@ HttpStateData::keepaliveAccounting(HttpReply *reply)
                 && reply->bodySize(request->method) == -1 && !flags.chunked) {
             debugs(11, DBG_IMPORTANT, "keepaliveAccounting: Impossible keep-alive header from '" << entry->url() << "'" );
             // debugs(11, 2, "GOT HTTP REPLY HDR:\n---------\n" << readBuf->content() << "\n----------" );
-            flags.keepalive_broken = 1;
+            flags.keepalive_broken = true;
         }
     }
 }
@@ -678,7 +679,7 @@ HttpStateData::processReplyHeader()
     } else {
         if (!parsed && error > 0) { // unrecoverable parsing error
             debugs(11, 3, "processReplyHeader: Non-HTTP-compliant header: '" <<  readBuf->content() << "'");
-            flags.headers_parsed = 1;
+            flags.headers_parsed = true;
             newrep->sline.version = HttpVersion(1,1);
             newrep->sline.status = error;
             HttpReply *vrep = setVirginReply(newrep);
@@ -710,9 +711,9 @@ HttpStateData::processReplyHeader()
         return;
     }
 
-    flags.chunked = 0;
+    flags.chunked = false;
     if (newrep->sline.protocol == AnyP::PROTO_HTTP && newrep->header.chunked()) {
-        flags.chunked = 1;
+        flags.chunked = true;
         httpChunkDecoder = new ChunkedCodingParser;
     }
 
@@ -720,7 +721,7 @@ HttpStateData::processReplyHeader()
         request->flags.connectionAuthDisabled = 1;
 
     HttpReply *vrep = setVirginReply(newrep);
-    flags.headers_parsed = 1;
+    flags.headers_parsed = true;
 
     keepaliveAccounting(vrep);
 
@@ -1068,7 +1069,7 @@ HttpStateData::readReply(const CommIoCbParams &io)
     int clen;
     int len = io.size;
 
-    flags.do_next_read = 0;
+    flags.do_next_read = false;
 
     debugs(11, 5, HERE << io.conn << ": len " << len << ".");
 
@@ -1088,12 +1089,12 @@ HttpStateData::readReply(const CommIoCbParams &io)
         debugs(11, 2, HERE << io.conn << ": read failure: " << xstrerror() << ".");
 
         if (ignoreErrno(io.xerrno)) {
-            flags.do_next_read = 1;
+            flags.do_next_read = true;
         } else {
             ErrorState *err = new ErrorState(ERR_READ_ERROR, HTTP_BAD_GATEWAY, fwd->request);
             err->xerrno = io.xerrno;
             fwd->fail(err);
-            flags.do_next_read = 0;
+            flags.do_next_read = false;
             serverConnection->close();
         }
 
@@ -1136,7 +1137,7 @@ HttpStateData::readReply(const CommIoCbParams &io)
 
     if (len == 0) { // reached EOF?
         eof = 1;
-        flags.do_next_read = 0;
+        flags.do_next_read = false;
 
         /* Bug 2879: Replies may terminate with \r\n then EOF instead of \r\n\r\n
          * Ensure here that we have at minimum two \r\n when EOF is seen.
@@ -1200,7 +1201,7 @@ HttpStateData::continueAfterParsingHeader()
 
     if (!flags.headers_parsed && !eof) {
         debugs(11, 9, HERE << "needs more at " << readBuf->contentSize());
-        flags.do_next_read = 1;
+        flags.do_next_read = true;
         /** \retval false If we have not finished parsing the headers and may get more data.
          *                Schedules more reads to retrieve the missing data.
          */
@@ -1246,7 +1247,7 @@ HttpStateData::continueAfterParsingHeader()
     assert(error != ERR_NONE);
     entry->reset();
     fwd->fail(new ErrorState(error, HTTP_BAD_GATEWAY, fwd->request));
-    flags.do_next_read = 0;
+    flags.do_next_read = false;
     serverConnection->close();
     return false; // quit on error
 }
@@ -1309,7 +1310,7 @@ HttpStateData::decodeAndWriteReplyBody()
     addVirginReplyBody(data, len);
     if (doneParsing) {
         lastChunk = 1;
-        flags.do_next_read = 0;
+        flags.do_next_read = false;
     }
     SQUID_EXIT_THROWING_CODE(wasThereAnException);
     return wasThereAnException;
@@ -1329,7 +1330,7 @@ HttpStateData::processReplyBody()
     bool ispinned = false;
 
     if (!flags.headers_parsed) {
-        flags.do_next_read = 1;
+        flags.do_next_read = true;
         maybeReadVirginBody();
         return;
     }
@@ -1349,7 +1350,7 @@ HttpStateData::processReplyBody()
     if (entry->isAccepting()) {
         if (flags.chunked) {
             if (!decodeAndWriteReplyBody()) {
-                flags.do_next_read = 0;
+                flags.do_next_read = false;
                 serverComplete();
                 return;
             }
@@ -1373,7 +1374,7 @@ HttpStateData::processReplyBody()
                 commSetConnTimeout(serverConnection, Config.Timeout.read, nil);
             }
 
-            flags.do_next_read = 1;
+            flags.do_next_read = true;
         }
         break;
 
@@ -1381,7 +1382,7 @@ HttpStateData::processReplyBody()
             debugs(11, 5, "processReplyBody: COMPLETE_PERSISTENT_MSG from " << serverConnection);
             /* yes we have to clear all these! */
             commUnsetConnTimeout(serverConnection);
-            flags.do_next_read = 0;
+            flags.do_next_read = false;
 
             comm_remove_close_handler(serverConnection->fd, closeHandler);
             closeHandler = NULL;
@@ -1442,7 +1443,7 @@ HttpStateData::maybeReadVirginBody()
         return;
 
     if (flags.do_next_read) {
-        flags.do_next_read = 0;
+        flags.do_next_read = false;
         typedef CommCbMemFunT<HttpStateData, CommIoCbParams> Dialer;
         entry->delayAwareRead(serverConnection, readBuf->space(read_size), read_size,
                               JobCallback(11, 5, Dialer, this,  HttpStateData::readReply));
@@ -1496,9 +1497,7 @@ HttpStateData::sendComplete()
                                       TimeoutDialer, this, HttpStateData::httpTimeout);
 
     commSetConnTimeout(serverConnection, Config.Timeout.read, timeoutCall);
-
-    flags.request_sent = 1;
-
+    flags.request_sent = true;
     request->hier.peer_http_request_sent = current_time;
 }
 
@@ -1526,7 +1525,7 @@ HttpStateData::doneWithServer() const
  * Fixup authentication request headers for special cases
  */
 static void
-httpFixupAuthentication(HttpRequest * request, const HttpHeader * hdr_in, HttpHeader * hdr_out, http_state_flags flags)
+httpFixupAuthentication(HttpRequest * request, const HttpHeader * hdr_in, HttpHeader * hdr_out, const HttpStateFlags &flags)
 {
     http_hdr_type header = flags.originpeer ? HDR_AUTHORIZATION : HDR_PROXY_AUTHORIZATION;
 
@@ -1622,7 +1621,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
                                       StoreEntry * entry,
                                       const AccessLogEntryPointer &al,
                                       HttpHeader * hdr_out,
-                                      const http_state_flags flags)
+                                      const HttpStateFlags &flags)
 {
     /* building buffer for complex strings */
 #define BBUF_SZ (MAX_URL+32)
@@ -1808,7 +1807,7 @@ HttpStateData::httpBuildRequestHeader(HttpRequest * request,
  * to our outgoing fetch request.
  */
 void
-copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, const String strConnection, const HttpRequest * request, HttpHeader * hdr_out, const int we_do_ranges, const http_state_flags flags)
+copyOneHeaderFromClientsideRequestToUpstreamRequest(const HttpHeaderEntry *e, const String strConnection, const HttpRequest * request, HttpHeader * hdr_out, const int we_do_ranges, const HttpStateFlags &flags)
 {
     debugs(11, 5, "httpBuildRequestHeader: " << e->name << ": " << e->value );
 
@@ -2055,7 +2054,7 @@ HttpStateData::sendRequest()
     AsyncCall::Pointer timeoutCall =  JobCallback(11, 5,
                                       TimeoutDialer, this, HttpStateData::httpTimeout);
     commSetConnTimeout(serverConnection, Config.Timeout.lifetime, timeoutCall);
-    flags.do_next_read = 1;
+    flags.do_next_read = true;
     maybeReadVirginBody();
 
     if (request->body_pipe != NULL) {
@@ -2068,7 +2067,7 @@ HttpStateData::sendRequest()
         Must(!flags.chunked_request);
         // use chunked encoding if we do not know the length
         if (request->content_length < 0)
-            flags.chunked_request = 1;
+            flags.chunked_request = true;
     } else {
         assert(!requestBodySource);
         typedef CommCbMemFunT<HttpStateData, CommIoCbParams> Dialer;
@@ -2078,31 +2077,31 @@ HttpStateData::sendRequest()
 
     if (_peer != NULL) {
         if (_peer->options.originserver) {
-            flags.proxying = 0;
-            flags.originpeer = 1;
+            flags.proxying = false;
+            flags.originpeer = true;
         } else {
-            flags.proxying = 1;
-            flags.originpeer = 0;
+            flags.proxying = false;
+            flags.originpeer = false;
         }
     } else {
-        flags.proxying = 0;
-        flags.originpeer = 0;
+        flags.proxying = false;
+        flags.originpeer = false;
     }
 
     /*
      * Is keep-alive okay for all request methods?
      */
     if (request->flags.mustKeepalive)
-        flags.keepalive = 1;
+        flags.keepalive = true;
     else if (!Config.onoff.server_pconns)
-        flags.keepalive = 0;
+        flags.keepalive = false;
     else if (_peer == NULL)
-        flags.keepalive = 1;
+        flags.keepalive = true;
     else if (_peer->stats.n_keepalives_sent < 10)
-        flags.keepalive = 1;
+        flags.keepalive = true;
     else if ((double) _peer->stats.n_keepalives_recv /
              (double) _peer->stats.n_keepalives_sent > 0.50)
-        flags.keepalive = 1;
+        flags.keepalive = true;
 
     if (_peer) {
         /*The old code here was
@@ -2118,7 +2117,7 @@ HttpStateData::sendRequest()
          */
         if (neighborType(_peer, request) == PEER_SIBLING &&
                 !_peer->options.allow_miss)
-            flags.only_if_cached = 1;
+            flags.only_if_cached = true;
 
         flags.front_end_https = _peer->front_end_https;
     }
@@ -2278,7 +2277,7 @@ HttpStateData::handleMoreRequestBodyAvailable()
         // XXX: why does not this trigger a debug message on every request?
 
         if (flags.headers_parsed && !flags.abuse_detected) {
-            flags.abuse_detected = 1;
+            flags.abuse_detected = true;
             debugs(11, DBG_IMPORTANT, "http handleMoreRequestBodyAvailable: Likely proxy abuse detected '" << request->client_addr << "' -> '" << entry->url() << "'" );
 
             if (virginReply()->sline.status == HTTP_INVALID_HEADER) {
index 819ba5248bee0c14a0a15201e0b558d8646f1e4b..bcc1bc23bb2d6c200a0afb8059dfdebcad8a2a59 100644 (file)
@@ -33,6 +33,7 @@
 #define SQUID_HTTP_H
 
 #include "comm.h"
+#include "HttpStateFlags.h"
 #include "Server.h"
 
 class ChunkedCodingParser;
@@ -49,7 +50,7 @@ public:
                                        StoreEntry * entry,
                                        const AccessLogEntryPointer &al,
                                        HttpHeader * hdr_out,
-                                       const http_state_flags flags);
+                                       const HttpStateFlags &flags);
 
     virtual const Comm::ConnectionPointer & dataConnection() const;
     /* should be private */
@@ -63,7 +64,7 @@ public:
     CachePeer *_peer;          /* CachePeer request made to */
     int eof;                   /* reached end-of-object? */
     int lastChunk;             /* reached last chunk of a chunk-encoded reply */
-    http_state_flags flags;
+    HttpStateFlags flags;
     size_t read_sz;
     int header_bytes_read;     // to find end of response,
     int64_t reply_bytes_read;  // without relying on StoreEntry
index e9285dccf60440fa2cc81ed0beba65ac14336b65..a5028e2079961a49dec53030007ddba9a5495479 100644 (file)
@@ -141,27 +141,6 @@ struct _fde_disk {
     off_t offset;
 };
 
-// POD
-class http_state_flags
-{
-public:
-    unsigned int proxying:1;
-    unsigned int keepalive:1;
-    unsigned int only_if_cached:1;
-    unsigned int handling1xx:1; ///< we are ignoring or forwarding 1xx response
-    unsigned int headers_parsed:1;
-    unsigned int front_end_https:2;
-    unsigned int originpeer:1;
-    unsigned int keepalive_broken:1;
-    unsigned int abuse_detected:1;
-    unsigned int request_sent:1;
-    unsigned int do_next_read:1;
-    unsigned int consume_body_data:1;
-    unsigned int chunked:1; ///< reading a chunked response; TODO: rename
-    unsigned int chunked_request:1; ///< writing a chunked request
-    unsigned int sentLastChunk:1; ///< do not try to write last-chunk again
-};
-
 #if USE_SSL
 struct _sslproxy_cert_sign {
     int alg;
index 248081f809ab56fce0f018aaa4576ab4792612ff..c5099fa4d571719b782c40b5d48f3bfc7a037f6e 100644 (file)
@@ -45,6 +45,7 @@
 #include "fde.h"
 #include "http.h"
 #include "HttpRequest.h"
+#include "HttpStateFlags.h"
 #include "MemBuf.h"
 #include "PeerSelectState.h"
 #include "SquidConfig.h"
@@ -692,7 +693,7 @@ tunnelRelayConnectRequest(const Comm::ConnectionPointer &srv, void *data)
     TunnelStateData *tunnelState = (TunnelStateData *)data;
     HttpHeader hdr_out(hoRequest);
     Packer p;
-    http_state_flags flags;
+    HttpStateFlags flags;
     debugs(26, 3, HERE << srv << ", tunnelState=" << tunnelState);
     memset(&flags, '\0', sizeof(flags));
     flags.proxying = tunnelState->request->flags.proxying;