+1
This commit is contained in:
parent
e16ea22595
commit
a24a75cb6a
5 changed files with 60 additions and 5 deletions
45
.gitignore
vendored
45
.gitignore
vendored
|
@ -26,3 +26,48 @@ doc/api/
|
||||||
# Don't commit pubspec lock file
|
# Don't commit pubspec lock file
|
||||||
# (Library packages only! Remove pattern if developing an application package)
|
# (Library packages only! Remove pattern if developing an application package)
|
||||||
pubspec.lock
|
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
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
# cors
|
# 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)
|
![build status](https://travis-ci.org/angel-dart/cors.svg)
|
||||||
|
|
||||||
Angel CORS middleware.
|
Angel CORS middleware.
|
||||||
|
|
|
@ -36,9 +36,9 @@ RequestMiddleware cors([CorsOptions options]) {
|
||||||
if (req.method == 'OPTIONS' && opts.allowedHeaders.isNotEmpty) {
|
if (req.method == 'OPTIONS' && opts.allowedHeaders.isNotEmpty) {
|
||||||
res.headers['Access-Control-Allow-Headers'] =
|
res.headers['Access-Control-Allow-Headers'] =
|
||||||
opts.allowedHeaders.join(',');
|
opts.allowedHeaders.join(',');
|
||||||
} else if (req.method == 'OPTIONS') {
|
} else if (req.headers['Access-Control-Request-Headers'] != null) {
|
||||||
res.headers['Access-Control-Allow-Headers'] =
|
res.headers['Access-Control-Allow-Headers'] =
|
||||||
req.headers.value('Access-Control-Allow-Headers');
|
req.headers.value('Access-Control-Request-Headers');
|
||||||
}
|
}
|
||||||
|
|
||||||
// Access-Control-Expose-Headers
|
// Access-Control-Expose-Headers
|
||||||
|
|
|
@ -4,7 +4,7 @@ environment:
|
||||||
sdk: ">=1.19.0"
|
sdk: ">=1.19.0"
|
||||||
homepage: "https://github.com/angel-dart/cors.git"
|
homepage: "https://github.com/angel-dart/cors.git"
|
||||||
name: "angel_cors"
|
name: "angel_cors"
|
||||||
version: 1.0.0
|
version: 1.0.0+1
|
||||||
dependencies:
|
dependencies:
|
||||||
angel_framework: "^1.0.0-dev"
|
angel_framework: "^1.0.0-dev"
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
|
|
|
@ -18,7 +18,7 @@ main() {
|
||||||
return false;
|
return false;
|
||||||
})
|
})
|
||||||
..all('*', () {
|
..all('*', () {
|
||||||
throw new AngelHttpException.NotFound();
|
throw new AngelHttpException.notFound();
|
||||||
});
|
});
|
||||||
|
|
||||||
server = await app.startServer();
|
server = await app.startServer();
|
||||||
|
@ -40,4 +40,14 @@ main() {
|
||||||
print('Headers: ${response.headers}');
|
print('Headers: ${response.headers}');
|
||||||
expect(response.headers['access-control-allow-origin'], equals('*'));
|
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'));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue