通过代理连接发送带有 headers 的 aiohttp post 请求

send aiohttp post request with headers through proxy connection

我现在拥有的(Python3.4):

r = yield from aiohttp.request('post', URL, params=None, data=values, headers=headers)

documentation 中的内容:

conn = aiohttp.ProxyConnector(proxy="http://some.proxy.com")
r = await aiohttp.get('http://python.org', connector=conn)

那么,我应该如何通过与 aiohttp 的代理连接使用 headers 发送 post 请求?

谢谢。

connector = aiohttp.ProxyConnector(proxy="http://some.proxy.com")
session = aiohttp.ClientSession(connector=connector)
async with session.post("http://example.com/post", data=b"binary data") as resp:
    print(resp.status)

session.close()

你可以使用这个:

import aiohttp

conn = aiohttp.ProxyConnector(proxy="http://some.proxy.com")

r = await aiohttp.post('http://python.org', connector=conn, data=b"hello", headers={})

import aiohttp

from aiohttp import request

conn = aiohttp.ProxyConnector(proxy="http://some.proxy.com")

r = await request('post','http://python.org', connector=conn, data=b"hello", headers={})