aboutsummaryrefslogtreecommitdiffstats
path: root/apps/http-proxy/includes/hicn/http-proxy/http_session.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/http-proxy/includes/hicn/http-proxy/http_session.h')
-rw-r--r--apps/http-proxy/includes/hicn/http-proxy/http_session.h42
1 files changed, 25 insertions, 17 deletions
diff --git a/apps/http-proxy/includes/hicn/http-proxy/http_session.h b/apps/http-proxy/includes/hicn/http-proxy/http_session.h
index f4a3dbdee..1b7df96a6 100644
--- a/apps/http-proxy/includes/hicn/http-proxy/http_session.h
+++ b/apps/http-proxy/includes/hicn/http-proxy/http_session.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2019 Cisco and/or its affiliates.
+ * Copyright (c) 2021 Cisco and/or its affiliates.
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at:
@@ -17,13 +17,19 @@
#include <hicn/transport/core/packet.h>
-#include "http_1x_message_fast_parser.h"
-
-#define ASIO_STANDALONE
-#include <asio.hpp>
+#ifdef __APPLE__
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Wshorten-64-to-32"
+#endif
+#include <hicn/transport/core/asio_wrapper.h>
+#ifdef __APPLE__
+#pragma clang diagnostic pop
+#endif
#include <deque>
#include <functional>
+#include "http_1x_message_fast_parser.h"
+
namespace transport {
using asio::ip::tcp;
@@ -67,13 +73,16 @@ class HTTPSession {
};
public:
- HTTPSession(asio::io_service &io_service, std::string &ip_address,
- std::string &port, ContentReceivedCallback receive_callback,
- OnConnectionClosed on_reconnect_callback, bool client = false);
+ HTTPSession(asio::io_service &io_service, const std::string &ip_address,
+ const std::string &port,
+ const ContentReceivedCallback &receive_callback,
+ const OnConnectionClosed &on_reconnect_callback,
+ bool client = false);
HTTPSession(asio::ip::tcp::socket socket,
- ContentReceivedCallback receive_callback,
- OnConnectionClosed on_reconnect_callback, bool client = true);
+ const ContentReceivedCallback &receive_callback,
+ const OnConnectionClosed &on_reconnect_callback,
+ bool client = true);
~HTTPSession();
@@ -97,8 +106,7 @@ class HTTPSession {
bool checkConnected();
- private:
- void handleRead(std::error_code ec, std::size_t length);
+ void handleRead(const std::error_code &ec, std::size_t length);
void tryReconnection();
void startConnectionTimer();
void handleDeadline(const std::error_code &ec);
@@ -114,14 +122,14 @@ class HTTPSession {
asio::streambuf input_buffer_;
bool reverse_;
- bool is_reconnection_;
- bool data_available_;
+ bool is_reconnection_ = false;
+ bool data_available_ = false;
- std::size_t content_length_;
+ std::size_t content_length_ = 0;
// Chunked encoding
- bool is_last_chunk_;
- bool chunked_;
+ bool is_last_chunk_ = false;
+ bool chunked_ = false;
ContentReceivedCallback receive_callback_;
OnConnectionClosed on_connection_closed_callback_;