From 6c1f73c53c9260d99f71676b400a27f0a853f584 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Wed, 4 May 2011 12:05:57 +0200 Subject: 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. --- src/cowboy_http_req.erl | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/cowboy_http_req.erl') 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) -> -- cgit v1.2.3