Skip to content

HttpServer doesn't respect chunked transfer coding when other codings are present #27885

Open
@nex3

Description

If I write:

import 'dart:convert';
import 'dart:io';

main() async {
  var server = await HttpServer.bind('127.0.0.1', 8080);
  await for (var request in server) {
    request.response.headers.set('transfer-encoding', 'gzip chunked');
    request.response.add(GZIP.encoder.convert(UTF8.encode('foo')));
    request.response.close();
  }
}

And I make a GET / request, I get back:

HTTP/1.1 200 OK
content-type: text/plain; charset=utf-8
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
transfer-encoding: gzip chunked
x-content-type-options: nosniff

K��!es�

I'd expect:

HTTP/1.1 200 OK
content-type: text/plain; charset=utf-8
x-frame-options: SAMEORIGIN
x-xss-protection: 1; mode=block
transfer-encoding: gzip chunked
x-content-type-options: nosniff

17
K��!es�
0

Normally the server will apply the chunked transfer encoding based on the Transfer-Encoding header, but in this case it's not doing so. And, since there's no explicit way to tell the server whether or not to apply a chunked encoding, there's not really a good workaround here other than manually re-implementing chunked encoding and specifically only applying that implementation if there are multiple encodings specified.

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onarea-vmUse area-vm for VM related issues, including code coverage, and the AOT and JIT backends.library-iotype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions