Skip to content

Commit 26e803d

Browse files
committed
fix asios bug: access-control-request-method shoun't be lowercase
fix asios bug: access-control-request-method shoun't be lowercase v = 0.3.3
1 parent 587688c commit 26e803d

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

gradle.properties

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
1-
GROUP=com.zaoo.lambda-local
2-
VERSION_NAME=0.3.2
1+
GROUP=com.github.tempofeng.lambda-local
2+
VERSION_NAME=0.3.3
3+
LOCAL_MVN_REPO=./mvn-repo

lambda-local/build.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
apply plugin: 'java'
2+
apply plugin: 'maven'
23

34
compileJava {
45
sourceCompatibility = JavaVersion.VERSION_1_8
@@ -52,3 +53,11 @@ dependencies {
5253
// spring-test
5354
testCompile rootProject.ext.springTest
5455
}
56+
57+
uploadArchives {
58+
repositories {
59+
mavenDeployer {
60+
repository(url: LOCAL_MVN_REPO)
61+
}
62+
}
63+
}

lambda-local/src/main/java/com/zaoo/lambda/rest/AbstractLambdaRestService.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,9 @@ public LambdaProxyResponse handleRequest(LambdaProxyRequest input, Context conte
4949
}
5050

5151
// CORS pre-flight requests
52-
String accessControlRequestMethod = input.getHeaders().get("Access-Control-Request-Method");
52+
String accessControlRequestMethod = input.getHeaders().get("Access-Control-Request-Method") != null ?
53+
input.getHeaders().get("Access-Control-Request-Method") :
54+
input.getHeaders().get("access-control-request-method"); // axios: shouldn't use lower case
5355
if (httpMethod == HttpMethod.OPTIONS && accessControlRequestMethod != null) {
5456
// Use AccessControlRequestMethod as HttpMethod
5557
input.setHttpMethod(accessControlRequestMethod.toUpperCase());
@@ -60,9 +62,10 @@ public LambdaProxyResponse handleRequest(LambdaProxyRequest input, Context conte
6062
}
6163
}
6264

63-
throw new IllegalArgumentException(String.format("Unhandled request:path=%s,method=%s",
65+
throw new IllegalArgumentException(String.format("Unhandled request:path=%s,method=%s,accessControlRequestMethod=%s",
6466
input.getPath(),
65-
httpMethod));
67+
httpMethod,
68+
accessControlRequestMethod));
6669
}
6770

6871
private LambdaProxyResponse invokeCorsPreflightMethod(MethodInvoker methodInvoker, LambdaProxyRequest input) {

0 commit comments

Comments
 (0)