Class StandardFormBody
java.lang.Object
de.craftsblock.craftsnet.api.http.body.Body
de.craftsblock.craftsnet.api.http.body.bodies.FormBody<String>
de.craftsblock.craftsnet.api.http.body.bodies.StandardFormBody
- All Implemented Interfaces:
AutoCloseable
The
StandardFormBody class represents an HTTP request body that contains form data
encoded in the standard application/x-www-form-urlencoded format.
This class extends the FormBody class and provides methods to deserialize the form data
from an input stream and access individual form fields.
- Since:
- 2.2.0-SNAPSHOT
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionStandardFormBody(Request request, InputStream body) Constructs a newStandardFormBodyby reading and parsing form data from an input stream. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidDeserializes the input stream, parsing it into individual form fields and values.Retrieves the value of a specific field from the form data.booleanChecks if a specific field exists in the form data.Methods inherited from class de.craftsblock.craftsnet.api.http.body.bodies.FormBody
close, getBody, getDataMethods inherited from class de.craftsblock.craftsnet.api.http.body.Body
cleanUp, getAsJsonBody, getAsMultipartFormBody, getAsStandardFormBody, getAsType, getBodies, getBodyTypes, getRawContentType, isBodyFromType, isClosed, isJsonBody, isMultipartFormBody, isStandardFormBody
-
Constructor Details
-
StandardFormBody
Constructs a newStandardFormBodyby reading and parsing form data from an input stream.- Parameters:
request- The representation of the http request.body- The input stream containing the form data.- Throws:
IOException- If an error occurs while reading or parsing the form data.
-
-
Method Details
-
deserialize
Deserializes the input stream, parsing it into individual form fields and values. This method reads the input streamline by line, splitting it into form fields and their values. It then decodes and stores the field names and values in the data map.- Specified by:
deserializein classFormBody<String>- Throws:
IOException- If an I/O error occurs while reading the input stream.
-
hasField
Checks if a specific field exists in the form data. -
getField
Retrieves the value of a specific field from the form data.
-