public class HttpRequest extends Request
Request.RequestType
Constructor and Description |
---|
HttpRequest()
构造函数
|
HttpRequest(Request request,
String characterSet,
IoSession socketSession)
构造函数
|
HttpRequest(String characterSet,
IoSession socketSession)
构造函数
|
Modifier and Type | Method and Description |
---|---|
void |
clear()
清理
|
HttpRequest |
copyFrom(HttpRequest request) |
HttpRequest |
copyFrom(HttpRequest request,
boolean useForSend) |
void |
flush()
将数据发送到 Socket 缓存
|
<T> T |
getAllParameterAsObject(Class<T> clazz)
将 HTTP 请求的所有参数, 转换成一个 Java 对象
|
Map<String,Object> |
getAttributes()
获取请求属性.此属性是会话级的
|
Object |
getAttributes(String attrName)
获取请求属性值
|
String |
getCharacterSet()
获取当前默认字符集
|
String |
getParameter(String paramName)
获取请求参数
|
boolean |
getParameterAsBoolean(String paramName)
获取 boolean 类型的数据
|
byte |
getParameterAsByte(String paramName)
获取 byte 类型的数据
|
char |
getParameterAsChar(String paramName)
获取 char 类型的数据
|
double |
getParameterAsDouble(String paramName)
获取 double 类型的数据
|
float |
getParameterAsFloat(String paramName)
获取 float 类型的数据
|
int |
getParameterAsInt(String paramName)
获取 int 类型的数据
|
long |
getParameterAsLong(String paramName)
获取 long 类型的数据
|
<T> T |
getParameterAsObject(String paramName,
Class<T> clazz)
将 HTTP 请求的一个参数,使用 JSON 转换成一个 Java 对象
|
short |
getParameterAsShort(String paramName)
获取 short 类型的数据
|
List<String> |
getParameterNames()
获取请求参数名称集合
|
Map<String,String> |
getParameters()
获取请求参数集合
|
protected String |
getQueryString()
获取请求字符串
|
String |
getRemoteAddres()
获取对端连接的 IP
|
int |
getRemotePort()
获取对端连接的端口
|
HttpSession |
getSession()
获取 Session
|
protected SessionManager |
getSessionManager() |
IoSession |
getSocketSession()
获取 socket 会话对象
|
void |
init(Request request,
String characterSet,
IoSession socketSession) |
void |
redirect(String url)
重置请求
用于在 HttpFilter 中重新定向,其他地方无用
|
void |
saveUploadedFile(String name,
File file)
保存上传的文件
|
void |
saveUploadedFile(String name,
String file)
保存上传的文件
|
void |
send()
发送响应
|
int |
send(ByteBuffer byteBuffer)
追加形式发送数据
|
boolean |
sessionExists()
判断 session 是否存在
|
void |
setAttributes(String attrName,
Object attrValue)
设置请求属性
|
protected void |
setCharacterSet(String charset)
设置当前默认字符集
|
protected void |
setSession(HttpSession session)
设置一个 Session
|
protected void |
setSessionManager(SessionManager sessionManager) |
protected void |
setSocketSession(IoSession socketSession)
设置 socket 会话对象
|
public HttpRequest()
public HttpRequest(Request request, String characterSet, IoSession socketSession)
request
- 解析出的 Request 对象characterSet
- 字符集socketSession
- socket 会话对象protected SessionManager getSessionManager()
protected void setSessionManager(SessionManager sessionManager)
public IoSession getSocketSession()
protected void setSocketSession(IoSession socketSession)
socketSession
- socket 会话对象public boolean sessionExists()
public HttpSession getSession()
protected void setSession(HttpSession session)
session
- HTTP-Session 对象public String getRemoteAddres()
public int getRemotePort()
public String getCharacterSet()
protected void setCharacterSet(String charset)
charset
- 字符集protected String getQueryString()
public String getParameter(String paramName)
paramName
- 请求参数名称public int getParameterAsInt(String paramName)
paramName
- 请求参数名称public float getParameterAsFloat(String paramName)
paramName
- 请求参数名称public long getParameterAsLong(String paramName)
paramName
- 请求参数名称public short getParameterAsShort(String paramName)
paramName
- 请求参数名称public double getParameterAsDouble(String paramName)
paramName
- 请求参数名称public boolean getParameterAsBoolean(String paramName)
paramName
- 请求参数名称public byte getParameterAsByte(String paramName)
paramName
- 请求参数名称public char getParameterAsChar(String paramName)
paramName
- 请求参数名称public <T> T getParameterAsObject(String paramName, Class<T> clazz)
T
- 范型paramName
- 参数名clazz
- 自定义数据类型public <T> T getAllParameterAsObject(Class<T> clazz)
T
- 范型clazz
- 自定义数据类型public Object getAttributes(String attrName)
attrName
- 请求属性名称public void setAttributes(String attrName, Object attrValue)
attrName
- 请求属性名称attrValue
- 请求属性值public void send() throws IOException
IOException
- IO 异常public int send(ByteBuffer byteBuffer) throws IOException
byteBuffer
- 发送的缓冲区IOException
- IOException IO 异常public void flush()
public void saveUploadedFile(String name, File file) throws IOException
name
- 提交的参数名file
- 目标文件名IOException
- IO 异常public void saveUploadedFile(String name, String file) throws IOException
name
- 提交的参数名file
- 目标文件名IOException
- IO 异常public void redirect(String url)
url
- 请求地址,"/"起始,可以包含"?"参数引导及参数.public HttpRequest copyFrom(HttpRequest request)
public HttpRequest copyFrom(HttpRequest request, boolean useForSend)
Copyright © 2020 Voovan. All rights reserved.