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
|
# Change Log
|
||||||
|
|
||||||
|
## 8.0.0
|
||||||
|
|
||||||
|
* Require Dart >= 3.0
|
||||||
|
|
||||||
## 7.0.1
|
## 7.0.1
|
||||||
|
|
||||||
* Fixed `BytesBuilder` warnings
|
* Fixed `BytesBuilder` warnings
|
||||||
|
|
|
@ -7,8 +7,7 @@
|
||||||
|
|
||||||
**Forked from `mock_request` to support NNBD**
|
**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
|
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.
|
||||||
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.
|
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';
|
import 'dart:io';
|
||||||
|
|
||||||
class MockHttpHeaders extends HttpHeaders {
|
class MockHttpHeaders implements HttpHeaders {
|
||||||
final Map<String, List<String>> _data = {};
|
final Map<String, List<String>> _data = {};
|
||||||
final List<String> _noFolding = [];
|
final List<String> _noFolding = [];
|
||||||
Uri? _host;
|
//Uri? _host;
|
||||||
|
String? _hostname;
|
||||||
|
int _port = 80;
|
||||||
|
|
||||||
List<String> get doNotFold => List<String>.unmodifiable(_noFolding);
|
List<String> get doNotFold => List<String>.unmodifiable(_noFolding);
|
||||||
|
|
||||||
|
@ -50,6 +52,8 @@ class MockHttpHeaders extends HttpHeaders {
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String? get host {
|
String? get host {
|
||||||
|
return _hostname;
|
||||||
|
/*
|
||||||
if (_host != null) {
|
if (_host != null) {
|
||||||
return _host!.host;
|
return _host!.host;
|
||||||
} else if (_data.containsKey(HttpHeaders.hostHeader)) {
|
} else if (_data.containsKey(HttpHeaders.hostHeader)) {
|
||||||
|
@ -58,12 +62,12 @@ class MockHttpHeaders extends HttpHeaders {
|
||||||
} else {
|
} else {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
int? get port {
|
int get port {
|
||||||
host; // Parse it
|
return _port;
|
||||||
return _host?.port;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
|
@ -148,4 +152,23 @@ class MockHttpHeaders extends HttpHeaders {
|
||||||
});
|
});
|
||||||
return b.toString();
|
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
|
name: angel3_mock_request
|
||||||
version: 7.0.1
|
version: 8.0.0
|
||||||
description: Manufacture dart:io HttpRequests, HttpResponses, HttpHeaders, etc.
|
description: Manufacture dart:io HttpRequests, HttpResponses, HttpHeaders, etc.
|
||||||
homepage: https://angel3-framework.web.app/
|
homepage: https://angel3-framework.web.app/
|
||||||
repository: https://github.com/dukefirehawk/angel/tree/master/packages/mock_request
|
repository: https://github.com/dukefirehawk/angel/tree/master/packages/mock_request
|
||||||
environment:
|
environment:
|
||||||
sdk: '>=3.0.0 <4.0.0'
|
sdk: '>=3.0.0 <4.0.0'
|
||||||
dependencies:
|
dependencies:
|
||||||
charcode: ^1.2.0
|
charcode: ^1.3.0
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
#angel3_framework: ^7.0.0
|
#angel3_framework: ^7.0.0
|
||||||
http: ^0.13.2
|
http: ^0.13.0
|
||||||
test: ^1.21.0
|
test: ^1.24.0
|
||||||
lints: ^2.0.0
|
lints: ^2.1.0
|
||||||
# dependency_overrides:
|
# dependency_overrides:
|
||||||
# angel3_framework:
|
# angel3_framework:
|
||||||
# path: ../framework
|
# path: ../framework
|
||||||
|
|
Loading…
Reference in a new issue