-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue with ClientSession.request('POST') method #1392
Comments
There is seem to be an infinite loop — your handler takes all request headers including |
well then how does post work with the normal localhost that i have here running? |
Sorry, my mistake. |
You mean the code is properly sending the POST request? and it is not just working for me?
|
Heh, re-read again and wound issue) |
this should work: async def handle(request):
url = request.rel_url
print(request.method)
kw = {"headers": request.headers}
if request.has_body:
kw["data"] = request.read()
async with aiohttp.ClientSession(loop=loop) as session:
with async_timeout.timeout(10):
async with session.request(request.method, url, **kw ... |
That worked, thank you!!
My test server, it was working without adding the data parameter. from flask import Flask
app = Flask(__name__)
@app.route("/", methods=['GET', 'POST'])
def home():
return "True"
if __name__ == "__main__":
app.run(port=8000, debug=True) That brings me to a suggestion, isn't it ok for a client to send a POST request without a body, shouldn't we have provisions for checking the data part implicitly? and ignoring it rather than showing an error, that we(as of people like me) hardly understand? |
@ja8zyjits please correct me if I misunderstood you. You are suggesting to raise an exception early if request type is |
@asvetlov |
Your local flask app works because it does not read POST data (flask, actually werkzeug, does it in lazy manner) |
I believe the question could be closed. |
Long story short
Iam trying to build a forwarder with aiohttp but iam unable to forward POST request.
Expected behaviour
if I send a post request to
http://httpbin/post
i normally get the full content.Actual behaviour
But when I use the forwarder to send request through the forwarder it waits a few seconds till timeout and it provides
ConnectionError: ('Connection aborted.', BadStatusLine("''",))
, later if I increase the timeout it provides a huge errorSteps to reproduce
I have hereby added my server code
Your environment
Its ubuntu 16.04 with a python3.5 virtual env
The text was updated successfully, but these errors were encountered: