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"); } }