From c2191a8c9cbe579c269fa419d878f7c11d120bde Mon Sep 17 00:00:00 2001 From: "thomashii@dukefirehawk.com" Date: Sun, 21 May 2023 08:53:53 +0800 Subject: [PATCH] Updated mock_request --- packages/mock_request/CHANGELOG.md | 4 +++ packages/mock_request/README.md | 3 +- packages/mock_request/lib/src/headers.dart | 33 ++++++++++++++++++---- packages/mock_request/pubspec.yaml | 10 +++---- 4 files changed, 38 insertions(+), 12 deletions(-) diff --git a/packages/mock_request/CHANGELOG.md b/packages/mock_request/CHANGELOG.md index eb326454..d5edb3e0 100644 --- a/packages/mock_request/CHANGELOG.md +++ b/packages/mock_request/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## 8.0.0 + +* Require Dart >= 3.0 + ## 7.0.1 * Fixed `BytesBuilder` warnings diff --git a/packages/mock_request/README.md b/packages/mock_request/README.md index e39d6019..52f2399e 100644 --- a/packages/mock_request/README.md +++ b/packages/mock_request/README.md @@ -7,8 +7,7 @@ **Forked from `mock_request` to support NNBD** -Manufacture dart:io HttpRequests, HttpResponses, HttpHeaders, etc. This makes it possible to test server-side Dart applications without -having to ever bind to a port. +Manufacture dart:io HttpRequests, HttpResponses, HttpHeaders, etc. This makes it possible to test server-side Dart applications without having to ever bind to a port. This package was originally designed to make testing [Angel3](https://angel3-framework.web.app/) applications smoother, but works with any Dart-based server. diff --git a/packages/mock_request/lib/src/headers.dart b/packages/mock_request/lib/src/headers.dart index d2ae30f9..07f015cc 100644 --- a/packages/mock_request/lib/src/headers.dart +++ b/packages/mock_request/lib/src/headers.dart @@ -1,9 +1,11 @@ import 'dart:io'; -class MockHttpHeaders extends HttpHeaders { +class MockHttpHeaders implements HttpHeaders { final Map> _data = {}; final List _noFolding = []; - Uri? _host; + //Uri? _host; + String? _hostname; + int _port = 80; List get doNotFold => List.unmodifiable(_noFolding); @@ -50,6 +52,8 @@ class MockHttpHeaders extends HttpHeaders { @override String? get host { + return _hostname; + /* if (_host != null) { return _host!.host; } else if (_data.containsKey(HttpHeaders.hostHeader)) { @@ -58,12 +62,12 @@ class MockHttpHeaders extends HttpHeaders { } else { return null; } + */ } @override - int? get port { - host; // Parse it - return _host?.port; + int get port { + return _port; } @override @@ -148,4 +152,23 @@ class MockHttpHeaders extends HttpHeaders { }); return b.toString(); } + + @override + bool chunkedTransferEncoding = false; + + @override + int contentLength = 0; + + @override + bool persistentConnection = true; + + @override + set host(String? host) { + _hostname = host; + } + + @override + set port(int? port) { + _port = port ?? 80; + } } diff --git a/packages/mock_request/pubspec.yaml b/packages/mock_request/pubspec.yaml index 1712a495..1159d069 100644 --- a/packages/mock_request/pubspec.yaml +++ b/packages/mock_request/pubspec.yaml @@ -1,17 +1,17 @@ name: angel3_mock_request -version: 7.0.1 +version: 8.0.0 description: Manufacture dart:io HttpRequests, HttpResponses, HttpHeaders, etc. homepage: https://angel3-framework.web.app/ repository: https://github.com/dukefirehawk/angel/tree/master/packages/mock_request environment: sdk: '>=3.0.0 <4.0.0' dependencies: - charcode: ^1.2.0 + charcode: ^1.3.0 dev_dependencies: #angel3_framework: ^7.0.0 - http: ^0.13.2 - test: ^1.21.0 - lints: ^2.0.0 + http: ^0.13.0 + test: ^1.24.0 + lints: ^2.1.0 # dependency_overrides: # angel3_framework: # path: ../framework