You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have managed to get the reproduction step. It's mainly caused by SetScheme
func TestHostURLForGH318(t *testing.T) {
// Notice that I'm using both SetScheme and SetHostURL in order to reproduce this issue.
client := resty.New()
client.SetScheme("https").SetHostURL("httpbin.org")
fmt.Println("with leading `/`")
resp, err := client.R().Post("/post")
fmt.Println("Error:", err)
fmt.Println("Response:", resp)
fmt.Println("\nwithout leading `/`")
resp, err = client.R().Post("post")
fmt.Println("Error:", err)
fmt.Println("Response:", resp)
fmt.Println()
fmt.Println("with leading `/` on request")
fmt.Println("with trailing `/` on host url")
client.SetHostURL("https://httpbin.org/")
resp, err = client.R().Post("/post")
fmt.Println("Error:", err)
fmt.Println("Response:", resp)
}
Error from first and second request:
with leading `/`
Error: Post "https://httpbin.org%2Fpost/httpbin.org/post": dial tcp: lookup httpbin.org/post: no such host
Response:
without leading `/`
Error: Post "https://httpbin.org%2Fpost/httpbin.org/post": dial tcp: lookup httpbin.org/post: no such host
Response:
The text was updated successfully, but these errors were encountered:
Resty should somehow do the right thing here (or at least not do the wrong thing), but the API assumes that the SetHostURL parameter will contain the scheme. Don't mix SetScheme and SetHostURL.
See #318
I have managed to get the reproduction step. It's mainly caused by SetScheme
Error from first and second request:
The text was updated successfully, but these errors were encountered: