diff options
author | flan <flan@flande.re> | 2017-01-20 16:01:31 +0100 |
---|---|---|
committer | Yorhel <git@yorhel.nl> | 2017-01-21 09:35:55 +0100 |
commit | c604c0c2e725f75346ed29fea081c7ae8559b542 (patch) | |
tree | a0c4aea01bc02ca317c1123480096b4134b62c73 | |
parent | a447f4854fc74fbc856eb411427f70839fbc591e (diff) |
Add reqProtocol() method
-rw-r--r-- | lib/TUWF/Request.pm | 10 | ||||
-rw-r--r-- | lib/TUWF/Request.pod | 4 |
2 files changed, 12 insertions, 2 deletions
diff --git a/lib/TUWF/Request.pm b/lib/TUWF/Request.pm index 5524acc..7081ae0 100644 --- a/lib/TUWF/Request.pm +++ b/lib/TUWF/Request.pm @@ -11,7 +11,7 @@ our $VERSION = '1.0'; our @EXPORT = qw| reqInit reqGets reqGet reqPosts reqPost reqParams reqParam reqUploadMIMEs reqUploadMIME reqUploadRaws reqUploadRaw reqSaveUpload - reqCookie reqMethod reqHeader reqPath reqQuery reqBaseURI reqURI reqHost reqIP reqFCGI + reqCookie reqMethod reqHeader reqPath reqQuery reqProtocol reqBaseURI reqURI reqHost reqIP reqFCGI |; @@ -258,9 +258,15 @@ sub reqPath { } +sub reqProtocol { + return $ENV{HTTPS} ? 'https' : 'http'; +} + + # returns base URI, excluding trailing slash sub reqBaseURI { - return ($ENV{HTTPS} ? 'https://' : 'http://').shift->reqHost(); + my $s = shift; + return $s->reqProtocol().'://'.$s->reqHost(); } diff --git a/lib/TUWF/Request.pod b/lib/TUWF/Request.pod index 21bb910..1d65dbc 100644 --- a/lib/TUWF/Request.pod +++ b/lib/TUWF/Request.pod @@ -157,6 +157,10 @@ have been sent by the client. Returns the path part of the current page, relative to the I<base URI>. Includes a leading slash. +=head2 reqProtocol() + +Returns the protocol used to perform the request, i.e. C<http> or C<https>. + =head2 reqBaseURI() Returns the I<base URI> of the current page. That is, C<http(s)://> plus |