mmazi / rescu

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

Add patch support with JAVA 8 #100

Closed EricAnderson1000 closed 6 years ago

EricAnderson1000 commented 6 years ago

@mmazi Please review changes

mmazi commented 6 years ago

Great, thanks!

I'll release this in rescu 2.0.1 shortly.

johnzweng commented 5 years ago

I know this is an old and merged PR, but is HTTP method PATCH working for anybody with Java 8?

I have a system running OpenJDK Runtime Environment (build 1.8.0_191-8u191-b12-2ubuntu0.16.04.1-b12).

When using the @PATCH annotation, I get an exception: Invalid HTTP method: PATCH (see below)

This seems to be reasonable as in HttpTemplate.java:160 a java.net.HttpURLConnection is used to create the connection which seems not to support PATCH.

See in openjdk HttpURLConnection:360.

So I am wondering, how could this be working for anybody running Java 8? Or am I missing something? (Please correct me, if so.)

java.net.ProtocolException: Invalid HTTP method: PATCH
    at java.net.HttpURLConnection.setRequestMethod(HttpURLConnection.java:440)
    at sun.net.www.protocol.http.HttpURLConnection.setRequestMethod(HttpURLConnection.java:552)
    at sun.net.www.protocol.https.HttpsURLConnectionImpl.setRequestMethod(HttpsURLConnectionImpl.java:383)
    at si.mazi.rescu.HttpTemplate.configureURLConnection(HttpTemplate.java:160)
    at si.mazi.rescu.HttpTemplate.send(HttpTemplate.java:100)
    at si.mazi.rescu.RestInvocationHandler.invokeHttp(RestInvocationHandler.java:158)
    at si.mazi.rescu.RestInvocationHandler.invoke(RestInvocationHandler.java:117)
    at com.sun.proxy.$Proxy4.patchApiMethod(Unknown Source)
    at com......patchApiMethod(xxxxx.java:98)
    ...