diff options
author | Loïc Hoguin <[email protected]> | 2011-05-04 12:05:57 +0200 |
---|---|---|
committer | Loïc Hoguin <[email protected]> | 2011-05-04 12:52:13 +0200 |
commit | 6c1f73c53c9260d99f71676b400a27f0a853f584 (patch) | |
tree | 5d3ca05904b9f65647a24e8d17e6856583fb8fbc /src/cowboy_http_req.erl | |
parent | cc663df5db916b4f4da532d765fc2d6b5b60933c (diff) | |
download | cowboy-6c1f73c53c9260d99f71676b400a27f0a853f584.tar.gz cowboy-6c1f73c53c9260d99f71676b400a27f0a853f584.tar.bz2 cowboy-6c1f73c53c9260d99f71676b400a27f0a853f584.zip |
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.
Diffstat (limited to 'src/cowboy_http_req.erl')
-rw-r--r-- | src/cowboy_http_req.erl | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/cowboy_http_req.erl b/src/cowboy_http_req.erl index 569bb9b..f0fc15c 100644 --- a/src/cowboy_http_req.erl +++ b/src/cowboy_http_req.erl @@ -17,7 +17,7 @@ -export([ method/1, version/1, peer/1, - host/1, raw_host/1, + host/1, raw_host/1, port/1, path/1, raw_path/1, qs_val/2, qs_val/3, qs_vals/1, raw_qs/1, binding/2, binding/3, bindings/1, @@ -63,6 +63,10 @@ host(Req) -> raw_host(Req) -> {Req#http_req.raw_host, Req}. +-spec port(Req::#http_req{}) -> {Port::ip_port(), Req::#http_req{}}. +port(Req) -> + {Req#http_req.port, Req}. + -spec path(Req::#http_req{}) -> {Path::cowboy_dispatcher:path_tokens(), Req::#http_req{}}. path(Req) -> |