Package eu.bandm.tools.util.http
Class PostAndUrlReader
java.lang.Object
eu.bandm.tools.util.http.PostAndUrlReader
Decodes key/value pairs, as they occur in http connections, and stores
them to a map. Two methods are provided, one for "get" url-encoded paremeters,
one for "post" parameters which come with the "message body". Both use the
same encoding mechanism, which is called "url encoding" by practioneers
(because in URLs it is visible !-)
The specification is rfc822.
Encoding is NOT an issue because only ASCII characters are permitted. (0..127, see
section 3.1 and 3.3)
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
evidentstatic final int
evidentprotected int
Buffer for the current character read.static final int
evidentstatic final int
evidentstatic final int
evidentstatic final int
evidentstatic final int
evidentstatic final int
evidentevidentstatic final int
The integer number for "end of input" as produced byInputStream.read()
.static final int
evidentprotected int
Counter for maximally read characters.protected InputStream
Source of input.static final int
evidentstatic final int
evidentstatic final int
evident -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic int
hexdigit
(int c) Returns the integer value of a hexadecimal digit.read
(InputStream in, int maxNum) Decodes key/value pairs from an http connection message body, as with a "post" method, and stores them to a map.protected void
readC()
Read and convert a character in the bufferc
.protected void
readCC()
Decodes key/value pairs from an http connection url value, as with the "get" method, and stores them to a map.
-
Field Details
-
QUEST
public static final int QUESTevident- See Also:
-
BLANK
public static final int BLANKevident- See Also:
-
PERC
public static final int PERCevident- See Also:
-
PLUS
public static final int PLUSevident- See Also:
-
AMP
public static final int AMPevident- See Also:
-
EQ
public static final int EQevident- See Also:
-
ch_A
public static final int ch_Aevident- See Also:
-
ch_F
public static final int ch_Fevident- See Also:
-
ch_a
public static final int ch_aevident- See Also:
-
ch_f
public static final int ch_fevident- See Also:
-
ch_0
public static final int ch_0evident- See Also:
-
ch_9
public static final int ch_9evident- See Also:
-
eof
public static final int eofThe integer number for "end of input" as produced byInputStream.read()
.- See Also:
-
c
protected int cBuffer for the current character read. -
expected
protected int expectedCounter for maximally read characters. -
in
Source of input. -
emptyMap
evident
-
-
Constructor Details
-
PostAndUrlReader
public PostAndUrlReader()
-
-
Method Details
-
hexdigit
Returns the integer value of a hexadecimal digit.- Throws:
IOException
- if no such.
-
readCC
- Throws:
IOException
-
readC
Read and convert a character in the bufferc
. A "+" is replaced by a blank " ". A percent sign followed by two hex digits is replaced by the character with that number.- Throws:
IOException
- if no two hexdigits follow a percent.
-
readUrl
Decodes key/value pairs from an http connection url value, as with the "get" method, and stores them to a map. The url analyzed starting with the first occurence of the lead-in characterQUEST
. It there is no such occurence, an empty map is returned.- Throws:
IOException
-
read
Decodes key/value pairs from an http connection message body, as with a "post" method, and stores them to a map. The format of the text to decode iskey1=value1&key2=value2&key3=value3
whereVW%2aXY
can insert one character by two hexadecimal digits.The stream must be provided, and the maximum number of octets to be read. When the stream is closed or this number is reached, the map is returned as constructed so far.
- Throws:
IOException
-