src: Just check emptiness for value since spaces around value are stripped

This commit is contained in:
Tatsuhiro Tsujikawa 2014-12-15 23:14:07 +09:00
parent 6f70a53da6
commit 9a35dbc4ab
6 changed files with 3 additions and 23 deletions

View File

@ -357,12 +357,8 @@ std::string value_to_str(const Headers::value_type *nv) {
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) {
return nv && !value_lws(nv);
return nv && !nv->value.empty();
}
nghttp2_nv make_nv(const std::string &name, const std::string &value,

View File

@ -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 "".
std::string value_to_str(const Headers::value_type *nv);
// Returns true if the value of |nv| includes only ' ' (0x20) or '\t'.
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.
// Returns true if the value of |nv| is not empty.
bool non_empty_value(const Headers::value_type *nv);
// Creates nghttp2_nv using |name| and |value| and returns it. The

View File

@ -162,16 +162,6 @@ void test_http2_get_header(void) {
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 {
auto headers = Headers{{"alpha", "0", true},
{"bravo", "1"},

View File

@ -31,7 +31,6 @@ void test_http2_add_header(void);
void test_http2_check_http2_headers(void);
void test_http2_get_unique_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_build_http1_headers_from_norm_headers(void);
void test_http2_lws(void);

View File

@ -73,7 +73,6 @@ int main(int argc, char *argv[]) {
!CU_add_test(pSuite, "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_value_lws", shrpx::test_http2_value_lws) ||
!CU_add_test(pSuite, "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",

View File

@ -921,7 +921,7 @@ int on_response_headers(Http2Session *http2session, Downstream *downstream,
auto status = http2::get_unique_header(nva, ":status");
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) {
http2session->submit_rst_stream(frame->hd.stream_id,