diff --git a/src/node_http2.cc b/src/node_http2.cc index 29d1207ecff58f..01d0eb3418b39f 100644 --- a/src/node_http2.cc +++ b/src/node_http2.cc @@ -437,8 +437,7 @@ Http2Session::Callbacks::Callbacks(bool kHasGetPaddingCallback) { callbacks_, OnFrameNotSent); nghttp2_session_callbacks_set_on_invalid_header_callback2( callbacks_, OnInvalidHeader); - nghttp2_session_callbacks_set_error_callback( - callbacks_, OnNghttpError); + nghttp2_session_callbacks_set_error_callback2(callbacks_, OnNghttpError); nghttp2_session_callbacks_set_send_data_callback( callbacks_, OnSendData); nghttp2_session_callbacks_set_on_invalid_frame_recv_callback( @@ -1257,13 +1256,10 @@ ssize_t Http2Session::OnSelectPadding(nghttp2_session* handle, return padding; } -#define BAD_PEER_MESSAGE "Remote peer returned unexpected data while we " \ - "expected SETTINGS frame. Perhaps, peer does not " \ - "support HTTP/2 properly." - // We use this currently to determine when an attempt is made to use the http2 // protocol with a non-http2 peer. int Http2Session::OnNghttpError(nghttp2_session* handle, + int lib_error_code, const char* message, size_t len, void* user_data) { @@ -1271,7 +1267,7 @@ int Http2Session::OnNghttpError(nghttp2_session* handle, // the session errored because the peer is not an http2 peer. Http2Session* session = static_cast(user_data); Debug(session, "Error '%s'", message); - if (strncmp(message, BAD_PEER_MESSAGE, len) == 0) { + if (lib_error_code == NGHTTP2_ERR_SETTINGS_EXPECTED) { Environment* env = session->env(); Isolate* isolate = env->isolate(); HandleScope scope(isolate); diff --git a/src/node_http2.h b/src/node_http2.h index fea51d2d7f3b28..87f6ab8305a7d8 100644 --- a/src/node_http2.h +++ b/src/node_http2.h @@ -843,11 +843,11 @@ class Http2Session : public AsyncWrap, const nghttp2_frame* frame, size_t maxPayloadLen, void* user_data); - static int OnNghttpError( - nghttp2_session* session, - const char* message, - size_t len, - void* user_data); + static int OnNghttpError(nghttp2_session* session, + int lib_error_code, + const char* message, + size_t len, + void* user_data); static int OnSendData( nghttp2_session* session, nghttp2_frame* frame,