I have a question regarding the HTTP format. The first line of a HTTP request looks something like this:
GET /path/to/resource.txt HTTP/1.1
or in other words:
METHOD URI HTTP-VERSION
Is it required that the URI
starts with the /
character so that /path/to/resource.txt
would be the same as path/to/resource.txt
and both are valid?
And if a leading /
is not required, are GET / HTTP/1.1
and GET HTTP/1.1
the same too? (two spaces between GET
and HTTP/1.1
)
See RFC 7230, section 5.3 Request target:
You're talking about origin-form, described in subsection 5.3.1:
And an "absolute path" is defined earlier in section 2.7 as
So yes, some target identifier is required, the path is always prefixed with a slash, and if unknown, empty or inapplicable, it is
/
.