]> git.ipfire.org Git - thirdparty/squid.git/blob - src/servers/Http1Server.h
553627bb73966c1994831597c5c8643843600d57
[thirdparty/squid.git] / src / servers / Http1Server.h
1 /*
2 * Copyright (C) 1996-2022 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_SRC_SERVERS_HTTP1SERVER_H
10 #define SQUID_SRC_SERVERS_HTTP1SERVER_H
11
12 #include "servers/forward.h"
13
14 namespace Http
15 {
16 namespace One
17 {
18
19 /// Manages a connection from an HTTP/1 or HTTP/0.9 client.
20 class Server: public ConnStateData
21 {
22 CBDATA_CHILD(Server);
23
24 public:
25 Server(const MasterXaction::Pointer &xact, const bool beHttpsServer);
26 ~Server() override {}
27
28 void readSomeHttpData();
29
30 protected:
31 /* ConnStateData API */
32 Http::Stream *parseOneRequest() override;
33 void processParsedRequest(Http::StreamPointer &context) override;
34 void handleReply(HttpReply *rep, StoreIOBuffer receivedData) override;
35 bool writeControlMsgAndCall(HttpReply *rep, AsyncCall::Pointer &call) override;
36 int pipelinePrefetchMax() const override;
37 time_t idleTimeout() const override;
38 void noteTakeServerConnectionControl(ServerConnectionContext) override;
39
40 /* BodyPipe API */
41 void noteMoreBodySpaceAvailable(BodyPipe::Pointer) override;
42 void noteBodyConsumerAborted(BodyPipe::Pointer) override;
43
44 /* AsyncJob API */
45 void start() override;
46
47 void proceedAfterBodyContinuation(Http::StreamPointer context);
48
49 private:
50 void processHttpRequest(Http::Stream *const context);
51 void handleHttpRequestData();
52
53 /// Handles parsing results. May generate and deliver an error reply
54 /// to the client if parsing is failed, or parses the url and build the
55 /// HttpRequest object using parsing results.
56 /// Return false if parsing is failed, true otherwise.
57 bool buildHttpRequest(Http::StreamPointer &context);
58
59 void setReplyError(Http::StreamPointer &context, HttpRequest::Pointer &request, err_type requestError, Http::StatusCode errStatusCode, const char *requestErrorBytes);
60
61 Http1::RequestParserPointer parser_;
62 HttpRequestMethod method_; ///< parsed HTTP method
63
64 /// temporary hack to avoid creating a true HttpsServer class
65 const bool isHttpsServer;
66 };
67
68 } // namespace One
69 } // namespace Http
70
71 #endif /* SQUID_SRC_SERVERS_HTTP1SERVER_H */
72