rexyai / RestRserve

R web API framework for building high-performance microservices and app backends
https://restrserve.org
275 stars 32 forks source link

Error in parse headers(headers) : header contains invalid character. #132

Closed AlexandreBeaudoin closed 4 years ago

AlexandreBeaudoin commented 4 years ago

It looks like my headers include the underscore character '_' and I get the following error "Error in parse headers(headers) : header contains invalid character."

After modifying parse_headers.cpp:

bool validate_header_name(const std::string& x) {
  auto check = [&](char c) { return std::isalpha(c) || c == '-' || c == '_'; };
  return std::all_of(x.begin(), x.end(), check);
}

I no longer get that error.

dselivanov commented 4 years ago

Thanks for reporting! you are right, according to rfc7230 header name may consists of:

     token          = 1*tchar

     tchar          = "!" / "#" / "$" / "%" / "&" / "'" / "*"
                    / "+" / "-" / "." / "^" / "_" / "`" / "|" / "~"
                    / DIGIT / ALPHA
                    ; any VCHAR, except delimiters
artemklevtsov commented 4 years ago

Fix in the dev branch now.