aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/com/android/volley/toolbox/HurlStack.java
diff options
context:
space:
mode:
authorAnonymous <no-reply@google.com>2017-08-10 00:23:15 +0000
committerandroid-build-merger <android-build-merger@google.com>2017-08-10 00:23:15 +0000
commit8b42d211a58fc5b434921a51cae2c99a806e00eb (patch)
tree840682988d908a367eadc4d2231bde1e43134333 /src/main/java/com/android/volley/toolbox/HurlStack.java
parentfd51dba5e6a4bb935fb4357a445848aee24eba11 (diff)
parentcc4c86984e7c6d0de90ea4362506fc5ca857bc68 (diff)
downloadvolley-8b42d211a58fc5b434921a51cae2c99a806e00eb.tar.gz
Import of Volley from GitHub to AOSP. - 27f4207774f7a0b59168f5b3b53d8c0c3841de64 Merge pull request #71 from google/fix-visibility by Jeff Davidson <jpd236@cornell.edu> - e1d75bc49fff2f43b4304688f22ccb57f0c2782c Merge pull request #66 from joebowbeer/dbc_overflow by Jeff Davidson <jpd236@cornell.edu> - d40b75f52f0f8e3467d63294142610a040ff8cd5 Merge pull request #64 from xyhuangjinfu/master by Jeff Davidson <jpd236@cornell.edu> - aafd2e5d1279d68cd2c39b02a915e501974daf2f Merge pull request #52 from joebowbeer/dbc by Jeff Davidson <jpd236@cornell.edu> - baefc4e4f7ad42ce84972716486928ab77b413fc Merge pull request #23 from google/javadoc-fixes by Jeff Davidson <jpd236@cornell.edu> - dea97629925acea8942c06a7ff52938eba5dc78c Merge pull request #39 from google/publish by Jeff Davidson <jpd236@cornell.edu> - f52e1e0d4a18c8e3e7004a3d60c8cbec9a04f3d4 Merge pull request #38 from SamuelYvon/master by Jeff Davidson <jpd236@cornell.edu> - f0ab9a527d3a525325139026a7da0318b506abb4 Merge pull request #41 from LappleApple/patch-1 by Jeff Davidson <jpd236@cornell.edu> - a444f81d099179ab7c5fa5f460262a206125cd37 Merge pull request #18 from Ericliu001/master by Jeff Davidson <jpd236@cornell.edu>android-o-mr1-preview-2android-o-mr1-preview-1
am: cc4c86984e Change-Id: I3c1cbe4af3237ac4bf2f54e4276bbc60151af82e
Diffstat (limited to 'src/main/java/com/android/volley/toolbox/HurlStack.java')
-rw-r--r--src/main/java/com/android/volley/toolbox/HurlStack.java30
1 files changed, 15 insertions, 15 deletions
diff --git a/src/main/java/com/android/volley/toolbox/HurlStack.java b/src/main/java/com/android/volley/toolbox/HurlStack.java
index c53d5e0..66f441d 100644
--- a/src/main/java/com/android/volley/toolbox/HurlStack.java
+++ b/src/main/java/com/android/volley/toolbox/HurlStack.java
@@ -59,7 +59,7 @@ public class HurlStack implements HttpStack {
* Returns a URL to use instead of the provided one, or null to indicate
* this URL should not be used at all.
*/
- public String rewriteUrl(String originalUrl);
+ String rewriteUrl(String originalUrl);
}
private final UrlRewriter mUrlRewriter;
@@ -209,16 +209,8 @@ public class HurlStack implements HttpStack {
// GET. Otherwise, it is assumed that the request is a POST.
byte[] postBody = request.getPostBody();
if (postBody != null) {
- // Prepare output. There is no need to set Content-Length explicitly,
- // since this is handled by HttpURLConnection using the size of the prepared
- // output stream.
- connection.setDoOutput(true);
connection.setRequestMethod("POST");
- connection.addRequestProperty(HEADER_CONTENT_TYPE,
- request.getPostBodyContentType());
- DataOutputStream out = new DataOutputStream(connection.getOutputStream());
- out.write(postBody);
- out.close();
+ addBody(connection, request, postBody);
}
break;
case Method.GET:
@@ -259,11 +251,19 @@ public class HurlStack implements HttpStack {
throws IOException, AuthFailureError {
byte[] body = request.getBody();
if (body != null) {
- connection.setDoOutput(true);
- connection.addRequestProperty(HEADER_CONTENT_TYPE, request.getBodyContentType());
- DataOutputStream out = new DataOutputStream(connection.getOutputStream());
- out.write(body);
- out.close();
+ addBody(connection, request, body);
}
}
+
+ private static void addBody(HttpURLConnection connection, Request<?> request, byte[] body)
+ throws IOException, AuthFailureError {
+ // Prepare output. There is no need to set Content-Length explicitly,
+ // since this is handled by HttpURLConnection using the size of the prepared
+ // output stream.
+ connection.setDoOutput(true);
+ connection.addRequestProperty(HEADER_CONTENT_TYPE, request.getBodyContentType());
+ DataOutputStream out = new DataOutputStream(connection.getOutputStream());
+ out.write(body);
+ out.close();
+ }
}