dpps0715
2015-02-15 00:11
浏览 271
已采纳

在golang http.NewRequest中包含%2F

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

图片转代码服务由CSDN问答提供 功能建议

当我尝试通过在http.NewRequest中使用%2F来添加“ /”时,它会将其转换回“ /”,当它调用url.Parse()时。 有什么办法可以防止这种情况? 我尝试将百分比转换为%25,但仍然无法使用。

您可以在此处查看: http://play.golang.org/p/YOnktREbbf

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dpzyd8865 2015-02-15 06:16
    已采纳

    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.

    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题