FormEncoding.java
1.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
package com.squareup.mimecraft;
import java.io.IOException;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.net.URLEncoder;
import java.util.Collections;
import java.util.Map;
public final class FormEncoding
implements Part
{
private static final Map<String, String> a = Collections.singletonMap("Content-Type", "application/x-www-form-urlencoded");
private final byte[] b;
private FormEncoding(String paramString)
{
try
{
this.b = paramString.getBytes("UTF-8");
return;
}
catch (UnsupportedEncodingException localUnsupportedEncodingException)
{
throw new IllegalArgumentException("Unable to convert input to UTF-8: " + paramString, localUnsupportedEncodingException);
}
}
public final Map<String, String> getHeaders()
{
return a;
}
public final void writeBodyTo(OutputStream paramOutputStream)
throws IOException
{
paramOutputStream.write(this.b);
}
public static class Builder
{
private final StringBuilder a = new StringBuilder();
public Builder add(String paramString1, String paramString2)
{
if (this.a.length() > 0) {
this.a.append('&');
}
try
{
this.a.append(URLEncoder.encode(paramString1, "UTF-8")).append('=').append(URLEncoder.encode(paramString2, "UTF-8"));
return this;
}
catch (UnsupportedEncodingException paramString1)
{
throw new AssertionError(paramString1);
}
}
public FormEncoding build()
{
if (this.a.length() == 0) {
throw new IllegalStateException("Form encoded body must have at least one part.");
}
return new FormEncoding(this.a.toString(), (byte)0);
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/com/squareup/mimecraft/FormEncoding.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/