Skip to content

Commit

Permalink
Handled PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
joviegas committed Dec 3, 2024
1 parent 700b3e5 commit 76713f1
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -116,31 +116,30 @@ private HttpRequestBase createApacheRequest(HttpExecuteRequest request, URI uri)

switch (method) {
case HEAD:
return request.contentStreamProvider().isPresent()
return isRequestBodyPresent(request)
? wrapEntity(request, new HttpRequestImpl(method, uri))
: new HttpHead(uri);
case GET:
return request.contentStreamProvider().isPresent()
return isRequestBodyPresent(request)
? wrapEntity(request, new HttpRequestImpl(method, uri))
: new HttpGet(uri);
case DELETE:
return request.contentStreamProvider().isPresent()
return isRequestBodyPresent(request)
? wrapEntity(request, new HttpRequestImpl(method, uri))
: new HttpDelete(uri);
case OPTIONS:
return request.contentStreamProvider().isPresent()
return isRequestBodyPresent(request)
? wrapEntity(request, new HttpRequestImpl(method, uri))
: new HttpOptions(uri);
case PATCH:
case POST:
case PUT:
return wrapEntity(request, new HttpRequestImpl(method, uri));
default:
throw new IllegalArgumentException("Unknown or unsupported HTTP method: " + method);
throw new RuntimeException("Unknown HTTP method name: " + request.httpRequest().method());
}
}


private HttpRequestBase wrapEntity(HttpExecuteRequest request,
HttpEntityEnclosingRequestBase entityEnclosingRequest) {

Expand Down Expand Up @@ -211,4 +210,9 @@ public String getMethod() {
return this.method.toString();
}
}

private static boolean isRequestBodyPresent(HttpExecuteRequest request) {
return request.contentStreamProvider().isPresent();
}

}

0 comments on commit 76713f1

Please sign in to comment.