Class WwwFormUrldecoder

java.lang.Object
org.jgrapes.http.WwwFormUrldecoder
All Implemented Interfaces:
InputConsumer

public class WwwFormUrldecoder extends Object implements InputConsumer
Decodes www-form-urlencoded data.
  • Constructor Details

  • Method Details

    • charset

      public WwwFormUrldecoder charset(Charset charset)
      Sets the charset to be used if feed(ManagedBuffer) is invoked with ManagedBuffer<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 with URLDecoder.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

      public <W extends Buffer> void feed(ManagedBuffer<W> buffer)
      Feed data to the collector.

      Calling this method with null as argument closes the feed.

      Specified by:
      feed in interface InputConsumer
      Parameters:
      buffer - the buffer
    • feed

      public <W extends Buffer> void feed(Input<W> event)
      Calls feed(ManagedBuffer) with the provided event’s buffer.

      If IOEvent.isEndOfRecord() returns true, no further input data is processed.

      Calling this method with null indicates the end of the feed.

      Specified by:
      feed in interface InputConsumer
      Type Parameters:
      W - the generic type
      Parameters:
      event - the event
    • eof

      public boolean eof()
      Checks if more input may become available.
      Returns:
      true, if successful
    • result

      public Map<String,List<String>> result()
      Gets the result.
      Returns:
      the line