Skip to content

Commit

Permalink
[openhabcloud] Accept all Jetty supported http method types (openhab#…
Browse files Browse the repository at this point in the history
…10600)

* Accept all Jetty supported http method types
This fixes a number of open issues due to the fact that we were only accepting a limited number of http method types.  The effect of this was some functionality like DELETE or HEAD requests would just not work when using the cloud service, which madee our UI look broken in different ways,  also it poluted the users log with a lot of messages.

Fixes openhab/openhab-core#2312
Fixes openhab/openhab-cloud#328

Signed-off-by: Dan Cunningham <[email protected]>
Signed-off-by: John Marshall <[email protected]>
  • Loading branch information
digitaldan authored and themillhousegroup committed May 10, 2021
1 parent a4d5f70 commit e565c97
Showing 1 changed file with 7 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -315,20 +315,15 @@ private void handleRequestEvent(JSONObject data) {
proto = data.getString("protocol");
}
request.header("X-Forwarded-Proto", proto);

if (requestMethod.equals("GET")) {
request.method(HttpMethod.GET);
} else if (requestMethod.equals("POST")) {
request.method(HttpMethod.POST);
request.content(new BytesContentProvider(requestBody.getBytes()));
} else if (requestMethod.equals("PUT")) {
request.method(HttpMethod.PUT);
request.content(new BytesContentProvider(requestBody.getBytes()));
} else {
// TODO: Reject unsupported methods
logger.warn("Unsupported request method {}", requestMethod);
HttpMethod method = HttpMethod.fromString(requestMethod);
if (method == null) {
logger.debug("Unsupported request method {}", requestMethod);
return;
}
request.method(method);
if (!requestBody.isEmpty()) {
request.content(new BytesContentProvider(requestBody.getBytes()));
}

request.onResponseHeaders(response -> {
logger.debug("onHeaders {}", requestId);
Expand Down

0 comments on commit e565c97

Please sign in to comment.