-
Notifications
You must be signed in to change notification settings - Fork 712
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How can I set a HOST for request? #154
Comments
@mail2fish This is known issue in the Go http client golang/go/issues/7682 however there is a workaround. Use For example: resty.SetPreRequestHook(func(c *resty.Client, r *resty.Request) error {
r.RawRequest.Host = "www.example.com"
return nil
}) Can you try and please let me know? |
Or via classic approach is using |
@jeevatkm thanks for your answer. That's worked. But I think that is convenient for developers if there is a shortcut for this matter. In my situation, I developed in the localhost, and don't want to change my hosts file because I have to access that host by a browser. Thanks again, That hook have solved my problem. |
@mail2fish thanks for confirming, I have created an issue to add built-in support for |
There is a vhost server IP. We like to access it with a host name which like www.example.com.
Usually we can set a Host header in request, but it didn't work for golang http request.
So could you add a special method for the matter?
The text was updated successfully, but these errors were encountered: