Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RequestFactory, REQUEST_URI and absolute URLs #91

Closed
ondrej-tuhacek opened this issue Apr 29, 2016 · 3 comments
Closed

RequestFactory, REQUEST_URI and absolute URLs #91

ondrej-tuhacek opened this issue Apr 29, 2016 · 3 comments

Comments

@ondrej-tuhacek
Copy link
Contributor

@ondrej-tuhacek ondrej-tuhacek commented Apr 29, 2016

Recently I installed this addon to Google Chrome:

https://chrome.google.com/webstore/detail/host-switch-plus/bopepoejgapmihklfepohbilpkcdoaeo

its purpose is something like etc/hosts file with one single exception. If used, it sends HTTP requests like:

GET http://www.example.com/ HTTP/1.1

instead of

GET / HTTP/1.1

which seems to be valid according to https://www.w3.org/Protocols/rfc2616/rfc2616-sec5.html

But Nette shows "no routes" and gives me 404.

Because RequestFactory.php where $_SEVER['REQUEST_URI'] is parsed cannot handle absolute URLs. I quick-fixed this simply by modifying urlFilters from:

    /** @var array */
    public $urlFilters = array(
        'path' => array('#/{2,}#' => '/'), // '%20' => ''
        'url' => array(), // '#[.,)]\z#' => ''
    );

to:

    /** @var array */
    public $urlFilters = array(
        'path' => array('#/{2,}#' => '/'), // '%20' => ''
        'url' => array('#^(http|ftp)s?://[^/]+/#' => '/'), // '#[.,)]\z#' => ''
    );

and it works, but I'm not sure if this is the best way to "fix" this.

@Majkl578

This comment has been minimized.

Copy link
Contributor

@Majkl578 Majkl578 commented Apr 29, 2016

According to RFC 7230 ch. 5.3 - Request Target, this is not valid.

When making a request directly to an origin server, other than a
CONNECT or server-wide OPTIONS request (as detailed below), a client
MUST send only the absolute path and query components of the target
URI as the request-target.

@ondrej-tuhacek

This comment has been minimized.

Copy link
Contributor Author

@ondrej-tuhacek ondrej-tuhacek commented Apr 29, 2016

Yes, you are right. In the most common used scenario it should be the absolute path, but in section 5.3.2 there is also absolute form = absolute-URI for proxies (and maybe the chrome add-on acts as a proxy - but I'm still not sure). And furthermore there is this sentence:

To allow for transition to the absolute-form for all requests in some
future version of HTTP, a server MUST accept the absolute-form in
requests, even though HTTP/1.1 clients will only send them in
requests to proxies
.

So I would say that Nette should handle these requests as well. What do you think? Or do you think that I should rather sent a bugreport to that chrome add-on vendor?

@dg

This comment has been minimized.

Copy link
Member

@dg dg commented Apr 29, 2016

Can you send PR? Absolute part should be stripped before $urlFilters are used.

ondrej-tuhacek pushed a commit to ondrej-tuhacek/http that referenced this issue May 6, 2016
ondrej-tuhacek pushed a commit to ondrej-tuhacek/http that referenced this issue May 6, 2016
ondrej-tuhacek pushed a commit to ondrej-tuhacek/http that referenced this issue May 6, 2016
dg added a commit that referenced this issue Jun 17, 2016
@dg dg closed this Jun 25, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.