Repository: VeryGoodOpenSource/dart_frog (dart)

Issue:
fix: bad state: The 'read' method can only be called once
**Description**

Seeing the following:

```sh
Asynchronous error
Bad state: The 'read' method can only be called once on a shelf.Request/shelf.Response object.

package:shelf/shelf_io.dart 143:11  handleRequest
```

When running the example and visiting `http://localhost:8080` in the browser.

Pull request description:
<!--
  Thanks for contributing!

  Provide a description of your changes below and a general summary in the title

  Please look at the following checklist to ensure that your PR can be accepted quickly:
-->

## Status

**READY**

## Description

<!--- Describe your changes in detail -->
- fix(dart_frog): support multiple routeNotFound.read calls (closes #27)

## Type of Change

<!--- Put an `x` in all the boxes that apply: -->

- [ ] ✨ New feature (non-breaking change which adds functionality)
- [X] 🛠️ Bug fix (non-breaking change which fixes an issue)
- [ ] ❌ Breaking change (fix or feature that would cause existing functionality to change)
- [ ] 🧹 Code refactor
- [ ] ✅ Build configuration change
- [ ] 📝 Documentation
- [ ] 🗑️ Chore

Patch:
diff --git a/packages/dart_frog/lib/src/router.dart b/packages/dart_frog/lib/src/router.dart
index 0241ff090..c1b106036 100644
--- a/packages/dart_frog/lib/src/router.dart
+++ b/packages/dart_frog/lib/src/router.dart
@@ -103,6 +103,9 @@ class _RouteNotFoundResponse extends Response {
   static const _message = 'Route not found';
   static final _messageBytes = utf8.encode(_message);
 
+  @override
+  shelf.Response get _response => super._response.change(body: _messageBytes);
+
   @override
   Stream<List<int>> bytes() => Stream<List<int>>.value(_messageBytes);
 


Test patch:
diff --git a/packages/dart_frog/test/src/serve_test.dart b/packages/dart_frog/test/src/serve_test.dart
index e4ec1bff8..dd80691ac 100644
--- a/packages/dart_frog/test/src/serve_test.dart
+++ b/packages/dart_frog/test/src/serve_test.dart
@@ -13,5 +13,17 @@ void main() {
       expect(response.statusCode, equals(HttpStatus.ok));
       await server.close();
     });
+
+    test('can return multiple 404s', () async {
+      final server = await serve(Router(), 'localhost', 3001);
+      final client = HttpClient();
+      var request = await client.getUrl(Uri.parse('http://localhost:3001'));
+      var response = await request.close();
+      expect(response.statusCode, equals(HttpStatus.notFound));
+      request = await client.getUrl(Uri.parse('http://localhost:3001'));
+      response = await request.close();
+      expect(response.statusCode, equals(HttpStatus.notFound));
+      await server.close();
+    });
   });
 }