req, err := http.NewRequest("GET", "http://example.com", nil)
req.AddCookie(&http.Cookie{Name: "c", Value: "ccc"})
resp, err := client.Do(req)
我需要将resp缓存到磁盘上,并在从缓存中恢复后保持其类型为http.Response。有什么想法吗?
或者使用https://github.com/lox/httpcache。这是一个符合 RFC7234 标准的 golang http.Handler,用于缓存 HTTP 响应。
func DumpResponse(filename string) error
和func Loadesponse(filename string) (*http.Response, error)
函数吗? - Volkerresp
转换为byte
数组并写入文件。https://dev59.com/E4Tba4cB1Zd3GeqP30cU - Aruna Herath