我想發送分塊的HTTP正文來測試我自己的HTTP服務器。 所以我寫了這條巨蟒代碼:如何強制http.client在python中發送chunked-encoding HTTP主體?
import http.client
body = 'Hello World!' * 80
conn = http.client.HTTPConnection("some.domain.com")
url = "/some_path?arg=true_arg"
conn.request("POST", url, body, {"Transfer-Encoding":"chunked"})
resp = conn.getresponse()
print(resp.status, resp.reason)
我希望HTTP請求的身體transferrd分塊, 但我捕獲網絡包使用Wireshark,HTTP請求的身體不轉讓分塊。
如何通過http.client庫在python中傳輸塊狀體?
對我的作品蒙山只有一個分離器更好的爲chunk_data(即內第二行:滯留+ =「%S \ r \ n」%(數據[我* chunk_size:(i + 1)* chunk_size])) – 2012-12-19 17:14:55