diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index ac9a142..194c5b9 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -20,12 +20,13 @@ jobs: '11.0.x', '12.0.x', '13.0.x', + '14.0.x', ] steps: - uses: actions/checkout@v1 - uses: actions/setup-python@v1 with: - python-version: '3.7' + python-version: '3.8' - uses: actions/setup-java@v1 with: java-version: ${{ matrix.java-version }} diff --git a/CHANGELOG.md b/CHANGELOG.md index ada758c..2b0a0e8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,10 @@ ## [Unreleased] +## [0.12.1] - 2020-03-27 +### Added +- Support OPTIONS requests to allow for CORS. + ## [0.12.0] - 2019-07-12 ### Changed - Things now use `title` rather than `name`. @@ -20,7 +24,8 @@ ### Changed - Property, Action, and Event description now use `links` rather than `href`. - [Spec PR](https://github.com/mozilla-iot/wot/pull/119) -[Unreleased]: https://github.com/mozilla-iot/webthing-java/compare/v0.12.0...HEAD +[Unreleased]: https://github.com/mozilla-iot/webthing-java/compare/v0.12.1...HEAD +[0.12.1]: https://github.com/mozilla-iot/webthing-java/compare/v0.12.0...v0.12.1 [0.12.0]: https://github.com/mozilla-iot/webthing-java/compare/v0.11.0...v0.12.0 [0.11.0]: https://github.com/mozilla-iot/webthing-java/compare/v0.10.0...v0.11.0 [0.10.0]: https://github.com/mozilla-iot/webthing-java/compare/v0.9.1...v0.10.0 diff --git a/pom.xml b/pom.xml index 2b99507..7a80fc7 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ org.mozilla.iot webthing - 0.12.0 + 0.12.1 WebThing Implementation of an HTTP Web Thing. @@ -73,7 +73,7 @@ org.json json - 20180813 + 20190722 org.nanohttpd @@ -98,7 +98,7 @@ com.github.everit-org.json-schema org.everit.json.schema - 1.11.1 + 1.12.1 junit diff --git a/src/main/java/org/mozilla/iot/webthing/WebThingServer.java b/src/main/java/org/mozilla/iot/webthing/WebThingServer.java index b685b95..e151cbd 100644 --- a/src/main/java/org/mozilla/iot/webthing/WebThingServer.java +++ b/src/main/java/org/mozilla/iot/webthing/WebThingServer.java @@ -510,6 +510,12 @@ public Response other(String method, UriResource uriResource, Map urlParams, IHTTPSession session) { + if (method.equals("OPTIONS")) { + return corsResponse(NanoHTTPD.newFixedLengthResponse(Response.Status.NO_CONTENT, + null, + null)); + } + return corsResponse(NanoHTTPD.newFixedLengthResponse(Response.Status.METHOD_NOT_ALLOWED, null, null)); @@ -757,7 +763,7 @@ public void run() { link.put("rel", "alternate"); link.put("href", wsHref); description.getJSONArray("links").put(link); - + String base = String.format("%s://%s%s", this.isSecure(uriResource) ? "https" :