Port numbers and URL's
our application requests a URL from a user however the URL might include information after the .com or .com.uk (any country designation) address ending.
for example the user may provide us with an address;
www.example.com/sample/userbin?form=sl&t=Of course 开发者_高级运维the above URL is made up and won't work but it illustrates my point.
Our application also stores connection data to enable the application to access the internet through a proxy server etc. It also allows the user to specify the Port number but we note that WebClient does not provide a member for Port Number.
The only other way is to append the port number to the URL but how can we do this when we don't know the URL provided by the user?
Why don't you know the domain? If the user has entered a valid URL it matches a pattern like:
//<domain>/path/file/whatever
or
<domain>/path/file/whatever
Add port:
<domain>:<port>/path/file/whatever
I don't know if this will help you, but ports in URLs come directly after the hostname, preceded by a colon.
Example: (www.example.com on port 8080)
http://www.example.com:8080/
You could split it up by the / or ? for example:
http://google.com|?search=cats
http://google.com|/mail
Where | is the split. The only possible characters to come after a URL are / and ?. So you could do the following:
http://google.com|/mail
split, then append the port after the domain then append the extra at the end, like so:
http://google.com:8080/mail
I think this is what you mean.
精彩评论