2012-06-04 16:48:31 +02:00
|
|
|
/*
|
2014-03-30 12:09:21 +02:00
|
|
|
* nghttp2 - HTTP/2 C Library
|
2012-06-04 16:48:31 +02:00
|
|
|
*
|
|
|
|
* Copyright (c) 2012 Tatsuhiro Tsujikawa
|
|
|
|
*
|
|
|
|
* Permission is hereby granted, free of charge, to any person obtaining
|
|
|
|
* a copy of this software and associated documentation files (the
|
|
|
|
* "Software"), to deal in the Software without restriction, including
|
|
|
|
* without limitation the rights to use, copy, modify, merge, publish,
|
|
|
|
* distribute, sublicense, and/or sell copies of the Software, and to
|
|
|
|
* permit persons to whom the Software is furnished to do so, subject to
|
|
|
|
* the following conditions:
|
|
|
|
*
|
|
|
|
* The above copyright notice and this permission notice shall be
|
|
|
|
* included in all copies or substantial portions of the Software.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
|
|
|
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
|
|
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
|
|
|
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
|
|
|
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
|
|
|
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
|
|
|
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
|
|
*/
|
|
|
|
#ifndef SHRPX_HTTPS_UPSTREAM_H
|
|
|
|
#define SHRPX_HTTPS_UPSTREAM_H
|
|
|
|
|
|
|
|
#include "shrpx.h"
|
|
|
|
|
2015-05-13 17:17:45 +02:00
|
|
|
#include <cinttypes>
|
2014-08-18 15:59:31 +02:00
|
|
|
#include <memory>
|
|
|
|
|
2012-07-11 11:32:04 +02:00
|
|
|
#include "http-parser/http_parser.h"
|
2012-06-04 16:48:31 +02:00
|
|
|
|
|
|
|
#include "shrpx_upstream.h"
|
2014-12-27 18:59:06 +01:00
|
|
|
#include "memchunk.h"
|
|
|
|
|
|
|
|
using namespace nghttp2;
|
2012-06-04 16:48:31 +02:00
|
|
|
|
|
|
|
namespace shrpx {
|
|
|
|
|
|
|
|
class ClientHandler;
|
|
|
|
|
|
|
|
class HttpsUpstream : public Upstream {
|
|
|
|
public:
|
|
|
|
HttpsUpstream(ClientHandler *handler);
|
|
|
|
virtual ~HttpsUpstream();
|
|
|
|
virtual int on_read();
|
2012-06-04 20:11:43 +02:00
|
|
|
virtual int on_write();
|
2012-06-04 16:48:31 +02:00
|
|
|
virtual int on_event();
|
2014-06-27 15:34:54 +02:00
|
|
|
virtual int on_downstream_abort_request(Downstream *downstream,
|
|
|
|
unsigned int status_code);
|
2014-11-27 15:39:04 +01:00
|
|
|
virtual ClientHandler *get_client_handler() const;
|
2014-12-27 18:59:06 +01:00
|
|
|
|
|
|
|
virtual int downstream_read(DownstreamConnection *dconn);
|
|
|
|
virtual int downstream_write(DownstreamConnection *dconn);
|
|
|
|
virtual int downstream_eof(DownstreamConnection *dconn);
|
|
|
|
virtual int downstream_error(DownstreamConnection *dconn, int events);
|
|
|
|
|
2014-08-18 15:59:31 +02:00
|
|
|
void attach_downstream(std::unique_ptr<Downstream> downstream);
|
2012-09-20 15:28:40 +02:00
|
|
|
void delete_downstream();
|
2014-11-27 15:39:04 +01:00
|
|
|
Downstream *get_downstream() const;
|
2014-08-18 15:59:31 +02:00
|
|
|
std::unique_ptr<Downstream> pop_downstream();
|
2015-01-21 14:55:00 +01:00
|
|
|
void error_reply(unsigned int status_code);
|
2012-06-04 16:48:31 +02:00
|
|
|
|
2012-11-18 13:23:13 +01:00
|
|
|
virtual void pause_read(IOCtrlReason reason);
|
2014-08-21 14:22:16 +02:00
|
|
|
virtual int resume_read(IOCtrlReason reason, Downstream *downstream,
|
|
|
|
size_t consumed);
|
2012-06-04 16:48:31 +02:00
|
|
|
|
|
|
|
virtual int on_downstream_header_complete(Downstream *downstream);
|
2014-11-27 15:39:04 +01:00
|
|
|
virtual int on_downstream_body(Downstream *downstream, const uint8_t *data,
|
|
|
|
size_t len, bool flush);
|
2012-06-04 16:48:31 +02:00
|
|
|
virtual int on_downstream_body_complete(Downstream *downstream);
|
|
|
|
|
2014-11-18 17:59:09 +01:00
|
|
|
virtual void on_handler_delete();
|
2016-09-14 15:16:07 +02:00
|
|
|
virtual int on_downstream_reset(Downstream *downstream, bool no_retry);
|
2015-09-03 15:29:16 +02:00
|
|
|
virtual int send_reply(Downstream *downstream, const uint8_t *body,
|
|
|
|
size_t bodylen);
|
2016-03-03 16:38:43 +01:00
|
|
|
virtual int initiate_push(Downstream *downstream, const StringRef &uri);
|
2015-10-02 15:42:46 +02:00
|
|
|
virtual int response_riovec(struct iovec *iov, int iovcnt) const;
|
|
|
|
virtual void response_drain(size_t n);
|
|
|
|
virtual bool response_empty() const;
|
2014-11-18 17:59:09 +01:00
|
|
|
|
2015-11-15 16:12:54 +01:00
|
|
|
virtual Downstream *on_downstream_push_promise(Downstream *downstream,
|
|
|
|
int32_t promised_stream_id);
|
|
|
|
virtual int
|
|
|
|
on_downstream_push_promise_complete(Downstream *downstream,
|
|
|
|
Downstream *promised_downstream);
|
|
|
|
virtual bool push_enabled() const;
|
|
|
|
virtual void cancel_premature_downstream(Downstream *promised_downstream);
|
|
|
|
|
2012-06-05 15:13:22 +02:00
|
|
|
void reset_current_header_length();
|
2015-09-11 16:07:00 +02:00
|
|
|
void log_response_headers(DefaultMemchunks *buf) const;
|
2014-11-27 15:39:04 +01:00
|
|
|
|
2012-06-04 16:48:31 +02:00
|
|
|
private:
|
|
|
|
ClientHandler *handler_;
|
2013-09-23 17:18:00 +02:00
|
|
|
http_parser htp_;
|
2012-06-05 15:13:22 +02:00
|
|
|
size_t current_header_length_;
|
2014-08-18 15:59:31 +02:00
|
|
|
std::unique_ptr<Downstream> downstream_;
|
2012-06-04 20:11:43 +02:00
|
|
|
IOControl ioctrl_;
|
2012-06-04 16:48:31 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace shrpx
|
|
|
|
|
|
|
|
#endif // SHRPX_HTTPS_UPSTREAM_H
|