let say I have ip 1.2.3.4
and I mapped it to the following names
folk.dude.cool
homie.dude.cool
bro.dude.cool
pal.dude.cool
buddy.dude.cool
I check the Host
header value in my http server to forward the request to the related module.
Now what http response code should I respond(400?
, 502?
) to client when the value with Host
header is missed or invalid? I note I like to show a error page rather to forward to a default name.
thanks.
Julian is correct:
RFC 2616 - 14.23 Host
... A client MUST include a Host header field in all HTTP/1.1 request messages . If the requested URI does not include an Internet host name for the service being requested, then the Host header field MUST be given with an empty value. An HTTP/1.1 proxy MUST ensure that any request message it forwards does contain an appropriate Host header field that identifies the service being requested by the proxy. All Internet-based HTTP/1.1 servers MUST respond with a 400 (Bad Request) status code to any HTTP/1.1 request message which lacks a Host header field.
When you've got protocol questions, the RFCs are a little dry to read, but very informative.
That's a malformed message, thus 400.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With