Skip to content

Commit

Permalink
Merge branch 'rsmmr-topic-fix-handshake'
Browse files Browse the repository at this point in the history
  • Loading branch information
Mraoul committed Dec 7, 2020
2 parents 5bef155 + 942bca8 commit 73c9d31
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/HTTP2.cc
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ void HTTP2_Analyzer::DeliverStream(int len, const u_char* data, bool orig){
prefaceOffset = 0;
// Evaluate incoming data to determine if it is HTTP2 protocol or not
if (!this->connectionActive) {
if ( ! orig ) {
// The first server-side message MUST be a SETTINGS. However, we can't handle that
// while we have not yet set up data structures, so we buffer it.
if ( serverPreface.empty() ) {
serverPreface = std::string(reinterpret_cast<const char*>(data), len);
return;
}
}

this->connectionActive = connectionPrefaceDetected(len, data);
if(this->connectionActive){
// Skip the preface and process what comes after it.
Expand Down Expand Up @@ -180,6 +189,12 @@ void HTTP2_Analyzer::DeliverStream(int len, const u_char* data, bool orig){
}
delete (frame);
}

if ( serverPreface.size() ) {
auto preface = serverPreface;
serverPreface.clear();
HTTP2_Analyzer::DeliverStream(preface.size(), reinterpret_cast<const u_char*>(preface.data()), false);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/HTTP2.h
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,7 @@ class HTTP2_Analyzer : public tcp::TCP_ApplicationAnalyzer {
int64_t maxHeaderListSize;
uint32_t lastStreams[2];
uint32_t goAwayStream;
std::string serverPreface;

HTTP2_FrameReassembler* reassemblers;
nghttp2_hd_inflater* inflaters[2];
Expand Down

0 comments on commit 73c9d31

Please sign in to comment.