From 2635d5af972ae6604dc3074c86bab669d7d7754e Mon Sep 17 00:00:00 2001 From: Jeff Ching Date: Fri, 28 Dec 2018 10:35:52 -0800 Subject: [PATCH] Re-add Apache PATCH request (#547) * Revert "Revert "add patch to google http client (#486)" (#493)" This reverts commit 9de9cbbb45c78fe48138dff01be34a66b5b2f51b. * Move the new handlers to the apache-transport from the legacy apache-transport --- .../com/google/api/client/http/apache/ApacheHttpTransport.java | 3 +++ .../google/api/client/http/apache/ApacheHttpTransportTest.java | 2 ++ 2 files changed, 5 insertions(+) diff --git a/google-http-client-apache/src/main/java/com/google/api/client/http/apache/ApacheHttpTransport.java b/google-http-client-apache/src/main/java/com/google/api/client/http/apache/ApacheHttpTransport.java index 50e74dc87..0b55a4ed0 100644 --- a/google-http-client-apache/src/main/java/com/google/api/client/http/apache/ApacheHttpTransport.java +++ b/google-http-client-apache/src/main/java/com/google/api/client/http/apache/ApacheHttpTransport.java @@ -35,6 +35,7 @@ import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpHead; import org.apache.http.client.methods.HttpOptions; +import org.apache.http.client.methods.HttpPatch; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.client.methods.HttpRequestBase; @@ -209,6 +210,8 @@ protected ApacheHttpRequest buildRequest(String method, String url) { requestBase = new HttpGet(url); } else if (method.equals(HttpMethods.HEAD)) { requestBase = new HttpHead(url); + } else if (method.equals(HttpMethods.PATCH)) { + requestBase = new HttpPatch(url); } else if (method.equals(HttpMethods.POST)) { requestBase = new HttpPost(url); } else if (method.equals(HttpMethods.PUT)) { diff --git a/google-http-client-apache/src/test/java/com/google/api/client/http/apache/ApacheHttpTransportTest.java b/google-http-client-apache/src/test/java/com/google/api/client/http/apache/ApacheHttpTransportTest.java index 21aa27357..07f6c29c7 100644 --- a/google-http-client-apache/src/test/java/com/google/api/client/http/apache/ApacheHttpTransportTest.java +++ b/google-http-client-apache/src/test/java/com/google/api/client/http/apache/ApacheHttpTransportTest.java @@ -73,6 +73,8 @@ public void testRequestsWithContent() throws Exception { subtestUnsupportedRequestsWithContent( transport.buildRequest("HEAD", "http://www.test.url"), "HEAD"); + // Test PATCH. + execute(transport.buildRequest("PATCH", "http://www.test.url")); // Test PUT. execute(transport.buildRequest("PUT", "http://www.test.url")); // Test POST.