FormBody, MultipartBodypublic abstract class RequestBody extends Object
| Constructor | Description |
|---|---|
RequestBody() |
| Modifier and Type | Method | Description |
|---|---|---|
long |
contentLength() |
Returns the number of bytes that will be written to
sink 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,
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. |
static RequestBody |
create(MediaType contentType,
okio.ByteString content) |
Returns a new request body that transmits
content. |
abstract void |
writeTo(okio.BufferedSink sink) |
Writes the content of this request to
sink. |
@Nullable public abstract MediaType contentType()
public long contentLength()
throws IOException
sink in a call to writeTo(okio.BufferedSink),
or -1 if that count is unknown.IOExceptionpublic abstract void writeTo(okio.BufferedSink sink)
throws IOException
sink.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 © 2021. All rights reserved.