John
John

Reputation: 3115

Include %2F in golang http.NewRequest

When I try and include a "/" by using %2F in http.NewRequest, it converts it back into "/" when it calls url.Parse(). Is there any way to prevent this? I tried converting the percent to %25, but it still doesn't work.

You can see it here: http://play.golang.org/p/YOnktREbbf

Upvotes: 2

Views: 1618

Answers (1)

Stephen Weinberg
Stephen Weinberg

Reputation: 53418

This is a flaw in the design of the Go standard library. It has been acknowledged (issue 3659), but they have decided not to fix it for backwards compatibility reasons.

Although it isn't fun, the best way is to build a URL using opaque. You can find documentation here.

Upvotes: 5

Related Questions