|
47 | 47 | * </code> |
48 | 48 | */ |
49 | 49 | public class Request implements Iterable<NameValuePair> { |
| 50 | + public static final String UTF_8 = "UTF-8"; |
| 51 | + |
50 | 52 | private List<NameValuePair> mParams = new ArrayList<NameValuePair>(); // XXX should probably be lazy |
51 | 53 | private Map<String, Attachment> mFiles; |
52 | 54 |
|
@@ -82,10 +84,10 @@ public Request(String resource) { |
82 | 84 | try { |
83 | 85 | if (kv.length == 2) { |
84 | 86 | mParams.add(new BasicNameValuePair( |
85 | | - URLDecoder.decode(kv[0], "UTF-8"), |
86 | | - URLDecoder.decode(kv[1], "UTF-8"))); |
| 87 | + URLDecoder.decode(kv[0], UTF_8), |
| 88 | + URLDecoder.decode(kv[1], UTF_8))); |
87 | 89 | } else if (kv.length == 1) { |
88 | | - mParams.add(new BasicNameValuePair(URLDecoder.decode(kv[0], "UTF-8"), null)); |
| 90 | + mParams.add(new BasicNameValuePair(URLDecoder.decode(kv[0], UTF_8), null)); |
89 | 91 | } |
90 | 92 | } catch (UnsupportedEncodingException ignored) { |
91 | 93 | } |
@@ -215,7 +217,7 @@ public int size() { |
215 | 217 | * list of parameters in an HTTP PUT or HTTP POST. |
216 | 218 | */ |
217 | 219 | public String queryString() { |
218 | | - return format(mParams, "UTF-8"); |
| 220 | + return format(mParams, UTF_8); |
219 | 221 | } |
220 | 222 |
|
221 | 223 | /** |
@@ -317,7 +319,7 @@ public Request withEntity(HttpEntity entity) { |
317 | 319 | */ |
318 | 320 | public Request withContent(String content, String contentType) { |
319 | 321 | try { |
320 | | - StringEntity stringEntity = new StringEntity(content); |
| 322 | + StringEntity stringEntity = new StringEntity(content, UTF_8); |
321 | 323 | if (contentType != null) { |
322 | 324 | stringEntity.setContentType(contentType); |
323 | 325 | } |
@@ -377,7 +379,7 @@ public <T extends HttpRequestBase> T buildRequest(Class<T> method) { |
377 | 379 | HttpEntityEnclosingRequestBase enclosingRequest = |
378 | 380 | (HttpEntityEnclosingRequestBase) request; |
379 | 381 |
|
380 | | - final Charset charSet = java.nio.charset.Charset.forName("UTF-8"); |
| 382 | + final Charset charSet = java.nio.charset.Charset.forName(UTF_8); |
381 | 383 | if (isMultipart()) { |
382 | 384 | MultipartEntity multiPart = new MultipartEntity( |
383 | 385 | HttpMultipartMode.BROWSER_COMPATIBLE, // XXX change this to STRICT once rack on server is upgraded |
|
0 commit comments