Skip to content

Commit

Permalink
RequestServer: Extract reason phrase from HTTP headers
Browse files Browse the repository at this point in the history
  • Loading branch information
rmg-x committed Oct 20, 2024
1 parent c3c1bb2 commit 975636b
Showing 1 changed file with 0 additions and 13 deletions.
13 changes: 0 additions & 13 deletions Userland/Services/RequestServer/ConnectionFromClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ struct ConnectionFromClient::ActiveRequest {
bool got_all_headers { false };
size_t downloaded_so_far { 0 };
String url;
Optional<String> reason_phrase;
ByteBuffer body;

ActiveRequest(ConnectionFromClient& client, CURLM* multi, CURL* easy, i32 request_id, int writer_fd)
Expand Down Expand Up @@ -74,18 +73,6 @@ size_t ConnectionFromClient::on_header_received(void* buffer, size_t size, size_
auto* request = static_cast<ActiveRequest*>(user_data);
size_t total_size = size * nmemb;
auto header_line = StringView { static_cast<char const*>(buffer), total_size };

// NOTE: We need to extract the HTTP reason phrase since it can be a custom value.
// Fetching infrastructure needs this value for setting the status message.
if (header_line.starts_with("HTTP/"sv)) {
if (auto const space_positions = header_line.find_all(" "sv); space_positions.size() > 2) {
auto const second_space_offset = space_positions.at(1);
auto const reason_phrase_string_view = header_line.substring_view(second_space_offset + 1);
request->reason_phrase = MUST(String::from_utf8(reason_phrase_string_view));
dbgln("Reason phrase: {}", *request->reason_phrase);
}
}

if (auto colon_index = header_line.find(':'); colon_index.has_value()) {
auto name = header_line.substring_view(0, colon_index.value()).trim_whitespace();
auto value = header_line.substring_view(colon_index.value() + 1, header_line.length() - colon_index.value() - 1).trim_whitespace();
Expand Down

0 comments on commit 975636b

Please sign in to comment.