Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Schemeless URL valid in HTTP?

Are schemeless urls like

//blog.flowl.info/

valid in HTTP (rfc?), like in plain HTTP Requests and Responses, or are they only valid in HTML attributes and content ?

HTTP/1.1 302 - Moved
Location: //blog.flowl.info

GET //blog.flowl.info

Update:

I have two contradictionary answers now. Which is correct?

Sidequestion: Why does the browser even resolve those to:

//blog.flowl.info/ 
->
http://blog.flowl.info/

instead of:

//blog.flowl.info/
->
http://blog.flowl.info///blog.flowl.info/
like image 909
Daniel W. Avatar asked Feb 09 '15 14:02

Daniel W.


People also ask

How to check if a URL is valid or not?

Given a URL as a character string str of size N .The task is to check if the given URL is valid or not. The above URL is a valid URL. Note that there is a space after https://, hence the URL is invalid. An approach using java.net.url class to validate a URL is discussed in the previous post.

What happens when a URL’s protocol is omitted?

When a URL’s protocol is omitted, the browser uses the underlying document’s protocol instead. This would allow both (http and https) versions of my Swagger docs to have a working "Try It out!" feature. Sorry, something went wrong.

Is this url valid or invalid in Java?

The above URL is a valid URL. Note that there is a space after https://, hence the URL is invalid. An approach using java.net.url class to validate a URL is discussed in the previous post.

What is the correct URL format for a website?

1 The URL must start with either http or https and 2 then followed by :// and 3 then it must contain www. and 4 then followed by subdomain of length (2, 256) and 5 last part contains top level domain like .com, .org etc.


1 Answers

They are valid in the Location header field (http://greenbytes.de/tech/webdav/rfc7231.html#header.location).

They are not valid in the request line of an HTTP request.

The browser resolves it this way because this is how relative reference resolution works (http://greenbytes.de/tech/webdav/rfc3986.html#reference-resolution).

like image 92
Julian Reschke Avatar answered Oct 16 '22 08:10

Julian Reschke