valyala/fasthttp

Request loses host information after calling RequestURI method

Open

#895 geöffnet am 28. Okt. 2020

Auf GitHub ansehen
 (3 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Go (1.755 Forks)batch import
help wanted

Repository-Metriken

Stars
 (21.741 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 1T 11h) (34 gemergte PRs in 30 T)

Beschreibung

Hello,

First, I would like to thank you for this awesome library.

I'm not sure if this is an issue but I noticed this. On the Request struct, il you call the RequestURI method, the Host method won't return anything after that.

It is really easy to reproduce :

package main

import (
	"github.com/valyala/fasthttp"
)

func main() {
	request := &fasthttp.Request{}
	request.SetRequestURI("http://example.com/test-1")

	println(string(request.Host()))
	println(string(request.RequestURI()))
	println(string(request.Host()))
}

This outpouts :

example.com
/test-1

As it should oupout in my opinion :

example.com
/test-1
example.com

For those who could experience the same issue, a workaround is to call instead :

request.URI().RequestURI()

But I would like to know if this is an issue or if this is the normal behavior. If this is the normal behavior, it should probably be documented :) Otherwise, I might be able to send you a PR to fix this if you want.

Thank you in advance for your help.

Contributor Guide