asio-lib: Remove validation offered by nghttp2 lib
This commit is contained in:
parent
9302e3edf4
commit
7897f5b94b
|
@ -336,54 +336,25 @@ int on_header_callback(nghttp2_session *session, const nghttp2_frame *frame,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!nghttp2_check_header_name(name, namelen) ||
|
|
||||||
!nghttp2_check_header_value(value, valuelen)) {
|
|
||||||
stream_error(session, stream_id, NGHTTP2_PROTOCOL_ERROR);
|
|
||||||
|
|
||||||
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto &req = stream->get_request()->impl();
|
auto &req = stream->get_request()->impl();
|
||||||
|
|
||||||
if (name[0] == ':' && !req.headers().empty()) {
|
switch (nghttp2::http2::lookup_token(name, namelen)) {
|
||||||
stream_error(session, stream_id, NGHTTP2_PROTOCOL_ERROR);
|
case nghttp2::http2::HD__METHOD:
|
||||||
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (util::streq_l(":method", name, namelen)) {
|
|
||||||
if (!req.method().empty()) {
|
|
||||||
stream_error(session, stream_id, NGHTTP2_PROTOCOL_ERROR);
|
|
||||||
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
|
|
||||||
}
|
|
||||||
req.method(std::string(value, value + valuelen));
|
req.method(std::string(value, value + valuelen));
|
||||||
} else if (util::streq_l(":scheme", name, namelen)) {
|
break;
|
||||||
if (!req.scheme().empty()) {
|
case nghttp2::http2::HD__SCHEME:
|
||||||
stream_error(session, stream_id, NGHTTP2_PROTOCOL_ERROR);
|
|
||||||
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
|
|
||||||
}
|
|
||||||
req.scheme(std::string(value, value + valuelen));
|
req.scheme(std::string(value, value + valuelen));
|
||||||
} else if (util::streq_l(":authority", name, namelen)) {
|
break;
|
||||||
if (!req.authority().empty()) {
|
case nghttp2::http2::HD__AUTHORITY:
|
||||||
stream_error(session, stream_id, NGHTTP2_PROTOCOL_ERROR);
|
|
||||||
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
|
|
||||||
}
|
|
||||||
req.authority(std::string(value, value + valuelen));
|
req.authority(std::string(value, value + valuelen));
|
||||||
} else if (util::streq_l(":path", name, namelen)) {
|
break;
|
||||||
if (!req.path().empty()) {
|
case nghttp2::http2::HD__PATH:
|
||||||
stream_error(session, stream_id, NGHTTP2_PROTOCOL_ERROR);
|
|
||||||
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
|
|
||||||
}
|
|
||||||
req.path(std::string(value, value + valuelen));
|
req.path(std::string(value, value + valuelen));
|
||||||
} else {
|
break;
|
||||||
if (name[0] == ':') {
|
case nghttp2::http2::HD_HOST:
|
||||||
stream_error(session, stream_id, NGHTTP2_PROTOCOL_ERROR);
|
req.host(std::string(value, value + valuelen));
|
||||||
return NGHTTP2_ERR_TEMPORAL_CALLBACK_FAILURE;
|
// fall through
|
||||||
}
|
default:
|
||||||
|
|
||||||
if (util::streq_l("host", name, namelen)) {
|
|
||||||
req.host(std::string(value, value + valuelen));
|
|
||||||
}
|
|
||||||
|
|
||||||
req.add_header(std::string(name, name + namelen),
|
req.add_header(std::string(name, name + namelen),
|
||||||
std::string(value, value + valuelen));
|
std::string(value, value + valuelen));
|
||||||
}
|
}
|
||||||
|
@ -416,12 +387,6 @@ int on_frame_recv_callback(nghttp2_session *session, const nghttp2_frame *frame,
|
||||||
|
|
||||||
auto &req = stream->get_request()->impl();
|
auto &req = stream->get_request()->impl();
|
||||||
|
|
||||||
if (req.method().empty() || req.scheme().empty() || req.path().empty() ||
|
|
||||||
(req.authority().empty() && req.host().empty())) {
|
|
||||||
stream_error(session, frame->hd.stream_id, NGHTTP2_PROTOCOL_ERROR);
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (req.host().empty()) {
|
if (req.host().empty()) {
|
||||||
req.host(req.authority());
|
req.host(req.authority());
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue