valyala / fasthttp

Fast HTTP package for Go. Tuned for high performance. Zero memory allocations in hot paths. Up to 10x faster than net/http
MIT License
21.91k stars 1.76k forks source link

Handle request URI containing query parameters but no path. #1661

Closed skidder closed 9 months ago

skidder commented 1 year ago

Fixes #1659

When returning a request URI, check whether it begins with a query (i.e. ?), in which case we should apply a default path of /). This is required to conform to the HTTP 1.1 specification.

"If the target URI's path component is empty, the client MUST send "/" as the path within the origin-form of request-target."

skidder commented 12 months ago

I'm sorry but I don't think SetRequestURI and SetRequestURIBytes need to be fixed. Users have control over these and can append the / themselves.

Ah, I see. I'm only using the FastHTTP client, not the FastHTTP server. My expectation was that the FastHTTP client would handle URLs using this format since that's the behavior of the built-in net/http client. I've been able to implement a work-around in my application, but thought this might be worth covering in FastHTTP.

erikdubbelboer commented 12 months ago

I'm a little bit afraid to make backwards breaking changes like this. I'll leave this pull request open for now and see if anyone else runs into this.