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

Ignoring Requests with Long URI #1697

Closed walterGil closed 10 months ago

walterGil commented 10 months ago

When I send a request where its URI has parameters' values causing it to be very long, the server endpoint's handler is not even called to function.

I placed a print statement at the beginning of the handler, and when I send a request with long URI, even this print statement is not triggered meaning that the handler is not called.

When I use shorter values for the parameters, it works.

Example : Handler :

// handlers "/hello"
func CallbackHandler(ctx *fasthttp.RequestCtx) {
        log.Println("/hello endpoint's handler is called")
    url := ctx.Request.URI()

    log.Printf("Callback URL: %s\n", url.String())

    // Extract the authorization code from the query parameters
    xVal := string(url.QueryArgs().Peek("X"))
    log.Println("X value is : ", xVal )
}

when I send a request where the length of 'X' parameter's value is short (say 128char) to the endpoint, the server processes the request and executes the log.Println statements and I can see their outputs. But, when I send a request where the length of 'X' parameter's value is long (say 1024char) to the endpoint, I do not get a valid response and I do not even see the log.Println statements' results.

What could be the problem here ? Does fasthttp imply any constraints or limitations to URI length ?

erikdubbelboer commented 10 months ago

You're going to have to increase Server.ReadBufferSize which limits how long a URI or headers can be.

walterGil commented 10 months ago

It worked. Thanks!