]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/HttpRequest.h
Cleanup: zap CVS Id tags
[thirdparty/squid.git] / src / HttpRequest.h
index 34e382fd17419355d154ac000bc4125f68e6004c..455bd74c8b750cead47d822d763d0c7145f43dde 100644 (file)
@@ -1,6 +1,6 @@
 
 /*
- * $Id: HttpRequest.h,v 1.3 2003/07/14 14:15:56 robertc Exp $
+ * $Id$
  *
  *
  * SQUID Web Proxy Cache          http://www.squid-cache.org/
  *  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.
 #ifndef SQUID_HTTPREQUEST_H
 #define SQUID_HTTPREQUEST_H
 
-#include "typedefs.h"
-#include "HttpHeader.h"
+#include "HttpMsg.h"
 #include "client_side.h"
+#include "HierarchyLogEntry.h"
+#include "HttpRequestMethod.h"
 
 /*  Http Request */
-extern request_t *requestCreate(method_t, protocol_t, const char *urlpath);
-extern void requestDestroy(request_t *);
-extern request_t *requestLink(request_t *);
-extern void requestUnlink(request_t *);
-extern int httpRequestParseHeader(request_t * req, const char *parse_start);
-extern void httpRequestSwapOut(const request_t * req, StoreEntry * e);
-extern void httpRequestPack(const request_t * req, Packer * p);
-extern int httpRequestPrefixLen(const request_t * req);
 extern int httpRequestHdrAllowed(const HttpHeaderEntry * e, String * strConnection);
 extern int httpRequestHdrAllowedByName(http_hdr_type id);
+extern void httpRequestPack(void *obj, Packer *p);
+
 
 class HttpHdrRange;
 
-class request_t
+class HttpRequest: public HttpMsg
 {
 
 public:
-    bool multipartRangeRequest() const;
+    MEMPROXY_CLASS(HttpRequest);
+    HttpRequest();
+    HttpRequest(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath);
+    ~HttpRequest();
+    virtual void reset();
+
+    // use HTTPMSGLOCK() instead of calling this directly
+    virtual HttpRequest *_lock() {
+        return static_cast<HttpRequest*>(HttpMsg::_lock());
+    };
+
+    void initHTTP(const HttpRequestMethod& aMethod, protocol_t aProtocol, const char *aUrlpath);
+
+    virtual HttpRequest *clone() const;
+
+    /* are responses to this request potentially cachable */
+    bool cacheable() const;
+
+    /* Now that we care what host contains it is better off being protected. */
+    /* HACK: These two methods are only inline to get around Makefile dependancies */
+    /*      caused by HttpRequest being used in places it really shouldn't.        */
+    /*      ideally they would be methods of URL instead. */
+    inline void SetHost(const char *src) {
+        host_addr.SetEmpty();
+        host_addr = src;
+        if ( host_addr.IsAnyAddr() ) {
+            xstrncpy(host, src, SQUIDHOSTNAMELEN);
+        } else {
+            host_addr.ToHostname(host, SQUIDHOSTNAMELEN);
+            debugs(23, 3, "HttpRequest::SetHost() given IP: " << host_addr);
+        }
+    };
+    inline const char* GetHost(void) const { return host; };
+
+protected:
+    void clean();
+
+    void init();
+
+public:
+    HttpRequestMethod method;
 
-    method_t method;
-    protocol_t protocol;
     char login[MAX_LOGIN_SZ];
-    char host[SQUIDHOSTNAMELEN + 1];
-    auth_user_request_t *auth_user_request;
+
+private:
+    char host[SQUIDHOSTNAMELEN];
+
+    /***
+     * The client side connection data of pinned connections for the client side
+     * request related objects
+     */
+    ConnStateData *pinned_connection;
+
+public:
+    IpAddress host_addr;
+
+    AuthUserRequest *auth_user_request;
+
     u_short port;
+
     String urlpath;
+
     char *canonical;
-    int link_count;            /* free when zero */
+
     request_flags flags;
-    HttpHdrCc *cache_control;
+
     HttpHdrRange *range;
-    http_version_t http_ver;
+
     time_t ims;
+
     int imslen;
+
     int max_forwards;
-    /* these in_addr's could probably be sockaddr_in's */
 
-    struct in_addr client_addr;
+    IpAddress client_addr;
+
+#if FOLLOW_X_FORWARDED_FOR
+    IpAddress indirect_client_addr;
+#endif /* FOLLOW_X_FORWARDED_FOR */
+
+    IpAddress my_addr;
 
-    struct in_addr my_addr;
-    unsigned short my_port;
-    unsigned short client_port;
-    HttpHeader header;
-    ConnStateData::Pointer body_connection;    /* used by clientReadBody() */
-    int content_length;
     HierarchyLogEntry hier;
+
     err_type errType;
+
     char *peer_login;          /* Configured peer login:password */
+
     time_t lastmod;            /* Used on refreshes */
+
     const char *vary_headers;  /* Used when varying entities are detected. Changes how the store key is calculated */
+
     char *peer_domain;         /* Configured peer forceddomain */
+
     String tag;                        /* Internal tag for this request */
+
     String extacl_user;                /* User name returned by extacl lookup */
+
     String extacl_passwd;      /* Password returned by extacl lookup */
+
     String extacl_log;         /* String to be used for access.log purposes */
+
+#if FOLLOW_X_FORWARDED_FOR
+    String x_forwarded_for_iterator; /* XXX a list of IP addresses */
+#endif /* FOLLOW_X_FORWARDED_FOR */
+
+public:
+    bool multipartRangeRequest() const;
+
+    bool parseFirstLine(const char *start, const char *end);
+
+    int parseHeader(const char *parse_start, int len);
+
+    virtual bool expectingBody(const HttpRequestMethod& unused, int64_t&) const;
+
+    bool bodyNibbled() const; // the request has a [partially] consumed body
+
+    int prefixLen();
+
+    void swapOut(StoreEntry * e);
+
+    void pack(Packer * p);
+
+    static void httpRequestPack(void *obj, Packer *p);
+
+    static HttpRequest * CreateFromUrlAndMethod(char * url, const HttpRequestMethod& method);
+
+    static HttpRequest * CreateFromUrl(char * url);
+
+    void setPinnedConnection(ConnStateData *conn) {
+        pinned_connection = cbdataReference(conn);
+    }
+
+    ConnStateData *pinnedConnection() {
+        return pinned_connection;
+    }
+
+    void releasePinnedConnection() {
+        cbdataReferenceDone(pinned_connection);
+    }
+
+private:
+    const char *packableURI(bool full_uri) const;
+
+protected:
+    virtual void packFirstLineInto(Packer * p, bool full_uri) const;
+
+    virtual bool sanityCheckStartLine(MemBuf *buf, http_status *error);
+
+    virtual void hdrCacheInit();
+
+    virtual bool inheritProperties(const HttpMsg *aMsg);
 };
 
+MEMPROXY_CLASS_INLINE(HttpRequest)          /**DOCS_NOSEMI*/
 
 #endif /* SQUID_HTTPREQUEST_H */