diff --git a/lib/angel_user_agent.dart b/lib/angel_user_agent.dart index a2964ba8..8a54dfd6 100644 --- a/lib/angel_user_agent.dart +++ b/lib/angel_user_agent.dart @@ -9,7 +9,7 @@ RequestMiddleware parseUserAgent({bool strict: true}) { return (RequestContext req, res) async { var agentString = req.headers.value('user-agent'); - if (agentString == null) { + if (agentString == null && strict) { throw new AngelHttpException.badRequest( message: 'User-Agent header is required.'); } else if (agentString != null) { @@ -17,7 +17,8 @@ RequestMiddleware parseUserAgent({bool strict: true}) { req.headers.forEach((k, v) => map[k] = v); req.inject(UserAgent, new UserAgent(agentString, headers: map)); - } + } else + req.inject(UserAgent, null); return true; }; diff --git a/pubspec.yaml b/pubspec.yaml index b3bd6641..04df76f2 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: angel_user_agent -version: 1.0.0 +version: 1.0.1 description: Middleware to inject a User Agent object into requests. author: Tobe O homepage: https://github.com/angel-dart/user_agent