Skip to content

Commit

Permalink
Only add nonstandard port to Host header
Browse files Browse the repository at this point in the history
Refs #20.

There are some servers (e.g. github pages with custom domain)
which will fail if you provide a port number with the Host
header. The RFC seems to claim that it's only needed if using
a nonstandard port -- so only add the port to the Host header
in that case.

Signed-off-by: Rick Elrod <[email protected]>
  • Loading branch information
relrod committed Feb 24, 2018
1 parent 9b75410 commit dc4a315
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/Http.idr
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,14 @@ sendRequest req = do
port : Int
port = uriPort . uriAuth . uri $ req

portHostHeader : String
portHostHeader =
if port `List.elem` [80, 443]
then ""
else ":" ++ show port

extraHeaders : List (String, String)
extraHeaders = [("Host", host ++ ":" ++ show port), ("Connection", "close")]
extraHeaders = [("Host", host ++ portHostHeader), ("Connection", "close")]

fullRequest : Request a
fullRequest = record { headers $= insertFrom extraHeaders } req
Expand Down

0 comments on commit dc4a315

Please sign in to comment.