Make lazy parsing the default
This commit is contained in:
parent
d3a3d93796
commit
2cb0797da5
8 changed files with 9 additions and 11 deletions
|
@ -21,4 +21,6 @@ respectively.
|
|||
* `RequestContext.io` and `ResponseContext.io` are now permanently
|
||||
gone.
|
||||
* `HttpRequestContextImpl` and `HttpResponseContextImpl` were renamed to
|
||||
`HttpRequestContext` and `HttpResponseContext`.
|
||||
`HttpRequestContext` and `HttpResponseContext`.
|
||||
* Lazy-parsing request bodies is now the default; `Angel.lazyParseBodies` was replaced
|
||||
with `Angel.eagerParseRequestBodies`.
|
|
@ -6,7 +6,6 @@ import 'package:logging/logging.dart';
|
|||
|
||||
main() async {
|
||||
var app = new Angel(reflector: MirrorsReflector())
|
||||
..lazyParseBodies = true
|
||||
..logger = (new Logger('angel')..onRecord.listen(print))
|
||||
..encoders.addAll({'gzip': gzip.encoder});
|
||||
|
||||
|
|
|
@ -40,7 +40,6 @@ serverMain(_) async {
|
|||
|
||||
// Performance tuning
|
||||
app
|
||||
..lazyParseBodies = true
|
||||
..serializer = json.encode;
|
||||
|
||||
app.errorHandler = (e, req, res) {
|
||||
|
|
|
@ -125,10 +125,10 @@ class Angel extends Routable {
|
|||
/// for you.
|
||||
final Map configuration = {};
|
||||
|
||||
/// When set to true, the request body will not be parsed
|
||||
/// automatically. You can call `req.parse()` manually,
|
||||
/// When set to `true` (default: `false`), the request body will be parsed
|
||||
/// automatically; otherwise, you must call [RequestContext].parseBody() manually,
|
||||
/// or use `lazyBody()`.
|
||||
bool lazyParseBodies = false;
|
||||
bool eagerParseRequestBodies = false;
|
||||
|
||||
/// When set to `true`, the original body bytes will be stored
|
||||
/// on requests. `false` by default.
|
||||
|
|
|
@ -121,7 +121,7 @@ class HttpRequestContext extends RequestContext<HttpRequest> {
|
|||
ctx._path = path;
|
||||
ctx._io = request;
|
||||
|
||||
if (app.lazyParseBodies != true) {
|
||||
if (app.eagerParseRequestBodies == true) {
|
||||
return ctx.parse().then((_) => ctx);
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,7 @@ main() async {
|
|||
}
|
||||
|
||||
void start(int id) {
|
||||
var app = new Angel(reflector: MirrorsReflector())..lazyParseBodies = true;
|
||||
var app = new Angel(reflector: MirrorsReflector());
|
||||
var http = new AngelHttp.custom(app, startShared, useZone: false);
|
||||
|
||||
app.get('/', (ResponseContext res) => res.write('Hello, world!'));
|
||||
|
|
|
@ -28,7 +28,7 @@ parameterMetaTests() {
|
|||
AngelHttp http;
|
||||
|
||||
setUp(() {
|
||||
app = new Angel(reflector: MirrorsReflector())..lazyParseBodies = true;
|
||||
app = new Angel(reflector: MirrorsReflector());
|
||||
http = new AngelHttp(app);
|
||||
|
||||
app.get('/cookie', (@CookieValue('token') String jwt) {
|
||||
|
|
|
@ -32,9 +32,7 @@ main() {
|
|||
nested = new Angel(reflector: MirrorsReflector());
|
||||
todos = new Angel(reflector: MirrorsReflector());
|
||||
|
||||
// Lazy-parse in production
|
||||
[app, nested, todos].forEach((Angel app) {
|
||||
app.lazyParseBodies = app.isProduction;
|
||||
app.logger = new Logger('routing_test')
|
||||
..onRecord.listen((rec) {
|
||||
if (rec.error != null) {
|
||||
|
|
Loading…
Reference in a new issue