Skip to content

Commit

Permalink
Use lwan_request_get_host() instead of the generic get_header()
Browse files Browse the repository at this point in the history
The Host header is ready to be fetched from the request helper struct,
so fetch it rather than looping through all the headers to find the
one we're looking for!
  • Loading branch information
lpereira committed Apr 14, 2024
1 parent 5815281 commit 7985267
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/samples/pastebin/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ static enum lwan_http_status post_paste(struct lwan_request *request,
cache_coro_get_and_ref_entry(pastes, request->conn->coro, key);

if (paste) {
const char *host_hdr = lwan_request_get_header(request, "Host");
const char *host_hdr = lwan_request_get_host(request);

if (!host_hdr)
return HTTP_BAD_REQUEST;
Expand All @@ -140,7 +140,7 @@ static enum lwan_http_status post_paste(struct lwan_request *request,
static enum lwan_http_status doc(struct lwan_request *request,
struct lwan_response *response)
{
const char *host_hdr = lwan_request_get_header(request, "Host");
const char *host_hdr = lwan_request_get_host(request);

if (!host_hdr)
return HTTP_BAD_REQUEST;
Expand Down

0 comments on commit 7985267

Please sign in to comment.