2012-11-18 13:23:13 +01:00
|
|
|
/*
|
2014-03-30 12:09:21 +02:00
|
|
|
* nghttp2 - HTTP/2 C Library
|
2012-11-18 13:23:13 +01: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_HTTP_DOWNSTREAM_CONNECTION_H
|
|
|
|
#define SHRPX_HTTP_DOWNSTREAM_CONNECTION_H
|
|
|
|
|
|
|
|
#include "shrpx.h"
|
|
|
|
|
2012-11-20 17:29:39 +01:00
|
|
|
#include "http-parser/http_parser.h"
|
|
|
|
|
2012-11-18 13:23:13 +01:00
|
|
|
#include "shrpx_downstream_connection.h"
|
2012-11-20 17:29:39 +01:00
|
|
|
#include "shrpx_io_control.h"
|
2015-02-04 13:15:58 +01:00
|
|
|
#include "shrpx_connection.h"
|
2012-11-18 13:23:13 +01:00
|
|
|
|
|
|
|
namespace shrpx {
|
|
|
|
|
2014-10-13 14:09:00 +02:00
|
|
|
class DownstreamConnectionPool;
|
2016-02-06 15:07:00 +01:00
|
|
|
class Worker;
|
2016-02-27 15:24:14 +01:00
|
|
|
struct DownstreamAddrGroup;
|
|
|
|
struct DownstreamAddr;
|
2014-10-13 14:09:00 +02:00
|
|
|
|
2012-11-18 13:23:13 +01:00
|
|
|
class HttpDownstreamConnection : public DownstreamConnection {
|
|
|
|
public:
|
2016-02-27 15:24:14 +01:00
|
|
|
HttpDownstreamConnection(DownstreamAddrGroup *group, struct ev_loop *loop,
|
|
|
|
Worker *worker);
|
2012-11-18 13:23:13 +01:00
|
|
|
virtual ~HttpDownstreamConnection();
|
|
|
|
virtual int attach_downstream(Downstream *downstream);
|
2012-11-20 17:29:39 +01:00
|
|
|
virtual void detach_downstream(Downstream *downstream);
|
2012-11-18 13:23:13 +01:00
|
|
|
|
|
|
|
virtual int push_request_headers();
|
|
|
|
virtual int push_upload_data_chunk(const uint8_t *data, size_t datalen);
|
|
|
|
virtual int end_upload_data();
|
|
|
|
|
2012-11-20 17:29:39 +01:00
|
|
|
virtual void pause_read(IOCtrlReason reason);
|
2014-08-21 14:22:16 +02:00
|
|
|
virtual int resume_read(IOCtrlReason reason, size_t consumed);
|
2012-11-20 17:29:39 +01:00
|
|
|
virtual void force_resume_read();
|
|
|
|
|
|
|
|
virtual int on_read();
|
|
|
|
virtual int on_write();
|
|
|
|
|
2013-08-03 11:51:01 +02:00
|
|
|
virtual void on_upstream_change(Upstream *upstream);
|
|
|
|
|
2015-03-10 15:11:22 +01:00
|
|
|
virtual bool poolable() const { return true; }
|
|
|
|
|
2016-02-27 15:24:14 +01:00
|
|
|
virtual DownstreamAddrGroup *get_downstream_addr_group() const;
|
|
|
|
|
2016-02-06 17:07:44 +01:00
|
|
|
int read_clear();
|
|
|
|
int write_clear();
|
|
|
|
int read_tls();
|
|
|
|
int write_tls();
|
2016-02-06 11:50:21 +01:00
|
|
|
|
2016-02-06 17:07:44 +01:00
|
|
|
int process_input(const uint8_t *data, size_t datalen);
|
2016-02-06 11:50:21 +01:00
|
|
|
int tls_handshake();
|
|
|
|
|
|
|
|
int connected();
|
2014-12-27 18:59:06 +01:00
|
|
|
void signal_write();
|
2014-11-27 15:39:04 +01:00
|
|
|
|
2016-02-06 11:50:21 +01:00
|
|
|
int noop();
|
|
|
|
|
2012-11-20 17:29:39 +01:00
|
|
|
private:
|
2015-02-04 13:15:58 +01:00
|
|
|
Connection conn_;
|
2016-02-06 11:50:21 +01:00
|
|
|
std::function<int(HttpDownstreamConnection &)> do_read_, do_write_;
|
2016-02-06 15:07:00 +01:00
|
|
|
Worker *worker_;
|
2016-02-06 11:50:21 +01:00
|
|
|
// nullptr if TLS is not used.
|
|
|
|
SSL_CTX *ssl_ctx_;
|
2016-02-27 15:24:14 +01:00
|
|
|
DownstreamAddrGroup *group_;
|
2016-02-07 10:22:57 +01:00
|
|
|
// Address of remote endpoint
|
2016-02-21 08:35:43 +01:00
|
|
|
DownstreamAddr *addr_;
|
2012-11-20 17:29:39 +01:00
|
|
|
IOControl ioctrl_;
|
2013-09-23 17:13:40 +02:00
|
|
|
http_parser response_htp_;
|
2012-11-18 13:23:13 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace shrpx
|
|
|
|
|
|
|
|
#endif // SHRPX_HTTP_DOWNSTREAM_CONNECTION_H
|