duandao7704 2016-09-04 06:38
浏览 224
已采纳

为什么RoundTrip不应该修改请求?

Why shouldn't RoundTrip modify the request ?

https://golang.org/src/net/http/client.go#L103

What happens if http.Request gets modified by a RoundTripper (http.Transport for instance)?

  • 写回答

1条回答 默认 最新

  • doulu1968 2016-09-26 15:27
    关注

    The awnser is stated in the interface comment https://golang.org/src/net/http/client.go#L89

    A RoundTripper must be safe for concurrent use by multiple goroutines.
    

    If a server gets a request, and starts multiple goroutines, it must be ensured that all requests work on the same input. If a RoundTripper changes the request, it can make already collected data useless (which may not even be noticed)

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 蓝牙耳机怎么查看日志
  • ¥15 R语言 拟时序分析降维图如何减少分支
  • ¥15 Fluent齿轮搅油
  • ¥15 八爪鱼爬数据为什么自己停了
  • ¥15 交替优化波束形成和ris反射角使保密速率最大化
  • ¥15 树莓派与pix飞控通信
  • ¥15 自动转发微信群信息到另外一个微信群
  • ¥15 outlook无法配置成功
  • ¥30 这是哪个作者做的宝宝起名网站
  • ¥60 版本过低apk如何修改可以兼容新的安卓系统