public class HttpParser extends Object
Modifier and Type | Field and Description |
---|---|
static int |
PARSER_TYPE_REQUEST |
static int |
PARSER_TYPE_RESPONSE |
Modifier and Type | Method and Description |
---|---|
static Map<String,String> |
getEqualMap(String str)
解析字符串中的所有等号表达式成 Map
|
static void |
parseCookie(List<Cookie> cookies,
int cookieType,
String cookieValue)
处理消息的Cookie
|
static TreeMap<String,Object> |
parseHeader(ByteBuffer byteBuffer,
Runnable contiuneRead,
int timeout)
解析 HTTP 请求 Header 中的一行
|
static boolean |
parseHeaderLine(Map<String,Object> headerMap,
ByteBuffer byteBuffer,
Runnable contiuneRead,
int timeout)
解析 HTTP 请求 Header 中的一行
|
static int |
parseProtocol(Object[] packetMap,
int type,
ByteBuffer byteBuffer,
Runnable contiuneRead,
int timeout)
解析 HTTP 请求写一行
|
static Object[] |
parser(IoSession session,
Object[] packetMap,
int type,
ByteBufferChannel byteBufferChannel,
int timeout,
long requestMaxSize)
解析 HTTP 报文
解析称 Map 形式,其中:
1.protocol 解析成 key/value 形式
2.header 解析成 key/value 形式
3.cookie 解析成 List[Map[String,String]] 形式
3.part 解析成 List[Map[Stirng,Object]](因为是递归,参考 HTTP 解析形式) 形式
5.body 解析成 key=BODY_VALUE 的Map 元素
|
static Request |
parseRequest(IoSession session,
ByteBufferChannel byteBufferChannel,
int timeOut,
long requestMaxSize)
解析报文成 HttpRequest 对象
|
static Request |
parseRequest(Request request,
IoSession session,
ByteBufferChannel byteBufferChannel,
int timeOut,
long requestMaxSize)
解析报文成 HttpRequest 对象
|
static Response |
parseResponse(IoSession session,
ByteBufferChannel byteBufferChannel,
int timeOut)
解析报文成 HttpResponse 对象
|
static Response |
parseResponse(Response response,
IoSession session,
ByteBufferChannel byteBufferChannel,
int timeOut)
解析报文成 HttpResponse 对象
|
static void |
resetThreadLocal() |
public static final int PARSER_TYPE_REQUEST
public static final int PARSER_TYPE_RESPONSE
public static Map<String,String> getEqualMap(String str)
str
- 等式表达式public static void parseCookie(List<Cookie> cookies, int cookieType, String cookieValue)
cookies
- Cookie 保存集合cookieType
- Cookie 类型 0: request, 1: responsecookieValue
- Cookie 数据public static int parseProtocol(Object[] packetMap, int type, ByteBuffer byteBuffer, Runnable contiuneRead, int timeout)
packetMap
- 解析后数据的容器type
- 解析的报文类型byteBuffer
- ByteBuffer对象contiuneRead
- 当数据不足时的读取器timeout
- 读取超时时间参数public static boolean parseHeaderLine(Map<String,Object> headerMap, ByteBuffer byteBuffer, Runnable contiuneRead, int timeout)
headerMap
- 解析后数据的容器byteBuffer
- ByteBuffer对象contiuneRead
- 当数据不足时的读取器timeout
- 读取超时时间参数public static TreeMap<String,Object> parseHeader(ByteBuffer byteBuffer, Runnable contiuneRead, int timeout)
byteBuffer
- ByteBuffer对象contiuneRead
- 当数据不足时的读取器timeout
- 读取超时时间参数public static Object[] parser(IoSession session, Object[] packetMap, int type, ByteBufferChannel byteBufferChannel, int timeout, long requestMaxSize) throws IOException
session
- socket 会话对象packetMap
- 用于填充的解析 maptype
- 解析的报文类型, 0: Request, 1: ResponsebyteBufferChannel
- 输入流timeout
- 读取超时时间参数requestMaxSize
- 上传文件的最大尺寸, 单位: kbIOException
- IO 异常public static Request parseRequest(IoSession session, ByteBufferChannel byteBufferChannel, int timeOut, long requestMaxSize) throws IOException
session
- socket 会话对象byteBufferChannel
- 输入字节流timeOut
- 读取超时时间参数requestMaxSize
- 上传文件的最大尺寸, 单位: kbIOException
- IO 异常public static Request parseRequest(Request request, IoSession session, ByteBufferChannel byteBufferChannel, int timeOut, long requestMaxSize) throws IOException
request
- 请求对象session
- socket 会话对象byteBufferChannel
- 输入字节流timeOut
- 读取超时时间参数requestMaxSize
- 上传文件的最大尺寸, 单位: kbIOException
- IO 异常public static Response parseResponse(IoSession session, ByteBufferChannel byteBufferChannel, int timeOut) throws IOException
session
- socket 会话对象byteBufferChannel
- 输入字节流timeOut
- 读取超时时间参数IOException
- IO 异常public static Response parseResponse(Response response, IoSession session, ByteBufferChannel byteBufferChannel, int timeOut) throws IOException
response
- Resposne 响应对象session
- socket 会话对象byteBufferChannel
- 输入字节流timeOut
- 读取超时时间参数IOException
- IO 异常public static void resetThreadLocal()
Copyright © 2020 Voovan. All rights reserved.