2 * nghttp2 - HTTP/2 C Library
4 * Copyright (c) 2012 Tatsuhiro Tsujikawa
6 * Permission is hereby granted, free of charge, to any person obtaining
7 * a copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sublicense, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice shall be
15 * included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 #ifndef SHRPX_HTTPS_UPSTREAM_H
26 #define SHRPX_HTTPS_UPSTREAM_H
34 #include "http-parser/http_parser.h"
36 #include "shrpx_upstream.h"
39 using namespace nghttp2;
45 class HttpsUpstream : public Upstream {
47 HttpsUpstream(ClientHandler *handler);
48 virtual ~HttpsUpstream();
49 virtual int on_read();
50 virtual int on_write();
51 virtual int on_event();
52 virtual int on_downstream_abort_request(Downstream *downstream,
53 unsigned int status_code);
54 virtual ClientHandler *get_client_handler() const;
56 virtual int downstream_read(DownstreamConnection *dconn);
57 virtual int downstream_write(DownstreamConnection *dconn);
58 virtual int downstream_eof(DownstreamConnection *dconn);
59 virtual int downstream_error(DownstreamConnection *dconn, int events);
61 void attach_downstream(std::unique_ptr<Downstream> downstream);
62 void delete_downstream();
63 Downstream *get_downstream() const;
64 std::unique_ptr<Downstream> pop_downstream();
65 void error_reply(unsigned int status_code);
67 virtual void pause_read(IOCtrlReason reason);
68 virtual int resume_read(IOCtrlReason reason, Downstream *downstream,
71 virtual int on_downstream_header_complete(Downstream *downstream);
72 virtual int on_downstream_body(Downstream *downstream, const uint8_t *data,
73 size_t len, bool flush);
74 virtual int on_downstream_body_complete(Downstream *downstream);
76 virtual void on_handler_delete();
77 virtual int on_downstream_reset(bool no_retry);
79 virtual MemchunkPool *get_mcpool();
81 void reset_current_header_length();
82 void log_response_headers(const std::string &hdrs) const;
85 ClientHandler *handler_;
87 size_t current_header_length_;
88 // must be put before downstream_
90 std::unique_ptr<Downstream> downstream_;
96 #endif // SHRPX_HTTPS_UPSTREAM_H