【发布时间】:2015-10-01 08:24:17
【问题描述】:
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。 有什么想法吗?
【问题讨论】:
-
你在这里尝试过一些编程吗?还是您希望找到一些带有神奇
func DumpResponse(filename string) error和func Loadesponse(filename string) (*http.Response, error)的包? -
@Volker 我在征求意见,而不是现成的包。
-
将
resp转换为byte数组并写入文件。 stackoverflow.com/questions/26372227/… -
不要忘记标题。