Skip to content

Commit d231ef6

Browse files
addaleaxMylesBorins
authored andcommitted
http2: ignore invalid headers explicitly
Required in order for `parallel/test-http2-response-splitting` to pass after upgrading `nghttp2`. PR-URL: #14955 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Colin Ihrig <[email protected]>
1 parent c46e7e1 commit d231ef6

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

src/node_http2_core-inl.h

+12
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,16 @@ inline int Nghttp2Session::OnFrameNotSent(nghttp2_session *session,
140140
return 0;
141141
}
142142

143+
inline int Nghttp2Session::OnInvalidHeader(nghttp2_session* session,
144+
const nghttp2_frame* frame,
145+
nghttp2_rcbuf* name,
146+
nghttp2_rcbuf* value,
147+
uint8_t flags,
148+
void* user_data) {
149+
// Ignore invalid header fields by default.
150+
return 0;
151+
}
152+
143153
// Called when nghttp2 closes a stream, either in response to an RST_STREAM
144154
// frame or the stream closing naturally on it's own
145155
inline int Nghttp2Session::OnStreamClose(nghttp2_session *session,
@@ -910,6 +920,8 @@ Nghttp2Session::Callbacks::Callbacks(bool kHasGetPaddingCallback) {
910920
callbacks, OnDataChunkReceived);
911921
nghttp2_session_callbacks_set_on_frame_not_send_callback(
912922
callbacks, OnFrameNotSent);
923+
nghttp2_session_callbacks_set_on_invalid_header_callback2(
924+
callbacks, OnInvalidHeader);
913925

914926
#ifdef NODE_DEBUG_HTTP2
915927
nghttp2_session_callbacks_set_error_callback(

src/node_http2_core.h

+6
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,12 @@ class Nghttp2Session {
240240
int32_t id,
241241
uint32_t code,
242242
void* user_data);
243+
static inline int OnInvalidHeader(nghttp2_session* session,
244+
const nghttp2_frame* frame,
245+
nghttp2_rcbuf* name,
246+
nghttp2_rcbuf* value,
247+
uint8_t flags,
248+
void* user_data);
243249
static inline int OnDataChunkReceived(nghttp2_session* session,
244250
uint8_t flags,
245251
int32_t id,

0 commit comments

Comments
 (0)