You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When responding to a HttpRequest with a 204 No Content status and no body, a body containing the number "0" is returned. This confuses some proxy servers (in case of keep alive). According to the spec:
import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as io;
void main() {
var handler = const shelf.Pipeline().addMiddleware(shelf.logRequests())
.addHandler(_echoRequest);
io.serve(handler, '0.0.0.0', 8080).then((server) {
print('Serving at http://${server.address.host}:${server.port}');
});
}
shelf.Response _echoRequest(shelf.Request request) {
return new shelf.Response(204);
}
Wireshark shows the malformed result:
We debugged the cause:
We don't supply a body to new shelf.Response(204) so it internally creates an empty array as body.
On Response generation (in dart:io) the "Transfer-Encoding" header defaults to "chunked" and thus the framework adds the 0 as initial chunk length of 0.
We managed to circumvent the problem by manually forcing the "Transfer-Encoding" header to "identity" for the 204 status results in a shelf middleware. However this issue should be fixed in order to be conformant to RFC 2616. But we are not sure if the issue is located in shelf or in dart:io.
Update: This is issue is also present for new Response.notModified(); (i.e. status code 304).
The text was updated successfully, but these errors were encountered:
This is really an issue in dart:io. It shouldn't force empty-bodied responses to be chunked, especially when they have a status code that disallows that. I've filed dart-lang/sdk#27660 to track that.
We can still work around this in shelf, though, so I'm keeping this issue open.
When responding to a HttpRequest with a 204 No Content status and no body, a body containing the number "0" is returned. This confuses some proxy servers (in case of keep alive). According to the spec:
We are using the following example code:
Wireshark shows the malformed result:
We debugged the cause:
new shelf.Response(204)
so it internally creates an empty array as body.We managed to circumvent the problem by manually forcing the "Transfer-Encoding" header to "identity" for the 204 status results in a shelf middleware. However this issue should be fixed in order to be conformant to RFC 2616. But we are not sure if the issue is located in shelf or in dart:io.
Update: This is issue is also present for
new Response.notModified();
(i.e. status code 304).The text was updated successfully, but these errors were encountered: