Java Code Examples for com.squareup.okhttp.RequestBody#contentType()
The following examples show how to use
com.squareup.okhttp.RequestBody#contentType() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SendFeedBack.java From xDrip with GNU General Public License v3.0 | 6 votes |
/** * https://github.com/square/okhttp/issues/350 */ private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { final Buffer buffer = new Buffer(); requestBody.writeTo(buffer); return new RequestBody() { @Override public MediaType contentType() { return requestBody.contentType(); } @Override public long contentLength() { return buffer.size(); } @Override public void writeTo(BufferedSink sink) throws IOException { sink.write(buffer.snapshot()); } }; }
Example 2
Source File: SendFeedBack.java From xDrip with GNU General Public License v3.0 | 6 votes |
private RequestBody gzip(final RequestBody body) { return new RequestBody() { @Override public MediaType contentType() { return body.contentType(); } @Override public long contentLength() { return -1; // We don't know the compressed length in advance! } @Override public void writeTo(BufferedSink sink) throws IOException { BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); body.writeTo(gzipSink); gzipSink.close(); } }; }
Example 3
Source File: SendFeedBack.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
/** * https://github.com/square/okhttp/issues/350 */ private RequestBody forceContentLength(final RequestBody requestBody) throws IOException { final Buffer buffer = new Buffer(); requestBody.writeTo(buffer); return new RequestBody() { @Override public MediaType contentType() { return requestBody.contentType(); } @Override public long contentLength() { return buffer.size(); } @Override public void writeTo(BufferedSink sink) throws IOException { sink.write(buffer.snapshot()); } }; }
Example 4
Source File: SendFeedBack.java From xDrip-plus with GNU General Public License v3.0 | 6 votes |
private RequestBody gzip(final RequestBody body) { return new RequestBody() { @Override public MediaType contentType() { return body.contentType(); } @Override public long contentLength() { return -1; // We don't know the compressed length in advance! } @Override public void writeTo(BufferedSink sink) throws IOException { BufferedSink gzipSink = Okio.buffer(new GzipSink(sink)); body.writeTo(gzipSink); gzipSink.close(); } }; }
Example 5
Source File: Ok2Factory.java From httplite with Apache License 2.0 | 5 votes |
ProgressRequestBody(RequestBody real, String mediaType, ProgressListener progressListener) { this.real = real; this.progressListener = progressListener; if (TextUtils.isEmpty(mediaType)) { this.mediaType = real.contentType(); } else { this.mediaType = MediaType.parse(mediaType); } }