Fixed issue 83

This commit is contained in:
thomashii@dukefirehawk.com 2022-10-06 08:00:03 +08:00
parent b9b0e49fd0
commit 8c48be9f9f
10 changed files with 27 additions and 14 deletions

View file

@ -1,5 +1,9 @@
# Change Log
## 7.0.3
* Fixed issue #83. Allow Http request to return null headers instead of throwing an exception.
## 7.0.2
* Added performance benchmark to README

View file

@ -28,8 +28,8 @@ class HttpRequestContext extends RequestContext<HttpRequest?> {
}
@override
HttpHeaders get headers {
return rawRequest!.headers;
HttpHeaders? get headers {
return rawRequest?.headers;
}
@override

View file

@ -1,5 +1,5 @@
name: angel3_framework
version: 7.0.2
version: 7.0.3
description: A high-powered HTTP server extensible framework with dependency injection, routing and much more.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/framework

View file

@ -1,5 +1,9 @@
# Change Log
## 7.0.1
* Updated `server` header to `angel3`
## 7.0.0
* Require Dart >= 2.17

View file

@ -93,7 +93,7 @@ class HotReloader {
response.statusCode = HttpStatus.badGateway;
response.headers
..contentType = ContentType.html
..set(HttpHeaders.serverHeader, 'angel_hot');
..set(HttpHeaders.serverHeader, 'angel3');
if (request.headers
.value(HttpHeaders.acceptEncodingHeader)
@ -163,11 +163,11 @@ class HotReloader {
'You have instantiated a HotReloader without providing any filesystem paths to watch.');
}
bool _sw(String s) {
bool sw(String s) {
return Platform.executableArguments.any((ss) => ss.startsWith(s));
}
if (!_sw('--observe') && !_sw('--enable-vm-service')) {
if (!sw('--observe') && !sw('--enable-vm-service')) {
_logWarning(
'You have instantiated a HotReloader without passing `--enable-vm-service` or `--observe` to the Dart VM. Hot reloading will be disabled.');
isHot = false;
@ -315,7 +315,7 @@ class HotReloader {
}
Future<void> _listenToStat(String path) async {
Future _listen() async {
Future listen() async {
try {
var stat = await FileStat.stat(path);
if (stat.type == FileSystemEntityType.link) {
@ -345,7 +345,7 @@ class HotReloader {
}
}
var r = await _listen();
var r = await listen();
if (r == null) {
_logWarning(

View file

@ -1,5 +1,5 @@
name: angel3_hot
version: 7.0.0
version: 7.0.1
description: Supports hot reloading/hot code push of Angel3 servers on file changes.
homepage: https://angel3-framework.web.app/
repository: https://github.com/dukefirehawk/angel/tree/master/packages/hot

View file

@ -11,7 +11,7 @@ void main(List<String> args) async {
var http = AngelHttp(app);
var ws = AngelWebSocket(app, sendErrors: !app.environment.isProduction);
var fs = const LocalFileSystem();
app.logger = Logger('angel_websocket');
app.logger = Logger('angel3_websocket');
// This is a plug-in. It hooks all your services,
// to automatically broadcast events.
@ -25,6 +25,9 @@ void main(List<String> args) async {
app.fallback((req, res) => throw AngelHttpException.notFound());
ws.onConnection.listen((socket) {
var h = socket.request.headers;
print('WebSocket onConnection $h');
socket.onData.listen((x) {
socket.send('pong', x);
});

View file

@ -157,7 +157,7 @@ class AngelWebSocket {
var event = await transformEvent(e);
event.eventName = '$path::${event.eventName}';
dynamic _filter(WebSocketContext socket) {
dynamic filter(WebSocketContext socket) {
if (e.service.configuration.containsKey('ws:filter')) {
return e.service.configuration['ws:filter'](e, socket);
} else if (e.params.containsKey('ws:filter')) {
@ -167,7 +167,7 @@ class AngelWebSocket {
}
}
await batchEvent(event, filter: _filter);
await batchEvent(event, filter: filter);
};
}

View file

@ -25,8 +25,8 @@ dev_dependencies:
# dependency_overrides:
# angel3_container:
# path: ../container/angel_container
# angel3_framework:
# path: ../framework
# angel3_framework:
# path: ../framework
# angel3_http_exception:
# path: ../http_exception
# angel3_model:

View file

@ -26,6 +26,8 @@ void main() {
if (username == 'foo' && password == 'bar') {
return user;
}
return {};
},
);