Updated mock_request
This commit is contained in:
parent
16bf2ddfc6
commit
c2191a8c9c
4 changed files with 38 additions and 12 deletions
|
@ -1,5 +1,9 @@
|
|||
# Change Log
|
||||
|
||||
## 8.0.0
|
||||
|
||||
* Require Dart >= 3.0
|
||||
|
||||
## 7.0.1
|
||||
|
||||
* Fixed `BytesBuilder` warnings
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import 'dart:io';
|
||||
|
||||
class MockHttpHeaders extends HttpHeaders {
|
||||
class MockHttpHeaders implements HttpHeaders {
|
||||
final Map<String, List<String>> _data = {};
|
||||
final List<String> _noFolding = [];
|
||||
Uri? _host;
|
||||
//Uri? _host;
|
||||
String? _hostname;
|
||||
int _port = 80;
|
||||
|
||||
List<String> get doNotFold => List<String>.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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue