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
HttpResponse.outputStream.close should work even if HttpRequest.inputStream isn't drained #6984
Comments
Added Accepted label. |
Hey, Mads. Can you take a look at this? I spent a few minutes on it, but the bowels of dart:io are a mystery to me. If you want to repro this, just remove this from utils/tests/pub/pub.status: # TODO(nweiz): The "pub lish" tests fail mysteriously on OS X. See issue #6984. And then run: dart utils/tests/pub/pub_lish_test.dart It repros 100% of the time. |
cc @sgjesse. |
There is one clear issue here. The server request handler does not read the request body. That will cause the error you are seeing here. So for all of your request handlers you should add: request.inputStream.onData = request.inputStream.read(); instead of just response.close(); That will read and discard the data that you are not interested in. We might want to change dart:io so that the server can just close the response and ignore the data from the client. That will however give an error on the client when he cannot write his data. So for this test it seems best in any case to read the data in the server request handlers. There seems to be one other issue that I didn't get the time to get to the bottom of. 'cloud storage upload provides an error' ends up not being able to get the data from the request. It seems that it works fine if the call to write on the response output stream is removed. That doesn't make much sense and we haven't been able to repro with pure dart:io client and server code. |
If it's an error to close the request input stream without reading it, why doesn't that error appear on Linux? |
Probably timing. On Linux the data might make its way through the parser before the close in which case you will not get the error. Another reason why it probably shouldn't be an error on the server side to just discard the request if you want to ignore the data. |
I looked into the last remaining failure that I consistently have on my Mountain Lion Mac. It turns out that curl does not like that you write something to it as a response before it is done sending its data. This might be a Mac specific curl issue. I have attached two files that reproduces this for me consistently. Attachments: Set owner to @nex3. |
Thanks Nathan! Set owner to @sgjesse. |
Added Started label. |
Fixed in http://code.google.com/p/dart/source/detail?r=15782- Added Fixed label. |
This still seems to be occurring. I tried removing all the workarounds for it in r15804 and the Pub curl tests started flaking again on OS X: http://build.chromium.org/p/client.dart/builders/pub-mac/builds/1277/steps/pub%20tests%20failures/logs/stdio. Added Triaged label. |
This should now be fixed in http://code.google.com/p/dart/source/detail?r=15951. The problem with the fix from #12 (http://code.google.com/p/dart/source/detail?r=15782) was that it broke the protocol as the server closed the connection without including the Connection header with the close token. Added Fixed label. |
Removed Area-IO label. |
Full error output:
Unhandled exception:
HttpParserException: Connection closed before full request body was received
0 _HttpServer.listenOn.onConnection.<anonymous closure> (dart:io:3316:11)
1 _HttpConnection._onError._onError (dart:io:3235:12)
2 _HttpParser.streamDone.streamDone (dart:io:4607:12)
3 _SocketBase._multiplex (dart:io-patch:399:26)
4 _SocketBase._sendToEventHandler.<anonymous closure> (dart:io-patch:500:20)
5 _ReceivePortImpl._handleMessage (dart:isolate-patch:37:92)
The text was updated successfully, but these errors were encountered: