Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP/2 Client #1554

Merged
merged 154 commits into from
May 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
b053c5a
Isolate HTTP/1.x client to it's own class
marty1885 Oct 29, 2023
4ff5082
track message sent and recv
marty1885 Oct 29, 2023
b073f39
skeleton HTTP/2 frame parser
marty1885 Oct 29, 2023
543a508
format
marty1885 Oct 29, 2023
ef3519c
more skeleton for HTTP/2 parsing
marty1885 Oct 31, 2023
c38ca49
Merge remote-tracking branch 'origin/master' into h2-client
marty1885 Oct 31, 2023
4f6034a
Fix dropping 1st request
marty1885 Nov 5, 2023
32dc3b5
format, etc
marty1885 Nov 5, 2023
3512090
format again
marty1885 Nov 5, 2023
a2dee1f
format yet again
marty1885 Nov 5, 2023
88f9978
update trantor
marty1885 Nov 5, 2023
f132339
properly handler protocol errors
marty1885 Nov 5, 2023
bda71e2
non working: send http frames
marty1885 Nov 5, 2023
356c17c
format
marty1885 Nov 5, 2023
921d805
hacky, but working request sending
marty1885 Nov 6, 2023
1165f35
slight cleanup, parse h2 header
marty1885 Nov 6, 2023
8fed760
parse data frames
marty1885 Nov 6, 2023
de139b1
single resp callback called
marty1885 Nov 6, 2023
1e62aae
format
marty1885 Nov 6, 2023
51b68dc
initial populate response data and header
marty1885 Nov 6, 2023
2156197
fix not decompressing HTTP response
marty1885 Nov 6, 2023
37d44b4
workaround clang compile error
marty1885 Nov 6, 2023
fc4b669
Support serialized GoAwau
marty1885 Nov 6, 2023
9102832
cleanup parsing API
marty1885 Nov 7, 2023
0c7e4de
fix clang compile warnings
marty1885 Nov 7, 2023
ffe1f6b
fix more clang warning
marty1885 Nov 7, 2023
ab73516
fix msvc build
marty1885 Nov 7, 2023
05a1867
optimize frame serialization
marty1885 Nov 7, 2023
1a27e8b
some minor improvments
marty1885 Nov 7, 2023
a0a9f7a
enable handling of multiple streams
marty1885 Nov 7, 2023
69f592b
release streamId on fail to decode header
marty1885 Nov 7, 2023
a3a6267
fix
marty1885 Nov 7, 2023
49cfea3
if content-length is present, cehck it matches the amount of data in …
marty1885 Nov 7, 2023
89786de
slight cleanup for error handling
marty1885 Nov 7, 2023
f2a7ac8
handle error
marty1885 Nov 7, 2023
98678dd
handle response with no body
marty1885 Nov 8, 2023
e27b800
handle out-of-order core frames
marty1885 Nov 8, 2023
7202330
reply to pings
marty1885 Nov 8, 2023
3ea6378
respect max concurrent streams
marty1885 Nov 8, 2023
09a8634
handle CR LF in header
marty1885 Nov 8, 2023
3eddcaf
send request body
marty1885 Nov 8, 2023
781ef3c
track window size
marty1885 Nov 8, 2023
8ce2b85
fix MSVC build
marty1885 Nov 8, 2023
75f197e
remove forced printing in debug
marty1885 Nov 8, 2023
9d80aaa
update README
marty1885 Nov 8, 2023
a26c0df
Comply with RFC setup sequence
marty1885 Nov 8, 2023
6b3881f
Turn most error into trace, ignore unknown frames
marty1885 Nov 8, 2023
2b3e6cb
Fix MSVC warnings
marty1885 Nov 8, 2023
a11eea1
Merge branch 'h2-client' of github.com:drogonframework/drogon into h2…
marty1885 Nov 8, 2023
8d9db18
format
marty1885 Nov 8, 2023
3b1db4c
sanitize max frame size settings
marty1885 Nov 8, 2023
b6b2db8
cleanup connection killing
marty1885 Nov 8, 2023
7861715
Correctly keep track of RX window size
marty1885 Nov 8, 2023
c364f72
send stream window update
marty1885 Nov 8, 2023
107c669
track TX window size
marty1885 Nov 8, 2023
ce4e601
politely close stream
marty1885 Nov 8, 2023
5c6e08e
Fix large file download
marty1885 Nov 8, 2023
bc4787a
Fix RX flow control
marty1885 Nov 9, 2023
5702f8f
RFC compliant stream ID assignment
marty1885 Nov 9, 2023
e96e3e7
handle connection close
marty1885 Nov 9, 2023
d50577b
More compliant connection error handling
marty1885 Nov 9, 2023
f5c4863
Sementics cleanup
marty1885 Nov 9, 2023
83606eb
slight optimization
marty1885 Nov 9, 2023
847b580
wip: store headers if we need more frames
marty1885 Nov 9, 2023
2eef512
parse incomming headers in continuation frame
marty1885 Nov 9, 2023
5d43457
fix untrue error message
marty1885 Nov 9, 2023
e565f38
fix unable to post any data
marty1885 Nov 9, 2023
ab566b3
kill connection when PUSH_PROMIS recv
marty1885 Nov 9, 2023
5f52a80
able to parse RST_STREAM
marty1885 Nov 9, 2023
d69699c
add check for DATA, HEADERS and PUSH_PROMISE frames
marty1885 Nov 9, 2023
45a2b1d
react to RST_STREAM
marty1885 Nov 10, 2023
4a2eecf
Handle sending CONTINUATION frame
marty1885 Nov 10, 2023
e13a8b9
handle sending large body
marty1885 Nov 10, 2023
c82e820
remove unneeded delay
marty1885 Nov 10, 2023
e12260a
safer string parsing
marty1885 Nov 10, 2023
0eb2cda
rfc compliant and overflow fix
marty1885 Nov 10, 2023
52d0fdd
format
marty1885 Nov 10, 2023
65d5215
round robbing sending pending body
marty1885 Nov 10, 2023
02d13a5
better ctor for frames
marty1885 Nov 10, 2023
f679900
update trantor
marty1885 Nov 10, 2023
f09c756
Merge remote-tracking branch 'origin/master' into h2-client
marty1885 Nov 10, 2023
9129f6d
correctly track intial RX/TX window
marty1885 Nov 10, 2023
651866d
fix minor ordering bugs
marty1885 Nov 10, 2023
c7b04ef
get rid of duplicated serialization
marty1885 Nov 11, 2023
9247211
track total sent bytes
marty1885 Nov 11, 2023
74cc7ca
allow unsupported frame type
marty1885 Nov 11, 2023
42cfbf8
format
marty1885 Nov 11, 2023
0c7555a
mark response as HTTP/2
marty1885 Nov 11, 2023
b361e1b
buffered write
marty1885 Nov 12, 2023
0ec5b00
remove bad warning
marty1885 Nov 12, 2023
2f9d01f
error on hpack error
marty1885 Nov 16, 2023
1f78acd
Merge remote-tracking branch 'origin/master' into h2-client
marty1885 Nov 21, 2023
e3bc481
Merge branch 'h2-client' of github.com:drogonframework/drogon into h2…
marty1885 Nov 21, 2023
38967ed
pile of small fixes
marty1885 Nov 21, 2023
b43b16d
wip: let client decide the http version to sue
marty1885 Nov 22, 2023
84764eb
some cleanup
marty1885 Nov 22, 2023
1ca87cc
send correct http1 request based on client protocol version
marty1885 Nov 22, 2023
ae30dde
correctly respect HTTP1.x pipelining settings
marty1885 Nov 22, 2023
c6d5192
reconnect HTTP/2 if running out of stream ids
marty1885 Nov 22, 2023
9d69aa7
isolate HTTP1 transport for client
marty1885 Nov 22, 2023
cd0d1e1
implement multipart support for HTTP/2
marty1885 Nov 22, 2023
993e17b
revert client settings
marty1885 Nov 22, 2023
1b6be3b
slight update
marty1885 Nov 22, 2023
826985f
fix build
marty1885 Nov 22, 2023
b07f237
tmp: disable version check
marty1885 Nov 22, 2023
97a720e
fix version check
marty1885 Nov 22, 2023
30213eb
Fix fail in debug build
marty1885 Nov 22, 2023
bff3829
fix debug code
marty1885 Nov 22, 2023
f9733ef
format
marty1885 Nov 22, 2023
9533a70
code style cleanup
marty1885 Nov 23, 2023
d4dfe92
correctly handle scheme in pasthrough mode
marty1885 Nov 23, 2023
93ceb01
format
marty1885 Nov 23, 2023
3a7042e
cleanup timeout handling logic
marty1885 Nov 24, 2023
7cdb39b
don't close connection if using HTTP/2
marty1885 Nov 24, 2023
9dab500
update trantor
marty1885 Nov 27, 2023
70d30ef
update function naming
marty1885 Nov 29, 2023
d0e61a4
check 1st frame must be settings
marty1885 Dec 2, 2023
14345e8
Merge branch 'h2-client' of github.com:drogonframework/drogon into h2…
marty1885 Dec 2, 2023
6d1041a
Merge remote-tracking branch 'origin/master' into h2-client
marty1885 Dec 3, 2023
54a0175
merge with master
marty1885 Dec 3, 2023
c060b66
better round robbin
marty1885 Dec 11, 2023
19c51be
merge with master
marty1885 Dec 11, 2023
df7bf31
fix spelling and update trantor
marty1885 Dec 11, 2023
acfec46
format
marty1885 Dec 11, 2023
1ff1aab
spelling
marty1885 Dec 11, 2023
e5e777b
Merge remote-tracking branch 'origin/master' into h2-client
marty1885 Dec 15, 2023
da61393
avoid status code overflow
marty1885 Dec 15, 2023
26f99ec
fix integer overflow when data frame too small with padding
marty1885 Dec 15, 2023
a38602a
fix windows
marty1885 Dec 15, 2023
4ea865d
fix bad dataframe parsing
marty1885 Jan 3, 2024
7720701
fix: Add support for query params for H2
marty1885 Jan 18, 2024
0b4decb
merge with master
marty1885 Jan 18, 2024
f7550f1
Merge remote-tracking branch 'origin/master' into h2-client
marty1885 Mar 9, 2024
d4d8094
Merge remote-tracking branch 'origin/master' into h2-client
marty1885 Mar 23, 2024
8d91e0e
Merge branch 'h2-client' of github.com:drogonframework/drogon into h2…
marty1885 Mar 23, 2024
0856d28
Merge branch 'master' into h2-client
marty1885 May 4, 2024
43e127d
merge with master
marty1885 May 12, 2024
6dcb6d7
move from hpacker to eric-hpack
marty1885 May 12, 2024
6e0e731
format
marty1885 May 12, 2024
445f709
enable changing dynamic table size
marty1885 May 12, 2024
263d226
fix typo
marty1885 May 12, 2024
dcf674f
fix lint
marty1885 May 12, 2024
93955fa
add license header
marty1885 May 12, 2024
9611bbb
get rid of included eric-hpack. Use submodule
marty1885 May 24, 2024
58cec38
Merge remote-tracking branch 'origin/master' into h2-client
marty1885 May 24, 2024
771da9a
fix codespell
marty1885 May 24, 2024
67ee603
fix format
marty1885 May 24, 2024
820a7eb
update eric-hpack
marty1885 May 25, 2024
9e35d5b
update comment
marty1885 May 25, 2024
d037850
fix cmake
marty1885 May 25, 2024
f0d0f76
replace example URL
marty1885 May 25, 2024
bd6de75
replace example URL to the old one
marty1885 May 25, 2024
b44e7ee
use new eric-hpack-core
marty1885 May 25, 2024
e25b154
use URL that does not redirect
marty1885 May 25, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codespell.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ jobs:
steps:
- uses: actions/checkout@v4
- run: pip install --user codespell[toml]
- run: codespell --ignore-words-list="coo,folx,ot,statics,xwindows" --skip="*.csp"
- run: codespell --ignore-words-list="coo,folx,ot,statics,xwindows,indexs,NotIn" --skip="*.csp"
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
path = trantor
url = https://github.com/an-tao/trantor.git
branch = master
[submodule "third_party/eric-hpack-core"]
path = third_party/eric-hpack-core
url = https://gitlab.com/joe1231231218/eric-hpack-core.git
14 changes: 12 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,10 @@ if (BUILD_BROTLI)
endif (Brotli_FOUND)
endif (BUILD_BROTLI)


target_include_directories(
${PROJECT_NAME}
PRIVATE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/third_party/eric-hpack-core>)
set(DROGON_SOURCES
lib/src/AOPAdvice.cc
lib/src/AccessLogger.cc
Expand All @@ -260,6 +264,8 @@ set(DROGON_SOURCES
lib/src/Hodor.cc
lib/src/HttpAppFrameworkImpl.cc
lib/src/HttpBinder.cc
lib/src/Http2Transport.cc
lib/src/Http1xTransport.cc
lib/src/HttpClientImpl.cc
lib/src/HttpConnectionLimit.cc
lib/src/HttpControllerBinder.cc
Expand Down Expand Up @@ -296,7 +302,8 @@ set(DROGON_SOURCES
lib/src/WebSocketClientImpl.cc
lib/src/WebSocketConnectionImpl.cc
lib/src/YamlConfigAdapter.cc
lib/src/drogon_test.cc)
lib/src/drogon_test.cc
third_party/eric-hpack-core/hpack.cpp)
set(private_headers
lib/src/AOPAdvice.h
lib/src/CacheFile.h
Expand All @@ -305,6 +312,8 @@ set(private_headers
lib/src/MiddlewaresFunction.h
lib/src/HttpAppFrameworkImpl.h
lib/src/HttpClientImpl.h
lib/src/Http2Transport.h
lib/src/Http1xTransport.h
lib/src/HttpConnectionLimit.h
lib/src/HttpControllerBinder.h
lib/src/HttpControllersRouter.h
Expand Down Expand Up @@ -332,7 +341,8 @@ set(private_headers
lib/src/ConfigAdapterManager.h
lib/src/JsonConfigAdapter.h
lib/src/YamlConfigAdapter.h
lib/src/ConfigAdapter.h)
lib/src/ConfigAdapter.h
third_party/eric-hpack-core/hpack.h)

if (NOT WIN32)
set(DROGON_SOURCES
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Drogon is a cross-platform framework, It supports Linux, macOS, FreeBSD, OpenBSD

* Use a non-blocking I/O network lib based on epoll (kqueue under macOS/FreeBSD) to provide high-concurrency, high-performance network IO, please visit the [TFB Tests Results](https://www.techempower.com/benchmarks/#section=data-r19&hw=ph&test=composite) for more details;
* Provide a completely asynchronous programming mode;
* Support Http1.0/1.1 (server side and client side);
* Support HTTP/2 (and 1.0/1.1) client and HTTP 1.1/1.0 server
* Based on template, a simple reflection mechanism is implemented to completely decouple the main program framework, controllers and views.
* Support cookies and built-in sessions;
* Support back-end rendering, the controller generates the data to the view to generate the Html page. Views are described by CSP template files, C++ codes are embedded into Html pages through CSP tags. And the drogon command-line tool automatically generates the C++ code files for compilation;
Expand Down
50 changes: 40 additions & 10 deletions lib/inc/drogon/HttpClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,11 @@ class DROGON_EXPORT HttpClient : public trantor::NonCopyable
* If this method is not called, the default depth value is 0 which means
* the pipelining is disabled. For details about pipelining, see
* rfc2616-8.1.2.2
*
* @param depth The depth value.
* @note This option is only valid for HTTP/1.x. If the client running in
* HTTP/2 mode, this settings have no effect. The maximum concurrent
* requests for HTTP/2 is 100 (unless the server has a different setting).
*/
virtual void setPipeliningDepth(size_t depth) = 0;

Expand Down Expand Up @@ -238,15 +243,20 @@ class DROGON_EXPORT HttpClient : public trantor::NonCopyable
* enabled for HTTPS.
* @param validateCert If the parameter is set to true, the client validates
* the server certificate when SSL handshaking.
* @param targetVersion The target TLS version to use for HTTPS connections.
* This is a mere hint, and the actual version used will depend on the
* server and the client's capabilities.
* @return HttpClientPtr The smart pointer to the new client object.
* @note: The ip parameter support for both ipv4 and ipv6 address
*/
static HttpClientPtr newHttpClient(const std::string &ip,
uint16_t port,
bool useSSL = false,
trantor::EventLoop *loop = nullptr,
bool useOldTLS = false,
bool validateCert = true);
static HttpClientPtr newHttpClient(
const std::string &ip,
uint16_t port,
bool useSSL = false,
trantor::EventLoop *loop = nullptr,
bool useOldTLS = false,
bool validateCert = true,
std::optional<Version> targetVersion = std::nullopt);

/// Get the event loop of the client;
virtual trantor::EventLoop *getLoop() = 0;
Expand Down Expand Up @@ -303,6 +313,16 @@ class DROGON_EXPORT HttpClient : public trantor::NonCopyable
const std::vector<std::pair<std::string, std::string>>
&sslConfCmds) = 0;

/**
* @brief get the protocol version used by the HTTP connection
* @return std::optional<Version> the protocol version used by the HTTP
*
* NOTE: It could return std::nullopt if the connection is not established
* or is still negotiating the protocol. This is IMPORTANT as the client
* COULD be lazy and not connecting until the first request arrives.
*/
virtual std::optional<Version> protocolVersion() const = 0;

/// Create a Http client using the hostString to connect to server
/**
*
Expand All @@ -329,15 +349,25 @@ class DROGON_EXPORT HttpClient : public trantor::NonCopyable
* @param validateCert If the parameter is set to true, the client validates
* the server certificate when SSL handshaking.
*
* @param targetVersion The target HTTP version that the client will attempt
* to use. **THIS IS ONLY A HINT**. The server may choose to ignore this as
* the server may not support the requested version. The preference is as
* follows:
* HTTP/2 > HTTP/1.1 > HTTP/1.0
* Note that there is no way to auto-detect HTTP/1.0 servers, so it is only
* used if explicitly requested.
*
* @note Don't add path and parameters in hostString, the request path and
* parameters should be set in HttpRequestPtr when calling the sendRequest()
* method.
*
*/
static HttpClientPtr newHttpClient(const std::string &hostString,
trantor::EventLoop *loop = nullptr,
bool useOldTLS = false,
bool validateCert = true);
static HttpClientPtr newHttpClient(
const std::string &hostString,
trantor::EventLoop *loop = nullptr,
bool useOldTLS = false,
bool validateCert = true,
std::optional<Version> targetVersion = std::nullopt);

virtual ~HttpClient()
{
Expand Down
1 change: 1 addition & 0 deletions lib/inc/drogon/HttpRequest.h
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,7 @@ class DROGON_EXPORT HttpRequest
/**
* kHttp10 means Http version is 1.0
* kHttp11 means Http version is 1.1
* kHttp20 means Http version is 2.0
*/
virtual Version version() const = 0;

Expand Down
1 change: 1 addition & 0 deletions lib/inc/drogon/HttpResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ class DROGON_EXPORT HttpResponse
/**
* kHttp10 means Http version is 1.0
* kHttp11 means Http version is 1.1
* kHttp2 means Http version is 2.0
*/
virtual Version version() const = 0;

Expand Down
5 changes: 4 additions & 1 deletion lib/inc/drogon/HttpTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,14 @@ enum HttpStatusCode
k511NetworkAuthenticationRequired = 511
};

// TODO: Add an option to use default HTTP version
// as the server may not support HTTP/2.
enum class Version
{
kUnknown = 0,
kHttp10,
kHttp11
kHttp11,
kHttp2,
};

enum ContentType
Expand Down
105 changes: 105 additions & 0 deletions lib/src/Http1xTransport.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
#include "Http1xTransport.h"
#include "HttpResponseParser.h"

using namespace drogon;

Http1xTransport::Http1xTransport(trantor::TcpConnectionPtr connPtr,
Version version,
size_t *bytesSent,
size_t *bytesReceived)
: connPtr(connPtr),
bytesSent_(bytesSent),
bytesReceived_(bytesReceived),
version_(version)
{
connPtr->setContext(std::make_shared<HttpResponseParser>(connPtr));
}

void Http1xTransport::sendRequestInLoop(const HttpRequestPtr &req,
HttpReqCallback &&callback)
{
sendReq(req);
pipeliningCallbacks_.emplace(std::move(req), std::move(callback));
}

void Http1xTransport::onRecvMessage(const trantor::TcpConnectionPtr &conn,
trantor::MsgBuffer *msg)
{
auto responseParser = connPtr->getContext<HttpResponseParser>();
assert(responseParser != nullptr);
assert(connPtr.get() == conn.get());

// LOG_TRACE << "###:" << msg->readableBytes();
auto msgSize = msg->readableBytes();
while (msg->readableBytes() > 0)
{
if (pipeliningCallbacks_.empty())
{
LOG_ERROR << "More responses than expected!";
connPtr->shutdown();
return;
}
auto &firstReq = pipeliningCallbacks_.front();
if (firstReq.first->method() == Head)
{
responseParser->setForHeadMethod();
}
if (!responseParser->parseResponse(msg))
{
*bytesReceived_ += (msgSize - msg->readableBytes());
errorCallback(ReqResult::BadResponse);
return;
}
if (responseParser->gotAll())
{
auto resp = responseParser->responseImpl();
responseParser->reset();
*bytesReceived_ += (msgSize - msg->readableBytes());
msgSize = msg->readableBytes();
respCallback(resp, std::move(firstReq), conn);

pipeliningCallbacks_.pop();
}
else
{
*bytesReceived_ += (msgSize - msg->readableBytes());
break;
}
}
}

Http1xTransport::~Http1xTransport()
{
}

bool Http1xTransport::handleConnectionClose()
{
auto responseParser = connPtr->getContext<HttpResponseParser>();
if (responseParser && responseParser->parseResponseOnClose() &&
responseParser->gotAll())
{
auto &firstReq = pipeliningCallbacks_.front();
if (firstReq.first->method() == Head)
{
responseParser->setForHeadMethod();
}
auto resp = responseParser->responseImpl();
responseParser->reset();
respCallback(resp, std::move(firstReq), connPtr);
return false;
}
return true;
}

void Http1xTransport::sendReq(const HttpRequestPtr &req)
{
trantor::MsgBuffer buffer;
assert(req);
auto implPtr = static_cast<HttpRequestImpl *>(req.get());
assert(version_ == Version::kHttp10 || version_ == Version::kHttp11);
implPtr->appendToBuffer(&buffer, version_);
LOG_TRACE << "Send request:"
<< std::string_view(buffer.peek(), buffer.readableBytes());
*bytesSent_ += buffer.readableBytes();
connPtr->send(std::move(buffer));
}
52 changes: 52 additions & 0 deletions lib/src/Http1xTransport.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#pragma once

#include <trantor/net/EventLoop.h>
#include <trantor/net/TcpClient.h>
#include <list>
#include <queue>
#include <vector>
#include "HttpTransport.h"

namespace drogon
{
class Http1xTransport : public HttpTransport
{
private:
std::queue<std::pair<HttpRequestPtr, HttpReqCallback>> pipeliningCallbacks_;
trantor::TcpConnectionPtr connPtr;
size_t *bytesSent_;
size_t *bytesReceived_;
Version version_{Version::kHttp11};

void sendReq(const HttpRequestPtr &req);

public:
Http1xTransport(trantor::TcpConnectionPtr connPtr,
Version version,
size_t *bytesSent,
size_t *bytesReceived);
virtual ~Http1xTransport();
void sendRequestInLoop(const HttpRequestPtr &req,
HttpReqCallback &&callback) override;
void onRecvMessage(const trantor::TcpConnectionPtr &,
trantor::MsgBuffer *) override;

size_t requestsInFlight() const override
{
return pipeliningCallbacks_.size();
}

bool handleConnectionClose() override;

void onError(ReqResult result) override
{
while (!pipeliningCallbacks_.empty())
{
auto &cb = pipeliningCallbacks_.front().second;
cb(result, nullptr);
pipeliningCallbacks_.pop();
}
}
};

} // namespace drogon
Loading
Loading