Skip to content

Conversation

@kevinkreiser
Copy link
Owner

@kevinkreiser kevinkreiser commented Nov 19, 2025

@nilsnolde is making good progress on vector tile serving and noticed an issue when hooking it up to qgis. prime_server chokes on the requests. he did all the hard work of debugging it to the section of code that parses header names and values. basic gist is, prime_server wasnt allowing empty values. i guess i didnt read the rfc all that carefully.. anyway this pr adds tests for and fixes that.

Comment on lines -54 to +55
template <class T> size_t name_max(const std::unordered_map<std::string, T>& methods) {
template <class T>
size_t name_max(const std::unordered_map<std::string, T>& methods) {
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

stupid linters

Comment on lines +464 to 465
if ((field_end = partial_buffer.find(':')) == std::string::npos)
throw RESPONSE_400;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok so we still bail if you send headers with no : to separate name and value

Comment on lines +466 to +468
if ((value_begin = partial_buffer.find_first_not_of(' ', field_end + 1)) ==
std::string::npos)
value_begin = partial_buffer.size();
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but now if you dont send a value or if your value is all whitespace we detect that and set the value to empty string

Comment on lines -268 to +291
testable_http_server_t server(context, "ipc:///tmp/test_http_server",
"ipc:///tmp/test_http_proxy_upstream", "ipc:///tmp/test_http_results",
"ipc:///tmp/test_http_interrupt", false,
MAX_REQUEST_SIZE, -1,
testable_http_server_t server(
context, "ipc:///tmp/test_http_server", "ipc:///tmp/test_http_proxy_upstream",
"ipc:///tmp/test_http_results", "ipc:///tmp/test_http_interrupt", false, MAX_REQUEST_SIZE, -1,
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more linter blowback

Comment on lines +193 to +203
request_str = "GET /empty HTTP/1.1\r\nx-often-empty-header: \r\n\r\n";
request = http_request_t::from_string(request_str.c_str(), request_str.size());
auto empty = request.headers.find("x-often-empty-header");
if (empty == request.headers.cend() || !empty->second.empty())
throw std::runtime_error("Request parsing failed");

request_str = "GET /empty HTTP/1.1\r\nx-often-empty-header:\r\n\r\n";
request = http_request_t::from_string(request_str.c_str(), request_str.size());
auto still_empty = request.headers.find("x-often-empty-header");
if (still_empty == request.headers.cend() || !still_empty->second.empty())
throw std::runtime_error("Request parsing failed");
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we try with no value but a ton of whitespace and then again with literally nothing, then below we make sure that no colon still fails

@kevinkreiser kevinkreiser merged commit 89e3d44 into master Nov 19, 2025
2 checks passed
@kevinkreiser kevinkreiser deleted the kk_empty_header branch November 19, 2025 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants