src: Just check emptiness for value since spaces around value are stripped
This commit is contained in:
parent
6f70a53da6
commit
9a35dbc4ab
|
@ -357,12 +357,8 @@ std::string value_to_str(const Headers::value_type *nv) {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
bool value_lws(const Headers::value_type *nv) {
|
|
||||||
return (*nv).value.find_first_not_of("\t ") == std::string::npos;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool non_empty_value(const Headers::value_type *nv) {
|
bool non_empty_value(const Headers::value_type *nv) {
|
||||||
return nv && !value_lws(nv);
|
return nv && !nv->value.empty();
|
||||||
}
|
}
|
||||||
|
|
||||||
nghttp2_nv make_nv(const std::string &name, const std::string &value,
|
nghttp2_nv make_nv(const std::string &name, const std::string &value,
|
||||||
|
|
|
@ -130,11 +130,7 @@ const Headers::value_type *get_header(const Headers &nva, const char *name);
|
||||||
// Returns nv->second if nv is not nullptr. Otherwise, returns "".
|
// Returns nv->second if nv is not nullptr. Otherwise, returns "".
|
||||||
std::string value_to_str(const Headers::value_type *nv);
|
std::string value_to_str(const Headers::value_type *nv);
|
||||||
|
|
||||||
// Returns true if the value of |nv| includes only ' ' (0x20) or '\t'.
|
// Returns true if the value of |nv| is not empty.
|
||||||
bool value_lws(const Headers::value_type *nv);
|
|
||||||
|
|
||||||
// Returns true if the value of |nv| is not empty value and not LWS
|
|
||||||
// and not contain illegal characters.
|
|
||||||
bool non_empty_value(const Headers::value_type *nv);
|
bool non_empty_value(const Headers::value_type *nv);
|
||||||
|
|
||||||
// Creates nghttp2_nv using |name| and |value| and returns it. The
|
// Creates nghttp2_nv using |name| and |value| and returns it. The
|
||||||
|
|
|
@ -162,16 +162,6 @@ void test_http2_get_header(void) {
|
||||||
CU_ASSERT(rv == nullptr);
|
CU_ASSERT(rv == nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void test_http2_value_lws(void) {
|
|
||||||
auto nva = Headers{
|
|
||||||
{"0", "alpha"}, {"1", " alpha"}, {"2", ""}, {" 3", " "}, {" 4", " a "}};
|
|
||||||
CU_ASSERT(!http2::value_lws(&nva[0]));
|
|
||||||
CU_ASSERT(!http2::value_lws(&nva[1]));
|
|
||||||
CU_ASSERT(http2::value_lws(&nva[2]));
|
|
||||||
CU_ASSERT(http2::value_lws(&nva[3]));
|
|
||||||
CU_ASSERT(!http2::value_lws(&nva[4]));
|
|
||||||
}
|
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
auto headers = Headers{{"alpha", "0", true},
|
auto headers = Headers{{"alpha", "0", true},
|
||||||
{"bravo", "1"},
|
{"bravo", "1"},
|
||||||
|
|
|
@ -31,7 +31,6 @@ void test_http2_add_header(void);
|
||||||
void test_http2_check_http2_headers(void);
|
void test_http2_check_http2_headers(void);
|
||||||
void test_http2_get_unique_header(void);
|
void test_http2_get_unique_header(void);
|
||||||
void test_http2_get_header(void);
|
void test_http2_get_header(void);
|
||||||
void test_http2_value_lws(void);
|
|
||||||
void test_http2_copy_norm_headers_to_nva(void);
|
void test_http2_copy_norm_headers_to_nva(void);
|
||||||
void test_http2_build_http1_headers_from_norm_headers(void);
|
void test_http2_build_http1_headers_from_norm_headers(void);
|
||||||
void test_http2_lws(void);
|
void test_http2_lws(void);
|
||||||
|
|
|
@ -73,7 +73,6 @@ int main(int argc, char *argv[]) {
|
||||||
!CU_add_test(pSuite, "http2_get_unique_header",
|
!CU_add_test(pSuite, "http2_get_unique_header",
|
||||||
shrpx::test_http2_get_unique_header) ||
|
shrpx::test_http2_get_unique_header) ||
|
||||||
!CU_add_test(pSuite, "http2_get_header", shrpx::test_http2_get_header) ||
|
!CU_add_test(pSuite, "http2_get_header", shrpx::test_http2_get_header) ||
|
||||||
!CU_add_test(pSuite, "http2_value_lws", shrpx::test_http2_value_lws) ||
|
|
||||||
!CU_add_test(pSuite, "http2_copy_norm_headers_to_nva",
|
!CU_add_test(pSuite, "http2_copy_norm_headers_to_nva",
|
||||||
shrpx::test_http2_copy_norm_headers_to_nva) ||
|
shrpx::test_http2_copy_norm_headers_to_nva) ||
|
||||||
!CU_add_test(pSuite, "http2_build_http1_headers_from_norm_headers",
|
!CU_add_test(pSuite, "http2_build_http1_headers_from_norm_headers",
|
||||||
|
|
|
@ -921,7 +921,7 @@ int on_response_headers(Http2Session *http2session, Downstream *downstream,
|
||||||
auto status = http2::get_unique_header(nva, ":status");
|
auto status = http2::get_unique_header(nva, ":status");
|
||||||
int status_code;
|
int status_code;
|
||||||
|
|
||||||
if (!status || http2::value_lws(status) ||
|
if (!http2::non_empty_value(status) ||
|
||||||
(status_code = http2::parse_http_status_code(status->value)) == -1) {
|
(status_code = http2::parse_http_status_code(status->value)) == -1) {
|
||||||
|
|
||||||
http2session->submit_rst_stream(frame->hd.stream_id,
|
http2session->submit_rst_stream(frame->hd.stream_id,
|
||||||
|
|
Loading…
Reference in New Issue