Skip to content

Shelf 1.1.1 breaking change: request body runtime type changed from Stream<List<int>> to Stream<Uint8List> #189

Closed
@nex3

Description

@nex3

Shelf 1.1.1 introduced a breaking change. By changing the runtime type of request bodies from Stream<List<int>> to Stream<Uint8List>, it caused it to no longer work with instances of StreamTransformer<List<int>, List<int>> such as dart:io's gzip.encoder and gzip.decoder. This is a breaking change and, if it was necessary, should have been released with a major version bump.

The following code works with shelf 1.1.0 and not with 1.1.1:

import 'dart:io';

import 'package:shelf/shelf.dart' as shelf;
import 'package:shelf/shelf_io.dart' as shelf_io;

Future<void> main() async {
  var server = await shelf_io.serve((request) async {
      await request.read().transform(gzip.decoder).drain();
      return shelf.Response.ok("");
    }, "localhost", 0);

  var client = HttpClient();
  var request = await client.post("localhost", server.port, "/");
  await request.close();
  client.close(force: true);
  server.close();
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-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