Skip to content

Add a RequestPath() function #106

Discussion options

You must be logged in to vote

.Host sets the host on the URL, which in turns gets passed into the Request. Is there a reason you need the host to be only on the request and not the URL? I know there's an option for that in curl, but I've only ever needed it because I was testing whether a server would work even if it got a bad host in.

I think the workaround for now would be to make a custom transport like

func WithHost(rt requests.Transport, s string) requests.Transport {
	return requests.RoundTripFunc(func(req *http.Request) (res *http.Response, err error) {
		rt = cmp.Or(rt, http.DefaultTransport)
		req2 := *req
		req2.Host = s
		return rt.RoundTrip(&req2)
	})
}

Replies: 1 comment 4 replies

Comment options

You must be logged in to vote
4 replies
@earthboundkid
Comment options

@earthboundkid
Comment options

@creativecreature
Comment options

@creativecreature
Comment options

Answer selected by earthboundkid
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
None yet
2 participants