Port Numbers and URLs

our application requests a URL from the user, however the URL may contain information after the end of the address .com or .com.uk (any name of the country).

for example, a user can provide us with an address; www.example.com/sample/userbin?form=sl&t =

Of course, the above URL is made up and will not work, but it illustrates my point.

Our application also stores connection data that allows the application to access the Internet through a proxy server, etc. It also allows the user to specify a port number, but we note that WebClient does not provide a member for the port number.

The only other way is to add the port number to the URL, but how can we do this when we don’t know the URL provided by the user?

+3
source share
3 answers

Why don't you know the domain? If the user entered the correct URL, it matches the pattern, for example:

//<domain>/path/file/whatever

or

<domain>/path/file/whatever

Add Port:

<domain>:<port>/path/file/whatever
+3
source

I don’t know if this will help you, but the ports in the URLs appear immediately after the host name followed by a colon.

Example: (www.example.com on port 8080)

http://www.example.com:8080/
+2
source

Could you split it into / or? eg:

http://google.com|?search=cats
http://google.com|/mail

Where | this is a split. The only possible characters that appear after the URL are / and ?. So you can do the following:

http://google.com|/mail 

then add the port after the domain, and then add additional ones at the end, for example:

http://google.com:8080/mail

I think this is what you mean.

0
source

Source: https://habr.com/ru/post/1731735/


All Articles