public final class FormBody extends RequestBody
Modifier and Type | Class and Description |
---|---|
static class |
FormBody.Builder |
Modifier and Type | Field and Description |
---|---|
private static MediaType |
CONTENT_TYPE |
private java.util.List<java.lang.String> |
encodedNames |
private java.util.List<java.lang.String> |
encodedValues |
Constructor and Description |
---|
FormBody(java.util.List<java.lang.String> encodedNames,
java.util.List<java.lang.String> encodedValues) |
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. |
MediaType |
contentType()
Returns the Content-Type header for this body.
|
java.lang.String |
encodedName(int index) |
java.lang.String |
encodedValue(int index) |
java.lang.String |
name(int index) |
int |
size()
The number of key-value pairs in this form-encoded body.
|
java.lang.String |
value(int index) |
private long |
writeOrCountBytes(okio.BufferedSink sink,
boolean countBytes)
Either writes this request to
sink or measures its content length. |
void |
writeTo(okio.BufferedSink sink)
Writes the content of this request to
sink . |
private static final MediaType CONTENT_TYPE
private final java.util.List<java.lang.String> encodedNames
private final java.util.List<java.lang.String> encodedValues
FormBody(java.util.List<java.lang.String> encodedNames, java.util.List<java.lang.String> encodedValues)
public int size()
public java.lang.String encodedName(int index)
public java.lang.String name(int index)
public java.lang.String encodedValue(int index)
public java.lang.String value(int index)
public MediaType contentType()
RequestBody
contentType
in class RequestBody
public long contentLength()
RequestBody
sink
in a call to RequestBody.writeTo(okio.BufferedSink)
,
or -1 if that count is unknown.contentLength
in class RequestBody
public void writeTo(okio.BufferedSink sink) throws java.io.IOException
RequestBody
sink
.writeTo
in class RequestBody
java.io.IOException
private long writeOrCountBytes(@Nullable okio.BufferedSink sink, boolean countBytes)
sink
or measures its content length. We have one method
do double-duty to make sure the counting and content are consistent, particularly when it comes
to awkward operations like measuring the encoded length of header strings, or the
length-in-digits of an encoded integer.