I need to be able to retrieve only the schema, host and port from the URL.
So, if my URL is in a browser: http://www.example.com:80/something.pl I need to be able to:http://www.example.com:80
http://www.example.com:80/something.pl
http://www.example.com:80
The URI module can help you cut and cut URIs in any way you want.
If you are trying to do this from a CGI script, you need to look $ENV{SERVER_NAME}and $ENV{SERVER_PORT}.
$ENV{SERVER_NAME}
$ENV{SERVER_PORT}
Using urlthe CGI module method that you use (e.g. CGI.pm or CGI :: Simple ) will make things simpler.
url
URI , :
use 5.010; use URI; my $url = 'http://www.example.com:80/something.pl'; my $uri = URI->new( $url ); say $uri->scheme; say $uri->host; say $uri->port;
modperl, Apache2:: RequestRec, uri, unparsed_uri.
uri
unparsed_uri
You cannot get the exact text entered in the userβs browser, only what is presented on the server.
The server name (virtual host) is in the Server object.
sub cgi_hostname { my $h = $ENV{HTTP_HOST} || $ENV{SERVER_NAME} || 'localhost'; my $dp =$ENV{HTTPS} ? 443 : 80; my $ds =$ENV{HTTPS} ? "s" : ""; my $p = $ENV{SERVER_PORT} || $dp; $h .= ":$p" if ($h !~ /:\d+$/ && $p != $dp); return "http$ds\://$h"; }
Source: https://habr.com/ru/post/1734462/More articles:Serialization of an operation in xaml - serializationConvert graph to canonical string - stringhttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1734459/using-finite-automata-as-keys-to-a-container&usg=ALkJrhjc7RKceR3bdWL6Zd4KxdcIo8Esng.Net 3.5 DLR DynamicObject Help - c#Capturing a random frame from a webcam using GStreamer in Python - pythonIs there a simple solution to show yes and no in combobox silverlight and bind to a database? - data-bindingScrolling iPhone SDK showing extra space - iphoneAdding dates in JavaScript in one line - javascripthttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1734467/how-do-i-publish-a-clickonce-install-in-msbuild-vs2005-that-goes-to-the-proper-directory-and-does-not-create-a-setupexe&usg=ALkJrhhAatxLp8nwJ4C3VTzLqYrUF2fFmQCode Reviews For offshore and temporary developers - code-reviewAll Articles