Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Manually merge PR #269, Conal-Tuohy's patch for HTTP PATCH
- Loading branch information
Showing
with
11 additions
and
3 deletions.
-
+11
−3
src/main/java/com/xmlcalabash/library/HttpRequest.java
|
@@ -63,6 +63,7 @@ |
|
|
import org.apache.http.client.methods.HttpHead; |
|
|
import org.apache.http.client.methods.HttpPost; |
|
|
import org.apache.http.client.methods.HttpPut; |
|
|
import org.apache.http.client.methods.HttpPatch; |
|
|
import org.apache.http.client.methods.HttpUriRequest; |
|
|
import org.apache.http.cookie.Cookie; |
|
|
import org.apache.http.entity.ByteArrayEntity; |
|
@@ -309,8 +310,8 @@ public void run() throws SaxonApiException { |
|
|
|
|
|
String lcMethod = method.toLowerCase(); |
|
|
|
|
|
// You can only have a body on PUT or POST |
|
|
if (body != null && !("put".equals(lcMethod) || "post".equals(lcMethod))) { |
|
|
// You can only have a body on PUT or POST or PATCH |
|
|
if (body != null && !("put".equals(lcMethod) || "post".equals(lcMethod) || "patch".equals(lcMethod))) { |
|
|
throw XProcException.stepError(5); |
|
|
} |
|
|
|
|
@@ -322,6 +323,8 @@ public void run() throws SaxonApiException { |
|
|
httpRequest = doPost(body); |
|
|
} else if ("put".equals(lcMethod)) { |
|
|
httpRequest = doPut(body); |
|
|
} else if ("patch".equals(lcMethod)) { |
|
|
httpRequest = doPatch(body); |
|
|
} else if ("head".equals(lcMethod)) { |
|
|
httpRequest = doHead(); |
|
|
} else if ("delete".equals(lcMethod)) { |
|
@@ -465,12 +468,17 @@ private HttpPut doPut(XdmNode body) { |
|
|
return method; |
|
|
} |
|
|
|
|
|
|
|
|
private HttpPost doPost(XdmNode body) { |
|
|
HttpPost method = new HttpPost(requestURI); |
|
|
doPutOrPost(method,body); |
|
|
return method; |
|
|
} |
|
|
|
|
|
private HttpPatch doPatch(XdmNode body) { |
|
|
HttpPatch method = new HttpPatch(requestURI); |
|
|
doPutOrPost(method,body); |
|
|
return method; |
|
|
} |
|
|
|
|
|
private void doPutOrPost(HttpEntityEnclosingRequest method, XdmNode body) { |
|
|
if (XProcConstants.c_multipart.equals(body.getNodeName())) { |
|
|