]> git.ipfire.org Git - thirdparty/squid.git/blob - src/adaptation/icap/InOut.h
SourceFormat Enforcement
[thirdparty/squid.git] / src / adaptation / icap / InOut.h
1 /*
2 * Copyright (C) 1996-2014 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_ICAPINOUT_H
10 #define SQUID_ICAPINOUT_H
11
12 #include "HttpMsg.h"
13 #include "HttpReply.h"
14 #include "HttpRequest.h"
15
16 // IcapInOut manages a pointer to the HTTP message being worked on.
17 // For HTTP responses, request header information is also available
18 // as the "cause". ICAP transactions use this class to store virgin
19 // and adapted HTTP messages.
20
21 namespace Adaptation
22 {
23 namespace Icap
24 {
25
26 class InOut
27 {
28
29 public:
30 typedef HttpMsg Header;
31
32 InOut(): header(0), cause(0) {}
33
34 ~InOut() {
35 HTTPMSGUNLOCK(cause);
36 HTTPMSGUNLOCK(header);
37 }
38
39 void setCause(HttpRequest *r) {
40 if (r) {
41 HTTPMSGUNLOCK(cause);
42 cause = r;
43 HTTPMSGLOCK(cause);
44 } else {
45 assert(!cause);
46 }
47 }
48
49 void setHeader(Header *h) {
50 HTTPMSGUNLOCK(header);
51 header = h;
52 HTTPMSGLOCK(header);
53 body_pipe = header->body_pipe;
54 }
55
56 public:
57 // virgin or adapted message being worked on
58 Header *header; // parsed HTTP status/request line and headers
59
60 // HTTP request header for HTTP responses (the cause of the response)
61 HttpRequest *cause;
62
63 // Copy of header->body_pipe, in case somebody moves the original.
64 BodyPipe::Pointer body_pipe;
65 };
66
67 // TODO: s/Header/Message/i ?
68
69 } // namespace Icap
70 } // namespace Adaptation
71
72 #endif /* SQUID_ICAPINOUT_H */
73