Skip to content

Host header extraction not working #165

@phlax

Description

@phlax

I think this is a bug in axum-server

i have been writing an echo server in axum, and use axum-server for https

im extracting the headers with HeaderMap

when i make an https query - the Host header is missing

$ curl -vk https://localhost:2323
* Host localhost:2323 was resolved.
... snip ...
* ALPN: server accepted h2
* Connected to localhost (127.0.0.1) port 2323
* using HTTP/2
* [HTTP/2] [1] OPENED stream for https://localhost:2323/
* [HTTP/2] [1] [:method: GET]
* [HTTP/2] [1] [:scheme: https]
* [HTTP/2] [1] [:authority: localhost:2323]
* [HTTP/2] [1] [:path: /]
* [HTTP/2] [1] [user-agent: curl/8.12.1]
* [HTTP/2] [1] [accept: */*]
> GET / HTTP/2
> Host: localhost:2323
> User-Agent: curl/8.12.1
> Accept: */*
>
* Request completely sent off
< HTTP/2 200
< content-type: application/json
< content-length: 167
< date: Tue, 18 Mar 2025 15:20:09 GMT
<
{
  "hostname": "echo",
  "method": "GET",
  "headers": {
    "user-agent": "curl/8.12.1",
    "accept": "*/*"
  },
  "query_params": {},
  "body": "",
  "path": ""
}

querying for http 1 or 2 the host is extracted as expected

$ curl -v http://localhost:8787
* Host localhost:8787 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:8787...
* Connected to localhost (::1) port 8787
* using HTTP/1.x
> GET / HTTP/1.1
> Host: localhost:8787
> User-Agent: curl/8.12.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 200 OK
< content-type: application/json
< content-length: 197
< date: Tue, 18 Mar 2025 15:24:15 GMT
<
{
  "hostname": "echo",
  "method": "GET",
  "headers": {
    "host": "localhost:8787",
    "user-agent": "curl/8.12.1",
    "accept": "*/*"
  },
  "query_params": {},
  "body": "",
  "path": ""
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions