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

renderHeaders assumes rawPathInfo is an absolute path #32

Open
jfischoff opened this issue Mar 29, 2019 · 5 comments
Open

renderHeaders assumes rawPathInfo is an absolute path #32

jfischoff opened this issue Mar 29, 2019 · 5 comments

Comments

@jfischoff
Copy link

When renderHeaders creates a request it assumes rawPathInfo is a absolute path. If it is a relative path the Request-Uri part of the HTTP request will be invalid.

I don't think wai makes any guarantees about the rawPathInfo so I don't think http-reverse-proxy should either.

I think renderHeaders should use the logic in http-client http://hackage.haskell.org/package/http-client-0.5.14/docs/src/Network.HTTP.Client.Request.html#local-6989586621679091539

Here is the logic I am referring to:

            <> (case S8.uncons $ path req of
                    Just ('/', _) -> fromByteString $ path req
                    _ -> fromChar '/' <> fromByteString (path req))
@snoyberg
Copy link
Member

How can rawPathInfo not be an absolute path? It's taken from the HTTP request header.

@jfischoff
Copy link
Author

jfischoff commented Mar 31, 2019 via email

@snoyberg
Copy link
Member

snoyberg commented Apr 5, 2019

Right, I get that, I'm just not sure what the case is where that will actually happen. Anyway, if you'd like to PR a fix, I'll be happy to review.

@jfischoff
Copy link
Author

The use case for use is a proxy that rewrites the path. The issue is no where did we see that the path must be absolute and it works fine if it regular HTTP and not websockets. I could see changing the Wai doc to say it must be absolute as an alternative. 🤷‍♂️

@jfischoff
Copy link
Author

I can also one day add a PR assuming inspiration hits me :p

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants