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,
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(BufferedSink sink)
Writes the content of this request to
out . |
public abstract MediaType contentType()
public long contentLength()
out
in a call
to writeTo(okio.BufferedSink)
, or -1 if that count is unknown.public abstract void writeTo(BufferedSink sink) throws IOException
out
.IOException
public static RequestBody create(MediaType contentType, String content)
content
. If contentType
is non-null and lacks a charset, this will use UTF-8.public static RequestBody create(MediaType contentType, byte[] content)
content
.public static RequestBody create(MediaType contentType, File file)
file
.Copyright © 2014. All Rights Reserved.