[openhabcloud] Accept all Jetty supported http method types (#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 https://github.com/openhab/openhab-core/issues/2312
Fixes https://github.com/openhab/openhab-cloud/issues/328

Signed-off-by: Dan Cunningham <dan@digitaldan.com>
This commit is contained in:
Dan Cunningham 2021-04-28 00:12:01 -07:00 committed by GitHub
parent eda5346a50
commit 9810995d09
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -315,20 +315,15 @@ public class CloudClient {
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);