java.lang.Object
org.miaixz.bus.http.bodys.RequestBody
org.miaixz.bus.http.bodys.FormBody
An HTTP request body that represents form-encoded data.
This class handles form data encoded in the application/x-www-form-urlencoded format. It provides support for
encoding and decoding form field names and values, which are stored as key-value pairs.
- Since:
- Java 17+
- Author:
- Kimi Liu
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionlongReturns the length of this request body in bytes.org.miaixz.bus.core.lang.MediaTypeReturns the media type of this request body.encodedName(int index) Returns the encoded field name at the specified index.encodedValue(int index) Returns the encoded field value at the specified index.name(int index) Returns the decoded field name at the specified index.intsize()Returns the number of form fields.value(int index) Returns the decoded field value at the specified index.voidwriteTo(org.miaixz.bus.core.io.sink.BufferSink sink) Writes the content of this request body to the given sink.
-
Method Details
-
size
public int size()Returns the number of form fields.- Returns:
- The number of fields.
-
encodedName
Returns the encoded field name at the specified index.- Parameters:
index- The index.- Returns:
- The encoded field name.
-
name
Returns the decoded field name at the specified index.- Parameters:
index- The index.- Returns:
- The decoded field name.
-
encodedValue
Returns the encoded field value at the specified index.- Parameters:
index- The index.- Returns:
- The encoded field value.
-
value
Returns the decoded field value at the specified index.- Parameters:
index- The index.- Returns:
- The decoded field value.
-
contentType
public org.miaixz.bus.core.lang.MediaType contentType()Returns the media type of this request body.- Specified by:
contentTypein classRequestBody- Returns:
- The media type (application/x-www-form-urlencoded).
-
contentLength
public long contentLength()Returns the length of this request body in bytes.- Overrides:
contentLengthin classRequestBody- Returns:
- The length of the request body.
-
writeTo
Writes the content of this request body to the given sink.- Specified by:
writeToin classRequestBody- Parameters:
sink- The sink to write to.- Throws:
IOException- if an I/O error occurs.
-