Package org.jgrapes.http
Class WwwFormUrldecoder
java.lang.Object
org.jgrapes.http.WwwFormUrldecoder
- All Implemented Interfaces:
InputConsumer
Decodes www-form-urlencoded data.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionSets the charset to be used iffeed(ManagedBuffer)is invoked withManagedBuffer<ByteBuffer>.consumer(BiConsumer<String, String> consumer) Configures a consumer for key/value pairs.booleaneof()Checks if more input may become available.<W extends Buffer>
voidCallsfeed(ManagedBuffer)with the provided event’s buffer.<W extends Buffer>
voidfeed(ManagedBuffer<W> buffer) Feed data to the collector.formCharset(Charset charset) The charset to be used withURLDecoder.decode(String, Charset).result()Gets the result.
-
Constructor Details
-
WwwFormUrldecoder
public WwwFormUrldecoder()
-
-
Method Details
-
charset
Sets the charset to be used iffeed(ManagedBuffer)is invoked withManagedBuffer<ByteBuffer>.Defaults to UTF-8. Must be set before the first invocation of
feed(ManagedBuffer).This is provided for edge cases. As “urlencoded” data may only contain ASCII characters, it does not make sense to specify a charset for media type
x-www-form-urlencoded- Parameters:
charset- the charset- Returns:
- the managed buffer reader
-
formCharset
The charset to be used withURLDecoder.decode(String, Charset).Defaults to UTF-8.
- Parameters:
charset- the charset- Returns:
- the www form urldecoder
-
consumer
Configures a consumer for key/value pairs.The consumer is invoked when a pair has been decoded. If a consumer is configured,
result()must not be used (always returns an empty map).- Parameters:
consumer- the consumer- Returns:
- the decoder
-
feed
Feed data to the collector.Calling this method with
nullas argument closes the feed.- Specified by:
feedin interfaceInputConsumer- Parameters:
buffer- the buffer
-
feed
Callsfeed(ManagedBuffer)with the provided event’s buffer.If
IOEvent.isEndOfRecord()returnstrue, no further input data is processed.Calling this method with
nullindicates the end of the feed.- Specified by:
feedin interfaceInputConsumer- Type Parameters:
W- the generic type- Parameters:
event- the event
-
eof
Checks if more input may become available.- Returns:
- true, if successful
-
result
Gets the result.- Returns:
- the line
-