Skip to content

Commit 7e5d89a

Browse files
author
Noor Dawod
committed
Forgot to use the new field name :)
1 parent d7d7e81 commit 7e5d89a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

library/src/main/java/com/loopj/android/http/JsonStreamerEntity.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ public class JsonStreamerEntity implements HttpEntity {
5858
private static final byte[] STREAM_NAME = escape("name");
5959
private static final byte[] STREAM_TYPE = escape("type");
6060
private static final byte[] STREAM_CONTENTS = escape("contents");
61-
private static final byte[] STREAM_ELAPSED = escape("_elapsed");
6261

6362
private static final Header HEADER_JSON_CONTENT =
6463
new BasicHeader(
@@ -76,14 +75,16 @@ public class JsonStreamerEntity implements HttpEntity {
7675
// Whether to use gzip compression while uploading
7776
private final Header contentEncoding;
7877

79-
private final String elapsedField;
78+
private final byte[] elapsedField;
8079

8180
private final ResponseHandlerInterface progressHandler;
8281

8382
public JsonStreamerEntity(ResponseHandlerInterface progressHandler, boolean useGZipCompression, String elapsedField) {
8483
this.progressHandler = progressHandler;
8584
this.contentEncoding = useGZipCompression ? HEADER_GZIP_ENCODING : null;
86-
this.elapsedField = elapsedField;
85+
this.elapsedField = TextUtils.isEmpty(elapsedField)
86+
? null
87+
: escape(elapsedField);
8788
}
8889

8990
/**
@@ -146,7 +147,7 @@ public void writeTo(final OutputStream out) throws IOException {
146147

147148
// Use GZIP compression when sending streams, otherwise just use
148149
// a buffered output stream to speed things up a bit.
149-
OutputStream os = null != contentEncoding
150+
OutputStream os = contentEncoding != null
150151
? new GZIPOutputStream(out, BUFFER_SIZE)
151152
: out;
152153

@@ -216,7 +217,7 @@ public void writeTo(final OutputStream out) throws IOException {
216217
}
217218
} finally {
218219
// Separate each K:V with a comma, except the last one.
219-
if (!TextUtils.isEmpty(elapsedField) || keysProcessed < keysCount) {
220+
if (elapsedField != null || keysProcessed < keysCount) {
220221
os.write(',');
221222
}
222223
}
@@ -228,8 +229,8 @@ public void writeTo(final OutputStream out) throws IOException {
228229
// Include the elapsed time taken to upload everything.
229230
// This might be useful for somebody, but it serves us well since
230231
// there will almost always be a ',' as the last sent character.
231-
if (!TextUtils.isEmpty(elapsedField)) {
232-
os.write(STREAM_ELAPSED);
232+
if (elapsedField != null) {
233+
os.write(elapsedField);
233234
os.write(':');
234235
os.write((elapsedTime + "").getBytes());
235236
}

0 commit comments

Comments
 (0)