2.1.1
This commit is contained in:
parent
327b3996c1
commit
67303b82aa
6 changed files with 17 additions and 15 deletions
|
@ -1,3 +1,6 @@
|
||||||
|
# 2.1.1
|
||||||
|
* Update for framework@2.0.0-alpha.15
|
||||||
|
|
||||||
# 2.1.0
|
# 2.1.0
|
||||||
|
|
||||||
- Use `Uri` instead of archaic `host`, `port`, and `mapTo`. Also cleaner + safer + easier.
|
- Use `Uri` instead of archaic `host`, `port`, and `mapTo`. Also cleaner + safer + easier.
|
||||||
|
|
|
@ -32,5 +32,6 @@ Also, you can map requests to a root path on the remote server:
|
||||||
Proxy(client, baseUrl.replace(path: '/path'));
|
Proxy(client, baseUrl.replace(path: '/path'));
|
||||||
```
|
```
|
||||||
|
|
||||||
If your app's `keepRawRequestBuffers` is `true`, then request bodies will be forwarded
|
Request bodies will be forwarded as well, if they are not empty. This allows things like POST requests to function.
|
||||||
as well, if they are not empty. This allows things like POST requests to function.
|
|
||||||
|
For a request body to be forwarded, the body must not have already been parsed.
|
|
@ -105,8 +105,10 @@ class Proxy {
|
||||||
|
|
||||||
List<int> body;
|
List<int> body;
|
||||||
|
|
||||||
if (req.method != 'GET' && req.app.keepRawRequestBuffers == true) {
|
if (!req.hasParsedBody) {
|
||||||
body = (await req.parse()).originalBuffer;
|
body = await req.body
|
||||||
|
.fold<BytesBuilder>(new BytesBuilder(), (bb, buf) => bb..add(buf))
|
||||||
|
.then((bb) => bb.takeBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
var rq = new http.Request(req.method, uri);
|
var rq = new http.Request(req.method, uri);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
name: angel_proxy
|
name: angel_proxy
|
||||||
description: Angel middleware to forward requests to another server (i.e. pub serve).
|
description: Angel middleware to forward requests to another server (i.e. pub serve).
|
||||||
version: 2.1.0
|
version: 2.1.1
|
||||||
author: Tobe O <thosakwe@gmail.com>
|
author: Tobe O <thosakwe@gmail.com>
|
||||||
homepage: https://github.com/angel-dart/proxy
|
homepage: https://github.com/angel-dart/proxy
|
||||||
environment:
|
environment:
|
||||||
|
|
|
@ -15,7 +15,7 @@ main() {
|
||||||
String url;
|
String url;
|
||||||
|
|
||||||
setUp(() async {
|
setUp(() async {
|
||||||
app = new Angel()..keepRawRequestBuffers = true;
|
app = new Angel();
|
||||||
var appHttp = AngelHttp(app);
|
var appHttp = AngelHttp(app);
|
||||||
var httpClient = new http.IOClient();
|
var httpClient = new http.IOClient();
|
||||||
|
|
||||||
|
@ -55,14 +55,12 @@ main() {
|
||||||
});
|
});
|
||||||
|
|
||||||
await appHttp.startServer();
|
await appHttp.startServer();
|
||||||
|
url = appHttp.uri.toString();
|
||||||
server = appHttp.httpServer;
|
|
||||||
url = 'http://${server.address.address}:${server.port}';
|
|
||||||
});
|
});
|
||||||
|
|
||||||
tearDown(() async {
|
tearDown(() async {
|
||||||
await testServer.close(force: true);
|
await testServer?.close(force: true);
|
||||||
await server.close(force: true);
|
await server?.close(force: true);
|
||||||
app = null;
|
app = null;
|
||||||
url = null;
|
url = null;
|
||||||
});
|
});
|
||||||
|
|
|
@ -6,14 +6,12 @@ import 'package:angel_framework/http.dart';
|
||||||
import 'package:logging/logging.dart';
|
import 'package:logging/logging.dart';
|
||||||
|
|
||||||
Future<HttpServer> startTestServer() {
|
Future<HttpServer> startTestServer() {
|
||||||
final app = new Angel()
|
final app = new Angel();
|
||||||
..eagerParseRequestBodies = false
|
|
||||||
..keepRawRequestBuffers = true;
|
|
||||||
|
|
||||||
app.get('/hello', (req, res) => res.write('world'));
|
app.get('/hello', (req, res) => res.write('world'));
|
||||||
app.get('/foo/bar', (req, res) => res.write('baz'));
|
app.get('/foo/bar', (req, res) => res.write('baz'));
|
||||||
app.post('/body', (RequestContext req, res) async {
|
app.post('/body', (RequestContext req, res) async {
|
||||||
var body = await req.parseBody();
|
var body = await req.parseBody().then((_) => req.bodyAsMap);
|
||||||
app.logger.info('Body: $body');
|
app.logger.info('Body: $body');
|
||||||
return body;
|
return body;
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue