aboutsummaryrefslogtreecommitdiffstats
path: root/apps/http-proxy/src/http_session.h
diff options
context:
space:
mode:
authorMauro Sardara <msardara@cisco.com>2020-05-27 19:16:27 +0200
committerMauro Sardara <msardara@cisco.com>2020-05-29 20:25:19 +0200
commitf54ae4ed4fd2f22525492e2525d0f24a314e65b2 (patch)
treefa0ac2ced671ccffd24a885e930834b8e2ecba48 /apps/http-proxy/src/http_session.h
parent4214534b001c27f1923bbb2a8e69fd7372ba5947 (diff)
[HICH-618] HTTP proxy automatic configuration.
Change-Id: I6a76b31b743f155a2d9f7b88e84b838265aab6c8 Signed-off-by: Mauro Sardara <msardara@cisco.com>
Diffstat (limited to 'apps/http-proxy/src/http_session.h')
-rw-r--r--apps/http-proxy/src/http_session.h31
1 files changed, 28 insertions, 3 deletions
diff --git a/apps/http-proxy/src/http_session.h b/apps/http-proxy/src/http_session.h
index 20ebc5d7d..05fdf62fa 100644
--- a/apps/http-proxy/src/http_session.h
+++ b/apps/http-proxy/src/http_session.h
@@ -17,6 +17,8 @@
#include <hicn/transport/core/packet.h>
+#include "HTTP1.xMessageFastParser.h"
+
#define ASIO_STANDALONE
#include <asio.hpp>
#include <deque>
@@ -26,8 +28,10 @@ namespace transport {
using asio::ip::tcp;
+struct Metadata;
+
typedef std::function<void(const uint8_t *data, std::size_t size, bool is_last,
- bool headers)>
+ bool headers, Metadata *metadata)>
ContentReceivedCallback;
typedef std::function<bool(asio::ip::tcp::socket &socket)> OnConnectionClosed;
typedef std::function<void()> ContentSentCallback;
@@ -35,7 +39,25 @@ typedef std::deque<
std::pair<std::unique_ptr<utils::MemBuf>, ContentSentCallback>>
BufferQueue;
+struct Metadata {
+ std::string http_version;
+ HTTPHeaders headers;
+};
+
+struct RequestMetadata : Metadata {
+ std::string method;
+ std::string path;
+};
+
+struct ResponseMetadata : Metadata {
+ std::string status_code;
+ std::string status_string;
+};
+
+class HTTPClientConnectionCallback;
+
class HTTPSession {
+ friend class HTTPClientConnectionCallback;
static constexpr uint32_t buffer_size = 1024 * 512;
enum class ConnectorState {
@@ -47,11 +69,11 @@ class HTTPSession {
public:
HTTPSession(asio::io_service &io_service, std::string &ip_address,
std::string &port, ContentReceivedCallback receive_callback,
- OnConnectionClosed on_reconnect_callback, bool reverse = false);
+ OnConnectionClosed on_reconnect_callback, bool client = false);
HTTPSession(asio::ip::tcp::socket socket,
ContentReceivedCallback receive_callback,
- OnConnectionClosed on_reconnect_callback, bool reverse = true);
+ OnConnectionClosed on_reconnect_callback, bool client = true);
~HTTPSession();
@@ -104,6 +126,9 @@ class HTTPSession {
ContentReceivedCallback receive_callback_;
OnConnectionClosed on_connection_closed_callback_;
+ // HTTP headers
+ std::unique_ptr<Metadata> header_info_;
+
// Connector state
ConnectorState state_;
};