0
Fork 0
mirror of https://github.com/ninenines/cowboy.git synced 2025-07-15 20:50:24 +00:00

Add cowboy_http_req:port/1.

Returns the port given in the Host header if present,
otherwise the default port of 443 for HTTPS and 80 for HTTP
is returned.
This commit is contained in:
Loïc Hoguin 2011-05-04 12:05:57 +02:00
parent cc663df5db
commit 6c1f73c53c
6 changed files with 84 additions and 43 deletions

View file

@ -199,7 +199,7 @@ websocket(Config) ->
[Headers, Body] = websocket_headers(erlang:decode_packet(httph, Rest, []), []),
{'Connection', "Upgrade"} = lists:keyfind('Connection', 1, Headers),
{'Upgrade', "WebSocket"} = lists:keyfind('Upgrade', 1, Headers),
{"sec-websocket-location", "ws://localhost/websocket"}
{"sec-websocket-location", "ws://localhost:80/websocket"}
= lists:keyfind("sec-websocket-location", 1, Headers),
{"sec-websocket-origin", "http://localhost"}
= lists:keyfind("sec-websocket-origin", 1, Headers),