mmazi / rescu

A lightweight json Rest client utility for JAX-RS
MIT License
65 stars 60 forks source link

Invalid HTTP method: PATCH #147

Open andre77 opened 1 week ago

andre77 commented 1 week ago

Facing a problem, where a REST API has a "PATCH" method using the jakarta.ws.rs.PATCH annotation i can very well setup such a call, but it fails with

Exception in thread "main" java.net.ProtocolException: Invalid HTTP method: PATCH
    at java.base/java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:491)
    at java.base/sun.net.www.protocol.http.HttpURLConnection.setRequestMethod(HttpURLConnection.java:598)
    at java.base/sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestMethod(HttpsURLConnectionImpl.java:343)
    at si.mazi.rescu.HttpTemplate.configureURLConnection(HttpTemplate.java:182)
    at si.mazi.rescu.HttpTemplate.send(HttpTemplate.java:123)
    at si.mazi.rescu.RestInvocationHandler.invokeHttp(RestInvocationHandler.java:152)
    at si.mazi.rescu.RestInvocationHandler.invoke(RestInvocationHandler.java:111)

with older java versions one could work around it with a pretty dirty trick: https://stackoverflow.com/questions/25163131/httpurlconnection-invalid-http-method-patch

but with the newer java versions (like ie 22.0.1) the workaround does not work any more

any idea how to bypass the problem?

mmazi commented 1 week ago

See also #95, #97, #100.

andre77 commented 1 week ago

here is an idea https://github.com/mmazi/rescu/pull/148