CrowdHailer / raxx

Interface for HTTP webservers, frameworks and clients
https://hexdocs.pm/raxx
Apache License 2.0
403 stars 29 forks source link

Provide unparsed URL #97

Closed varnerac closed 6 years ago

varnerac commented 6 years ago

Currently, we get the path back as a list of tokens in the path field of Raxx.Request.

Some applications forbid or require a trailing slash in a URL (e.g. TAXII 2.0 requires it). Without access to the unparsed path, I can't verify if a request is valid.

I'd like access to the unparsed URL in Raxx.Request

CrowdHailer commented 6 years ago

Would getting the path with empty segments be sufficient. i.e. ["foo", ""] and ["foo"] for "foo/" vs `"foo". I've though about ace building requests like that then have a compact middleware of similar in the Raxx project

varnerac commented 6 years ago

It would be sufficient, but it doesn't seem "natural". I may want to know if the last character is /. In that case, looking for "" at the end of the path tokens seems like an odd way to check it. It also seems unnatural to folks who are already matching on path tokens to have to handle the "". I'd prefer a plain, string path, or even entire URL.

CrowdHailer commented 6 years ago

Fair enough. I'm hesitant to duplicate data in the request struct (i.e. having a segments and string path) however I do think it should be possible to access the raw path. Am open to ideas about how to expose it.

CharlesOkwuagwu commented 6 years ago

@CrowdHailer Having the raw path is valuable in the request, sometimes we have to reconstruct that ourselves anyway.

Also, it solves the issues of foo/bar or foo/bar/ easily

CrowdHailer commented 6 years ago

Check sections 5 and 6 here on path normalisation https://tools.ietf.org/html/rfc3986#section-5

varnerac commented 6 years ago

Do you want to add path normalization in the path segments middleware?

CrowdHailer commented 6 years ago

Closed by #106