在请求模块python中使用http标头

时间:2018-03-17 12:06:05

标签: python-3.x http python-requests

是否可以通过在其中一个标头中指定源IP地址的值来指定请求的源地址? From字段可以用于此目的吗?

到目前为止我的代码:

response = requests.get('http://server_ip/file_name',headers={"From":"source_ip"}, stream=True)  
handle = open('/home/client1/test/try101.txt', "wb")
for chunk in response.iter_content(chunk_size=512):
    if chunk:  # filter out keep-alive new chunks
        handle.write(chunk)

From字段似乎没有为此目的而工作?还有另一个领域用于此目的吗?或另一种替代方案来实现这一任务?

0 个答案:

没有答案
相关问题