public class HttpRequest extends HttpPacket
| Modifier and Type | Field and Description |
|---|---|
org.tio.core.ChannelContext |
channelContext |
protected Map<String,String> |
headers |
HttpConfig |
httpConfig |
RequestLine |
requestLine |
body| Constructor and Description |
|---|
HttpRequest() |
HttpRequest(org.tio.core.Node remote) |
| Modifier and Type | Method and Description |
|---|---|
void |
addHeader(String key,
String value) |
void |
addHeaders(Map<String,String> headers) |
void |
addParam(String key,
Object value) |
void |
close()
关闭连接
|
void |
close(String remark)
关闭连接
|
HttpResponse |
forward(String newPath) |
HttpConst.RequestBodyFormat |
getBodyFormat() |
String |
getBodyString() |
Byte |
getByte(String name) |
byte |
getByte(String name,
byte defaultValue) |
org.tio.core.ChannelContext |
getChannelContext() |
Charset |
getCharset() |
String |
getClientIp()
获取真实的客户端ip
|
String |
getConnection() |
int |
getContentLength() |
Cookie |
getCookie(String name) |
@NotNull Map<String,Cookie> |
getCookieMap() |
Collection<Cookie> |
getCookies() |
long |
getCreateTime() |
String |
getDomain()
根据host字段,获取去除端口的纯域名部分的值,形如:www.t-io.org, t-io.org等值
|
Double |
getDouble(String name) |
double |
getDouble(String name,
double defaultValue) |
Float |
getFloat(String name) |
float |
getFloat(String name,
float defaultValue) |
String |
getHeader(String key) |
Map<String,String> |
getHeaders() |
String |
getHost()
获取请求头中的host字段,形如:www.t-io.org:8080, www.t-io.org等值
|
HttpConfig |
getHttpConfig() |
long |
getId() |
Integer |
getInt(String name) |
int |
getInt(String name,
int defaultValue)
获取 int 参数
|
boolean |
getIsSupportGzip() |
Long |
getLong(String name) |
long |
getLong(String name,
long defaultValue) |
Object |
getObject(String name) |
Map<String,Object> |
getParam()
把类型为数组的参数值转换成Object,相当于是取了数组的第一个值,便于业务开发(因为大部分参数值其实只有一个)
|
String |
getParam(String name) |
Object[] |
getParamArray(String name) |
Map<String,Object[]> |
getParams() |
String |
getReferer() |
org.tio.core.Node |
getRemote() |
RequestLine |
getRequestLine() |
Short |
getShort(String name) |
short |
getShort(String name,
short defaultValue) |
String |
getString(String name)
同getParam(String name)
|
UploadFile |
getUploadFile(String name) |
String |
getUserAgent()
获取请求头中的User-Agent字段
|
boolean |
isClosed() |
boolean |
isForward() |
boolean |
isNeedForward() |
String |
logstr() |
void |
removeHeader(String key,
String value) |
void |
setBodyFormat(HttpConst.RequestBodyFormat bodyFormat) |
void |
setBodyString(String bodyString) |
void |
setChannelContext(org.tio.core.ChannelContext channelContext) |
void |
setCharset(Charset charset) |
void |
setClosed(boolean closed) |
void |
setConnection(String connection) |
void |
setContentLength(int contentLength) |
void |
setCreateTime(long createTime) |
void |
setForward(boolean isForward) |
void |
setHeaders(Map<String,String> headers)
设置好header后,会把cookie等头部信息也设置好
|
void |
setHttpConfig(HttpConfig httpConfig) |
void |
setNeedForward(boolean needForward) |
void |
setParams(Map<String,Object[]> params) |
void |
setRemote(org.tio.core.Node remote) |
void |
setRequestLine(RequestLine requestLine) |
String |
toString() |
getAttribute, getAttribute, getBody, getHeaderString, removeAttribute, setAttribute, setBody, setHeaderStringpublic RequestLine requestLine
public org.tio.core.ChannelContext channelContext
public HttpConfig httpConfig
public HttpRequest(org.tio.core.Node remote)
public HttpRequest()
public long getId()
public void close()
public void close(String remark)
remark - remarkpublic HttpResponse forward(String newPath)
newPath - newPathpublic HttpConst.RequestBodyFormat getBodyFormat()
public void setBodyFormat(HttpConst.RequestBodyFormat bodyFormat)
bodyFormat - the bodyFormat to setpublic String getUserAgent()
public String getHost()
public String getClientIp()
public String getDomain()
public String getBodyString()
public void setBodyString(String bodyString)
bodyString - the bodyString to setpublic org.tio.core.ChannelContext getChannelContext()
public void setChannelContext(org.tio.core.ChannelContext channelContext)
channelContext - the channelContext to setpublic Charset getCharset()
public void setCharset(Charset charset)
charset - the charset to setpublic int getContentLength()
public void setContentLength(int contentLength)
contentLength - the bodyLength to setpublic Collection<Cookie> getCookies()
public HttpConfig getHttpConfig()
public void setHttpConfig(HttpConfig httpConfig)
httpConfig - the httpConfig to setpublic void setHeaders(Map<String,String> headers)
headers - the headers to setpublic boolean getIsSupportGzip()
public Map<String,Object> getParam()
public String getString(String name)
name - namepublic UploadFile getUploadFile(String name)
name - namepublic int getInt(String name, int defaultValue)
name - namedefaultValue - 默认值public short getShort(String name, short defaultValue)
public byte getByte(String name, byte defaultValue)
public long getLong(String name, long defaultValue)
public double getDouble(String name, double defaultValue)
public float getFloat(String name, float defaultValue)
public Object[] getParamArray(String name)
name - namepublic org.tio.core.Node getRemote()
public void setRemote(org.tio.core.Node remote)
public RequestLine getRequestLine()
public void setRequestLine(RequestLine requestLine)
requestLine - the requestLine to setpublic String logstr()
logstr in class org.tio.core.intf.Packetpublic long getCreateTime()
public void setCreateTime(long createTime)
public boolean isClosed()
public void setClosed(boolean closed)
public String getConnection()
public void setConnection(String connection)
connection - the connection to setpublic String getReferer()
public boolean isNeedForward()
public void setNeedForward(boolean needForward)
public boolean isForward()
public void setForward(boolean isForward)
Copyright © 2025. All rights reserved.