This commit is contained in:
thosakwe 2017-04-15 15:45:29 -04:00
parent e16ea22595
commit a24a75cb6a
5 changed files with 60 additions and 5 deletions

45
.gitignore vendored
View file

@ -26,3 +26,48 @@ doc/api/
# Don't commit pubspec lock file
# (Library packages only! Remove pattern if developing an application package)
pubspec.lock
### JetBrains template
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and Webstorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff:
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/dictionaries
# Sensitive or high-churn files:
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.xml
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
# Gradle:
.idea/**/gradle.xml
.idea/**/libraries
# Mongo Explorer plugin:
.idea/**/mongoSettings.xml
## File-based project format:
*.iws
## Plugin-specific files:
# IntelliJ
/out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

View file

@ -1,6 +1,6 @@
# cors
![1.0.0](https://img.shields.io/badge/version-1.0.0-brightgreen.svg)
![1.0.0+1](https://img.shields.io/badge/version-1.0.0+1-brightgreen.svg)
![build status](https://travis-ci.org/angel-dart/cors.svg)
Angel CORS middleware.

View file

@ -36,9 +36,9 @@ RequestMiddleware cors([CorsOptions options]) {
if (req.method == 'OPTIONS' && opts.allowedHeaders.isNotEmpty) {
res.headers['Access-Control-Allow-Headers'] =
opts.allowedHeaders.join(',');
} else if (req.method == 'OPTIONS') {
} else if (req.headers['Access-Control-Request-Headers'] != null) {
res.headers['Access-Control-Allow-Headers'] =
req.headers.value('Access-Control-Allow-Headers');
req.headers.value('Access-Control-Request-Headers');
}
// Access-Control-Expose-Headers

View file

@ -4,7 +4,7 @@ environment:
sdk: ">=1.19.0"
homepage: "https://github.com/angel-dart/cors.git"
name: "angel_cors"
version: 1.0.0
version: 1.0.0+1
dependencies:
angel_framework: "^1.0.0-dev"
dev_dependencies:

View file

@ -18,7 +18,7 @@ main() {
return false;
})
..all('*', () {
throw new AngelHttpException.NotFound();
throw new AngelHttpException.notFound();
});
server = await app.startServer();
@ -40,4 +40,14 @@ main() {
print('Headers: ${response.headers}');
expect(response.headers['access-control-allow-origin'], equals('*'));
});
test('mirror headers', () async {
final response = await client.post(url, headers: {
'access-control-request-headers': 'foo'
});
expect(response.statusCode, equals(200));
print('Response: ${response.body}');
print('Headers: ${response.headers}');
expect(response.headers['access-control-allow-headers'], equals('foo'));
});
}