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

标签 http go

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

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

如果 http.Request 被 RoundTripper 修改(例如 http.Transport),会发生什么?

最佳答案

awnser在接口(interface)注释https://golang.org/src/net/http/client.go#L89中有说明

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

如果服务器收到请求并启动多个 goroutine,则必须确保所有请求都在同一输入上工作。如果 RoundTripper 更改请求,它可能会使已收集的数据变得无用(甚至可能不会被注意到)

关于http - 为什么 RoundTrip 不应该修改请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39314219/

相关文章:

java - ReSTLet HTTP 到 HTTPS(非默认端口)重定向

rest - 在 Allow : header for overloaded POST 中宣传什么

http - HAProxy 将 http 重定向到 https (ssl)

go - Mux 处理程序未收到从 curl post 传递的所有查询参数

go - 将 google Inject 与提供者函数的多重返回连线

java - 将字符“替换为无文本然后将值转换为 Float 时出现空指针异常

java - IllegalStateException : Already connected with HttpURLConnection. setFixedLengthStreamingMode

go - 如何在Go中打开进程并正确记录stdin和stdout?

go - 如何在GoLang中解析url中的多个参数?

go - undefined <type float32 has no field or method sum> 错误。如何解决?