Skip to content

Commit

Permalink
http/Status: http_status_to_string() returns std::string_view
Browse files Browse the repository at this point in the history
  • Loading branch information
MaxKellermann committed Jan 17, 2025
1 parent 53e0a75 commit 7840bc0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libcommon
6 changes: 2 additions & 4 deletions src/http/server/Send.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -62,12 +62,10 @@ format_status_line(char *p, HttpStatus status) noexcept
{
assert(http_status_is_valid(status));

const char *status_string = http_status_to_string(status);
assert(status_string != nullptr);
std::size_t length = strlen(status_string);
const std::string_view status_string = http_status_to_string(status);

p = (char *)mempcpy(p, "HTTP/1.1 ", 9);
p = (char *)mempcpy(p, status_string, length);
p = std::copy(status_string.begin(), status_string.end(), p);
*p++ = '\r';
*p++ = '\n';

Expand Down
2 changes: 1 addition & 1 deletion src/lb/TranslationHttpRequestHandler.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ LbHttpRequest::OnTranslateResponse(UniquePoolPtr<TranslateResponse> _response) n

const std::string_view body = response.message != nullptr
? std::string_view{response.message}
: std::string_view{http_status_to_string(status)};
: http_status_to_string(status);

_request.SendSimpleResponse(status, location, body);
} else if (response.pool != nullptr) {
Expand Down

0 comments on commit 7840bc0

Please sign in to comment.