Package kilim.http
Class HttpRequest
- java.lang.Object
-
- kilim.http.HttpMsg
-
- kilim.http.HttpRequest
-
public class HttpRequest extends HttpMsg
This object encapsulates a bytebuffer (via HttpMsg). HttpRequestParser creates an instance of this object, but only converts a few of the important fields into Strings; the rest are maintained as ranges (offset + length) in the bytebuffer. UsegetHeader(String)to get the appropriate field.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) static byteb0(package private) static byteb9(package private) static byteba(package private) static bytebA(package private) static bytebf(package private) static bytebFintcontentLengthintcontentOffsetstatic byteCRintireadThe read cursor, used in the read* methods.java.lang.String[]keysKeys present in the HTTP headerstatic byteLFjava.lang.StringmethodThe original header.intnFieldsintqueryStringRange(package private) static byteSEMIinturiFragmentRangejava.lang.StringuriPathThe UTF8 decoded path from the HTTP header.int[]valueRangesintversionRange
-
Constructor Summary
Constructors Constructor Description HttpRequest()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddField(java.lang.String key, int valRange)voiddumpBuffer(java.nio.ByteBuffer buffer)byte[]extractBytes(int beg, int end)java.lang.StringextractRange(int range)java.lang.StringextractRange(int beg, int end)voidfill(EndPoint endpoint, int offset, int size)java.lang.StringgetHeader(java.lang.String key)Get the value for a given keyjava.lang.StringgetQuery()KeyValuesgetQueryComponents()KeyValuesgetQueryComponents(java.lang.String q)booleanisOldHttp()booleankeepAlive()static intparseChunkSize(java.nio.ByteBuffer buffer, int start, int end)voidreadAllChunks(EndPoint endpoint)voidreadBody(EndPoint endpoint)voidreadFrom(EndPoint endpoint)voidreadHeader(EndPoint endpoint)intreadLine(EndPoint endpoint)voidreadTrailers(EndPoint endpoint)voidreuse()Clear the request object so that it can be reused for the next message.java.lang.StringtoString()java.lang.StringuriFragment()java.lang.Stringversion()
-
-
-
Field Detail
-
method
public java.lang.String method
The original header. All string variables that pertain to the message's header are either subsequences of this header, or interned (all known keywords).
-
uriPath
public java.lang.String uriPath
The UTF8 decoded path from the HTTP header.
-
nFields
public int nFields
-
keys
public java.lang.String[] keys
Keys present in the HTTP header
-
versionRange
public int versionRange
-
uriFragmentRange
public int uriFragmentRange
-
queryStringRange
public int queryStringRange
-
valueRanges
public int[] valueRanges
-
contentOffset
public int contentOffset
-
contentLength
public int contentLength
-
iread
public int iread
The read cursor, used in the read* methods.
-
CR
public static byte CR
-
LF
public static byte LF
-
b0
static final byte b0
- See Also:
- Constant Field Values
-
b9
static final byte b9
- See Also:
- Constant Field Values
-
ba
static final byte ba
- See Also:
- Constant Field Values
-
bf
static final byte bf
- See Also:
- Constant Field Values
-
bA
static final byte bA
- See Also:
- Constant Field Values
-
bF
static final byte bF
- See Also:
- Constant Field Values
-
SEMI
static final byte SEMI
- See Also:
- Constant Field Values
-
-
Method Detail
-
getHeader
public java.lang.String getHeader(java.lang.String key)
Get the value for a given key- Parameters:
key-- Returns:
- null if the key is not present in the header.
-
getQuery
public java.lang.String getQuery()
- Returns:
- the query part of the URI.
-
version
public java.lang.String version()
-
keepAlive
public boolean keepAlive()
-
getQueryComponents
public KeyValues getQueryComponents()
-
getQueryComponents
public KeyValues getQueryComponents(java.lang.String q)
-
uriFragment
public java.lang.String uriFragment()
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
isOldHttp
public boolean isOldHttp()
- Returns:
- true if version is 1.0 or earlier
-
reuse
public void reuse()
Clear the request object so that it can be reused for the next message.
-
readFrom
public void readFrom(EndPoint endpoint) throws Pausable, java.io.IOException
- Throws:
Pausablejava.io.IOException
-
readHeader
public void readHeader(EndPoint endpoint) throws Pausable, java.io.IOException
- Throws:
Pausablejava.io.IOException
-
dumpBuffer
public void dumpBuffer(java.nio.ByteBuffer buffer)
-
addField
public void addField(java.lang.String key, int valRange)
-
extractRange
public java.lang.String extractRange(int range)
-
extractRange
public java.lang.String extractRange(int beg, int end)
-
extractBytes
public byte[] extractBytes(int beg, int end)
-
readBody
public void readBody(EndPoint endpoint) throws Pausable, java.io.IOException
- Throws:
Pausablejava.io.IOException
-
readTrailers
public void readTrailers(EndPoint endpoint)
-
readAllChunks
public void readAllChunks(EndPoint endpoint) throws java.io.IOException, Pausable
- Throws:
java.io.IOExceptionPausable
-
parseChunkSize
public static int parseChunkSize(java.nio.ByteBuffer buffer, int start, int end) throws java.io.IOException- Throws:
java.io.IOException
-
fill
public void fill(EndPoint endpoint, int offset, int size) throws java.io.IOException, Pausable
- Throws:
java.io.IOExceptionPausable
-
-