Patch
This commit is contained in:
parent
81a4081441
commit
84f84f9b3b
2 changed files with 4 additions and 3 deletions
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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 <thosakwe@gmail.com>
|
||||
homepage: https://github.com/angel-dart/user_agent
|
||||
|
|
Loading…
Reference in a new issue