final class BufferedRequestBody extends OutputStreamRequestBody
This body has two special powers. First, it can retransmit the same request body multiple times in order to recover from failures or cope with redirects. Second, it can compute the total length of the request body by measuring it after it has been written to the output stream.
| Modifier and Type | Field and Description |
|---|---|
(package private) okio.Buffer |
buffer |
(package private) long |
contentLength |
closed| Constructor and Description |
|---|
BufferedRequestBody(long expectedContentLength) |
| Modifier and Type | Method and Description |
|---|---|
long |
contentLength()
Returns the number of bytes that will be written to
sink in a call to RequestBody.writeTo(okio.BufferedSink),
or -1 if that count is unknown. |
Request |
prepareToSendRequest(Request request)
Now that we've buffered the entire request body, update the request headers and the body
itself.
|
void |
writeTo(okio.BufferedSink sink)
Writes the content of this request to
sink. |
contentType, initOutputStream, isClosed, outputStream, timeoutpublic long contentLength()
throws java.io.IOException
RequestBodysink in a call to RequestBody.writeTo(okio.BufferedSink),
or -1 if that count is unknown.contentLength in class OutputStreamRequestBodyjava.io.IOExceptionpublic Request prepareToSendRequest(Request request) throws java.io.IOException
prepareToSendRequest in class OutputStreamRequestBodyjava.io.IOExceptionpublic void writeTo(okio.BufferedSink sink)
throws java.io.IOException
RequestBodysink.writeTo in class RequestBodyjava.io.IOException