From adec488f99795bcba135cbbdb1b9821880425b4c Mon Sep 17 00:00:00 2001 From: Jon Watson Date: Thu, 31 Oct 2013 16:06:56 -0500 Subject: [PATCH] Allow PATCH to have body/output --- .../java/com/squareup/okhttp/internal/http/HttpEngine.java | 2 +- .../squareup/okhttp/internal/http/HttpURLConnectionImpl.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpEngine.java b/okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpEngine.java index df5af0c47..fee0e0159 100644 --- a/okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpEngine.java +++ b/okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpEngine.java @@ -339,7 +339,7 @@ public class HttpEngine { } boolean hasRequestBody() { - return method.equals("POST") || method.equals("PUT"); + return method.equals("POST") || method.equals("PUT") || method.equals("PATCH"); } /** Returns the request body or null if this request doesn't have a body. */ diff --git a/okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpURLConnectionImpl.java b/okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpURLConnectionImpl.java index 3beafb554..0ba02281c 100644 --- a/okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpURLConnectionImpl.java +++ b/okhttp/src/main/java/com/squareup/okhttp/internal/http/HttpURLConnectionImpl.java @@ -254,8 +254,8 @@ public class HttpURLConnectionImpl extends HttpURLConnection implements Policy { if (method.equals("GET")) { // they are requesting a stream to write to. This implies a POST method method = "POST"; - } else if (!method.equals("POST") && !method.equals("PUT")) { - // If the request method is neither POST nor PUT, then you're not writing + } else if (!method.equals("POST") && !method.equals("PUT") && !method.equals("PATCH")) { + // If the request method is neither POST nor PUT nor PATCH, then you're not writing throw new ProtocolException(method + " does not support writing"); } }