Skip to content

Commit

Permalink
Add support for OPTIONS method, used by CORS support at invoker.
Browse files Browse the repository at this point in the history
  • Loading branch information
joshuaauerbachwatson committed Sep 27, 2017
1 parent c87eff3 commit e9017fd
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions javaService/src/org/qcert/javasvc/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,11 @@ public Response serve(IHTTPSession session) {
String arg = files.get("postData");
String response = engine != null ? simulateWhisk(arg) : Dispatcher.dispatch(verb.get(0), arg);
return respond(Response.Status.OK, response);
} else if (Method.OPTIONS.equals(method)) {
Response response = respond(Response.Status.OK, "");
response.addHeader("Access-Control-Allow-Methods", "POST");
response.addHeader("Access-Control-Allow-Headers", "Content-Type");
return response;
} else {
System.out.println("Rejecting non-post request");
return respond(Response.Status.BAD_REQUEST, "Only POST requests accepted");
Expand Down

0 comments on commit e9017fd

Please sign in to comment.