#1491 Host-Header should be sent first

closed-fixed
http (206)
5
2015-03-12
2015-03-09
No

rfc7230 recommends that the Host:-header should be sent first:

https://tools.ietf.org/html/rfc7230#section-5.4

Since the Host field-value is critical information for handling a
request, a user agent SHOULD generate Host as the first header field
following the request-line.

If one explicitly sets a Host-header, curl emits such a "custom" Host:-header in the order it was set, i.e. not as the first header as recommended by rfc7230:

The order is essentially the same with the curl command line tool and the
PHP curl bindings.

$ nc -l 1234 &
[1] 50827
$ curl -vH 'X-foo: asdf' -H 'Host: asdf' http://127.0.0.1:1234/qwert
Trying 127.0.0.1...
Connected to 127.0.0.1 (127.0.0.1) port 1234 (#0)
GET /qwert HTTP/1.1
User-Agent: curl/7.40.0
Accept: /
X-foo: asdf
Host: asdf

GET /qwert HTTP/1.1
User-Agent: curl/7.40.0
Accept: /
X-foo: asdf
Host: asdf

Discussion

  • Daniel Stenberg

    Daniel Stenberg - 2015-03-09

    Thanks! We should fix this.

     
  • Daniel Stenberg

    Daniel Stenberg - 2015-03-09
    • labels: --> http
    • status: open --> open-confirmed
    • assigned_to: Daniel Stenberg
     
  • Daniel Stenberg

    Daniel Stenberg - 2015-03-12

    Thanks!

    Fixed in commit a5d994941c.

    Man, that included updating 120 test cases to use the new order!

     
  • Daniel Stenberg

    Daniel Stenberg - 2015-03-12
    • status: open-confirmed --> closed-fixed
     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks