public abstract class RequestBody extends Object
| Constructor and Description |
|---|
RequestBody() |
| Modifier and Type | Method and Description |
|---|---|
long |
contentLength()
Returns the number of bytes that will be written to
out in a call to writeTo(okio.BufferedSink),
or -1 if that count is unknown. |
abstract MediaType |
contentType()
Returns the Content-Type header for this body.
|
static RequestBody |
create(MediaType contentType,
byte[] content)
Returns a new request body that transmits
content. |
static RequestBody |
create(MediaType contentType,
byte[] content,
int offset,
int byteCount)
Returns a new request body that transmits
content. |
static RequestBody |
create(MediaType contentType,
okio.ByteString content)
Returns a new request body that transmits
content. |
static RequestBody |
create(MediaType contentType,
File file)
Returns a new request body that transmits the content of
file. |
static RequestBody |
create(MediaType contentType,
String content)
Returns a new request body that transmits
content. |
abstract void |
writeTo(okio.BufferedSink sink)
Writes the content of this request to
out. |
@Nullable public abstract MediaType contentType()
public long contentLength()
throws IOException
out in a call to writeTo(okio.BufferedSink),
or -1 if that count is unknown.IOExceptionpublic abstract void writeTo(okio.BufferedSink sink)
throws IOException
out.IOExceptionpublic static RequestBody create(@Nullable MediaType contentType, String content)
content. If contentType is non-null
and lacks a charset, this will use UTF-8.public static RequestBody create(@Nullable MediaType contentType, okio.ByteString content)
content.public static RequestBody create(@Nullable MediaType contentType, byte[] content)
content.public static RequestBody create(@Nullable MediaType contentType, byte[] content, int offset, int byteCount)
content.public static RequestBody create(@Nullable MediaType contentType, File file)
file.Copyright © 2017. All Rights Reserved.