1 回答

TA貢獻2037條經驗 獲得超6個贊
您要求服務器發送壓縮的內容 (?req.Header.Add("Accept-Encoding", "gzip, deflate")
),這就是您得到的:gzip 響應,由響應標頭指示:Content-Encoding:[gzip]
。
刪除該標頭(不設置Accept-Encoding
請求標頭),您應該得到純 JSON 響應?;蛘咦约航獯a gzip 響應。
請注意,如果省略此標頭,默認傳輸仍會請求gzip
編碼,但也會透明地對其進行解碼。由于您明確請求它,因此不會發生透明的自動解碼。這在Transport.DisableCompression
現場有記錄:
// DisableCompression, if true, prevents the Transport from
// requesting compression with an "Accept-Encoding: gzip"
// request header when the Request contains no existing
// Accept-Encoding value. If the Transport requests gzip on
// its own and gets a gzipped response, it's transparently
// decoded in the Response.Body. However, if the user
// explicitly requested gzip it is not automatically
// uncompressed.
DisableCompression bool
- 1 回答
- 0 關注
- 218 瀏覽
添加回答
舉報