1 /*
2  * Copyright (C) 1996-2021 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_CLIENTREQUESTCONTEXT_H
10 #define SQUID_CLIENTREQUESTCONTEXT_H
11 
12 #include "base/RefCount.h"
13 #include "cbdata.h"
14 #include "dns/forward.h"
15 #include "helper/forward.h"
16 #include "ipcache.h"
17 
18 #if USE_ADAPTATION
19 #include "adaptation/forward.h"
20 #endif
21 
22 class ACLChecklist;
23 class ClientHttpRequest;
24 class ErrorState;
25 
26 class ClientRequestContext : public RefCountable
27 {
28     CBDATA_CLASS(ClientRequestContext);
29 
30 public:
31     ClientRequestContext(ClientHttpRequest *);
32     ~ClientRequestContext();
33 
34     bool httpStateIsValid();
35     void hostHeaderVerify();
36     void hostHeaderIpVerify(const ipcache_addrs* ia, const Dns::LookupDetails &dns);
37     void hostHeaderVerifyFailed(const char *A, const char *B);
38     void clientAccessCheck();
39     void clientAccessCheck2();
40     void clientAccessCheckDone(const allow_t &answer);
41     void clientRedirectStart();
42     void clientRedirectDone(const Helper::Reply &reply);
43     void clientStoreIdStart();
44     void clientStoreIdDone(const Helper::Reply &reply);
45     void checkNoCache();
46     void checkNoCacheDone(const allow_t &answer);
47 #if USE_ADAPTATION
48 
49     void adaptationAccessCheck();
50 #endif
51 #if USE_OPENSSL
52     /**
53      * Initiates and start the acl checklist to check if the a CONNECT
54      * request must be bumped.
55      \retval true if the acl check scheduled, false if no ssl-bump required
56      */
57     bool sslBumpAccessCheck();
58     /// The callback function for ssl-bump access check list
59     void sslBumpAccessCheckDone(const allow_t &answer);
60 #endif
61 
62     ClientHttpRequest *http;
63     ACLChecklist *acl_checklist;        /* need ptr back so we can unreg if needed */
64     int redirect_state;
65     int store_id_state;
66 
67     bool host_header_verify_done;
68     bool http_access_done;
69     bool adapted_http_access_done;
70 #if USE_ADAPTATION
71     bool adaptation_acl_check_done;
72 #endif
73     bool redirect_done;
74     bool store_id_done;
75     bool no_cache_done;
76     bool interpreted_req_hdrs;
77     bool tosToClientDone;
78     bool nfmarkToClientDone;
79 #if USE_OPENSSL
80     bool sslBumpCheckDone;
81 #endif
82     ErrorState *error; ///< saved error page for centralized/delayed processing
83     bool readNextRequest; ///< whether Squid should read after error handling
84 };
85 
86 #endif /* SQUID_CLIENTREQUESTCONTEXT_H */
87 
88