SimpleMultipartEntity.java
4.17 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
package net.hockeyapp.android.utils;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Random;
public class SimpleMultipartEntity
{
private static final char[] a = "-_1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray();
private boolean b = false;
private boolean c = false;
private ByteArrayOutputStream d = new ByteArrayOutputStream();
private String e;
public SimpleMultipartEntity()
{
StringBuffer localStringBuffer = new StringBuffer();
Random localRandom = new Random();
while (i < 30)
{
localStringBuffer.append(a[localRandom.nextInt(a.length)]);
i += 1;
}
this.e = localStringBuffer.toString();
}
public void addPart(String paramString, File paramFile, boolean paramBoolean)
throws IOException
{
addPart(paramString, paramFile.getName(), new FileInputStream(paramFile), paramBoolean);
}
public void addPart(String paramString1, String paramString2)
throws IOException
{
writeFirstBoundaryIfNeeds();
this.d.write(("Content-Disposition: form-data; name=\"" + paramString1 + "\"\r\n").getBytes());
this.d.write("Content-Type: text/plain; charset=UTF-8\r\n".getBytes());
this.d.write("Content-Transfer-Encoding: 8bit\r\n\r\n".getBytes());
this.d.write(paramString2.getBytes());
this.d.write(("\r\n--" + this.e + "\r\n").getBytes());
}
public void addPart(String paramString1, String paramString2, InputStream paramInputStream, String paramString3, boolean paramBoolean)
throws IOException
{
writeFirstBoundaryIfNeeds();
try
{
paramString3 = "Content-Type: " + paramString3 + "\r\n";
this.d.write(("Content-Disposition: form-data; name=\"" + paramString1 + "\"; filename=\"" + paramString2 + "\"\r\n").getBytes());
this.d.write(paramString3.getBytes());
this.d.write("Content-Transfer-Encoding: binary\r\n\r\n".getBytes());
paramString1 = new byte['က'];
for (;;)
{
int i = paramInputStream.read(paramString1);
if (i == -1) {
break;
}
this.d.write(paramString1, 0, i);
}
try
{
paramInputStream.close();
throw paramString1;
this.d.flush();
if (paramBoolean) {
writeLastBoundaryIfNeeds();
}
for (;;)
{
try
{
paramInputStream.close();
return;
}
catch (IOException paramString1)
{
paramString1.printStackTrace();
return;
}
this.d.write(("\r\n--" + this.e + "\r\n").getBytes());
}
}
catch (IOException paramString2)
{
for (;;)
{
paramString2.printStackTrace();
}
}
}
finally {}
}
public void addPart(String paramString1, String paramString2, InputStream paramInputStream, boolean paramBoolean)
throws IOException
{
addPart(paramString1, paramString2, paramInputStream, "application/octet-stream", paramBoolean);
}
public String getBoundary()
{
return this.e;
}
public long getContentLength()
{
writeLastBoundaryIfNeeds();
return this.d.toByteArray().length;
}
public String getContentType()
{
return "multipart/form-data; boundary=" + getBoundary();
}
public ByteArrayOutputStream getOutputStream()
{
writeLastBoundaryIfNeeds();
return this.d;
}
public void writeFirstBoundaryIfNeeds()
throws IOException
{
if (!this.c) {
this.d.write(("--" + this.e + "\r\n").getBytes());
}
this.c = true;
}
public void writeLastBoundaryIfNeeds()
{
if (this.b) {
return;
}
try
{
this.d.write(("\r\n--" + this.e + "--\r\n").getBytes());
this.b = true;
return;
}
catch (IOException localIOException)
{
for (;;)
{
localIOException.printStackTrace();
}
}
}
}
/* Location: /home/merong/decompile/hackery-dex2jar.jar!/net/hockeyapp/android/utils/SimpleMultipartEntity.class
* Java compiler version: 6 (50.0)
* JD-Core Version: 0.7.1
*/