-
Enhancement
-
Resolution: Won't Fix
-
P4
-
None
-
8, 11
A DESCRIPTION OF THE PROBLEM :
For the moment, it is impossible to make an HTTP PATCH request with HttpURLConnection object. PATCH is a valid HTTP Verb and is described on RFC 5789.
HTTP PATCH method RFC: https://tools.ietf.org/html/rfc5789
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use this main :
public static void main(String[] args) throws IOException {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("https://httpbin.org/patch").openConnection();
httpURLConnection.setRequestMethod("PATCH");
System.out.println(httpURLConnection.getResponseCode());
}
ACTUAL -
Exception in thread "main" java.net.ProtocolException: Invalid HTTP method: PATCH
---------- BEGIN SOURCE ----------
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("https://httpbin.org/patch").openConnection();
httpURLConnection.setRequestMethod("PATCH");
assertEquals(200, httpURLConnection.getResponseCode());
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
It's possible to bypass this bug by using reflection: rewrite the HttpUrlConnections.methods field to add the "PATCH" string into the array.
FREQUENCY : always
For the moment, it is impossible to make an HTTP PATCH request with HttpURLConnection object. PATCH is a valid HTTP Verb and is described on RFC 5789.
HTTP PATCH method RFC: https://tools.ietf.org/html/rfc5789
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Use this main :
public static void main(String[] args) throws IOException {
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("https://httpbin.org/patch").openConnection();
httpURLConnection.setRequestMethod("PATCH");
System.out.println(httpURLConnection.getResponseCode());
}
ACTUAL -
Exception in thread "main" java.net.ProtocolException: Invalid HTTP method: PATCH
---------- BEGIN SOURCE ----------
HttpURLConnection httpURLConnection = (HttpURLConnection) new URL("https://httpbin.org/patch").openConnection();
httpURLConnection.setRequestMethod("PATCH");
assertEquals(200, httpURLConnection.getResponseCode());
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
It's possible to bypass this bug by using reflection: rewrite the HttpUrlConnections.methods field to add the "PATCH" string into the array.
FREQUENCY : always
- duplicates
-
JDK-8226688 The class HttpURLConnection doesnt support PATCH http method.
- Closed