- java.lang.Object
-
- org.redkale.net.Request<HttpContext>
-
- org.redkale.net.http.HttpRequest
-
public class HttpRequest extends Request<HttpContext>
Http请求包 与javax.servlet.http.HttpServletRequest 基本类似。
同时提供json的解析接口: public Object getJsonParameter(Type type, String name)
Redkale提倡带简单的参数的GET请求采用类似REST风格, 因此提供了 getPathParam 系列接口。
例如简单的翻页查询
/pipes/user/query/offset:0/limit:20
获取页号: int offset = request.getPathParam("offset:", 0);
获取行数: int limit = request.getPathParam("limit:", 10);
详情见: https://redkale.org
- 作者:
- zhangjx
-
-
字段概要
字段 修饰符和类型 字段 说明 protected intactionidprotected booleanboundaryprotected booleanchunkedprotected booleanchunkedCRprotected intchunkedCurrOffsetprotected byte[]chunkedHalfLenBytesprotected intchunkedLengthprotected StringcontentEncodingprotected longcontentLengthprotected StringcontentTypeprotected Stringcookieprotected HttpCookie[]cookiesprotected SerializablecurrentUseridprotected Supplier<Serializable>currentUserSupplierprotected static SerializableCURRUSERID_NILprotected static byte[]EMPTY_BYTESprotected booleangetmethodprotected static StringHEAD_ACCEPTprotected static StringHEAD_CONNECTIONprotected static StringHEAD_CONTENT_ENCODINGprotected static StringHEAD_CONTENT_LENGTHprotected static StringHEAD_CONTENT_TYPEprotected static StringHEAD_COOKIEprotected static StringHEAD_EXPECTprotected static StringHEAD_HOSTprotected static StringHEAD_TRANSFER_ENCODINGprotected static StringHEAD_UPGRADEprotected static StringHEAD_USER_AGENTprotected intheaderHalfLenprotected intheaderLengthprotected HttpHeadersheadersprotected Stringhostprotected static StringHTTP_1_1protected static StringHTTP_2_0protected Stringlocaleprotected static intMAX_CHUNK_HEADER_SIZEprotected Stringmethodprotected static StringMETHOD_GETprotected static StringMETHOD_HEADprotected static StringMETHOD_OPTIONSprotected static StringMETHOD_POSTprotected static StringMETHOD_PUTprotected intmoduleidprotected StringnewSessionidprotected HttpParametersparamsprotected Stringprotocolprotected byte[]queryBytesprotected static intREAD_STATE_BODYprotected static intREAD_STATE_ENDprotected static intREAD_STATE_HEADERprotected static intREAD_STATE_ROUTEprotected intreadStateprotected StringremoteAddrprotected ConvertreqConvertprotected ConvertTypereqConvertTypeprotected StringrequestPathprotected ConvertrespConvertprotected ConvertTyperespConvertTypeprotected booleanrpcstatic StringSESSIONID_NAME-
从类继承的字段 org.redkale.net.Request
annotations, attributes, channel, context, createTime, jsonConvert, keepAlive, pipelineCompleted, pipelineCount, pipelineIndex, protobufConvert, readCompleted, traceid
-
-
构造器概要
构造器 限定符 构造器 说明 HttpRequest(HttpContext context)protectedHttpRequest(HttpContext context, WebRequest req)protectedHttpRequest(HttpContext context, ByteArray headerBytes, ByteArray bodyBytes)
-
方法概要
所有方法 静态方法 实例方法 具体方法 修饰符和类型 方法 说明 protected HttpRequestaddHeader(String name, String value)protected ByteArrayarray()StringchangeSessionid()更新sessionidStringchangeSessionid(String newSessionid)指定值更新sessionidWebRequestcreateSimpleRequest(String contextPath)intcurrentIntUserid()获取当前用户ID的int值longcurrentLongUserid()获取当前用户ID的long值StringcurrentStringUserid()获取当前用户ID的String值<T> TcurrentUser()建议使用 currentUserid, 通过userid从Service或缓存中获取用户信息
获取当前用户信息
数据类型由@HttpUserType指定<T extends Serializable>
TcurrentUserid(Class<T> type)获取当前用户IDintgetActionid()获取操作ID,来自@HttpMapping.actionid()byte[]getBody()获取请求内容的byte[]StringgetBody(Charset charset)获取请求内容指定的编码字符串<T> TgetBodyJson(Type type)获取请求内容的JavaBean对象<T> TgetBodyJson(Convert convert, Type type)获取请求内容的JavaBean对象StringgetBodyUTF8()获取请求内容的UTF-8编码字符串booleangetBooleanHeader(String name, boolean defaultValue)获取指定的header的boolean值, 没有返回默认boolean值booleangetBooleanParameter(String name, boolean defaultValue)获取指定的参数boolean值, 没有返回默认boolean值longgetContentLength()获取请求内容的长度, 为-1表示内容长度不确定StringgetContentType()获取Content-Type的header值StringgetCookie(String name)获取Cookie值StringgetCookie(String name, String dfvalue)获取Cookie值, 没有返回默认值HttpCookie[]getCookies()获取所有Cookie对象protected ByteArraygetDirectBody()直接获取body对象doublegetDoubleHeader(String name, double defaultValue)获取指定的header的double值, 没有返回默认double值doublegetDoubleParameter(String name, double defaultValue)获取指定的参数double值, 没有返回默认double值FlippergetFlipper()获取翻页对象 同 getFlipper("flipper", false, 0);FlippergetFlipper(boolean autoCreate)获取翻页对象 同 getFlipper("flipper", autoCreate, 0);FlippergetFlipper(boolean autoCreate, int maxLimit)获取翻页对象 同 getFlipper("flipper", autoCreate, maxLimit)FlippergetFlipper(int maxLimit)获取翻页对象 同 getFlipper("flipper", false, maxLimit);FlippergetFlipper(String name, boolean autoCreate, int maxLimit)获取翻页对象 https://redkale.org/pipes/users/list?floatgetFloatHeader(String name, float defaultValue)获取指定的header的float值, 没有返回默认float值floatgetFloatParameter(String name, float defaultValue)获取指定的参数float值, 没有返回默认float值StringgetHeader(String name)获取指定的header值StringgetHeader(String name, String defaultValue)获取指定的header值, 没有返回默认值String[]getHeaderNames()获取所有的header名HttpHeadersgetHeaders()获取请求Header总对象StringgetHost()获取Host的Header值intgetIntHeader(int radix, String name, int defaultValue)获取指定的header的int值, 没有返回默认int值intgetIntHeader(String name, int defaultValue)获取指定的header的int值, 没有返回默认int值intgetIntParameter(int radix, String name, int defaultValue)获取指定的参数int值, 没有返回默认int值intgetIntParameter(String name, int defaultValue)获取指定的参数int值, 没有返回默认int值<T> TgetJsonHeader(Type type, String name)获取指定的header的json值<T> TgetJsonHeader(JsonConvert convert, Type type, String name)获取指定的header的json值<T> TgetJsonParameter(Type type, String name)获取指定的参数json值<T> TgetJsonParameter(JsonConvert convert, Type type, String name)获取指定的参数json值StringgetLocale()获取国际化Locale,值可以取之于header或parameterlonggetLongHeader(int radix, String name, long defaultValue)获取指定的header的long值, 没有返回默认long值longgetLongHeader(String name, long defaultValue)获取指定的header的long值, 没有返回默认long值longgetLongParameter(int radix, String name, long defaultValue)获取指定的参数long值, 没有返回默认long值longgetLongParameter(String name, long defaultValue)获取指定的参数long值, 没有返回默认long值StringgetMethod()获取请求方法 GET、POST等intgetModuleid()获取模块ID,来自@HttpServlet.moduleid()MultiContextgetMultiContext()获取文件上传对象StringgetParameter(String name)获取指定的参数值StringgetParameter(String name, String defaultValue)获取指定的参数值, 没有返回默认值String[]getParameterNames()获取所有参数名HttpParametersgetParameters()获取请求参数总对象StringgetParametersToString()将请求参数转换成String, 字符串格式为: bean1={}&id=13&name=xxx
不会返回null,没有参数返回空字符串StringgetParametersToString(String prefix)将请求参数转换成String, 字符串格式为: bean1={}&id=13&name=xxx
不会返回null,没有参数返回空字符串StringgetPathLastParam()截取getRequestPath最后的一个/后面的部分doublegetPathLastParam(double defvalue)获取请求URL最后的一个/后面的部分的double值
例如请求URL /pipes/user/query/2
获取type参数: double type = request.getPathLastParam(0.0); //type = 2.0floatgetPathLastParam(float defvalue)获取请求URL最后的一个/后面的部分的float值
例如请求URL /pipes/user/query/2
获取type参数: float type = request.getPathLastParam(0.0f); //type = 2.0fintgetPathLastParam(int defvalue)获取请求URL最后的一个/后面的部分的int值
例如请求URL /pipes/user/query/2
获取type参数: int type = request.getPathLastParam(0); //type = 2intgetPathLastParam(int radix, int defvalue)获取请求URL最后的一个/后面的部分的int值
例如请求URL /pipes/user/query/2
获取type参数: int type = request.getPathLastParam(16, 0); //type = 2longgetPathLastParam(int radix, long defvalue)获取请求URL最后的一个/后面的部分的int值
例如请求URL /pipes/user/query/2
获取type参数: long type = request.getPathLastParam(16, 0L); //type = 2shortgetPathLastParam(int radix, short defvalue)获取请求URL最后的一个/后面的部分的short值
例如请求URL /pipes/user/query/2
获取type参数: short type = request.getPathLastParam(16, (short)0); //type = 2longgetPathLastParam(long defvalue)获取请求URL最后的一个/后面的部分的int值
例如请求URL /pipes/user/query/2
获取type参数: long type = request.getPathLastParam(0L); //type = 2shortgetPathLastParam(short defvalue)获取请求URL最后的一个/后面的部分的short值
例如请求URL /pipes/user/query/2
获取type参数: short type = request.getPathLastParam((short)0); //type = 2intgetPathParam(int radix, String prefix, int defvalue)获取请求URL分段中含prefix段的int值
例如请求URL /pipes/user/query/offset:0/limit:50
获取offset参数: int offset = request.getPathParam("offset:", 0);
获取limit参数: int limit = request.getPathParam(16, "limit:", 20); // limit = 16longgetPathParam(int radix, String prefix, long defvalue)获取请求URL分段中含prefix段的long值
例如请求URL /pipes/user/query/time:1453104341363/id:40
获取time参数: long time = request.getPathParam(16, "time:", 0L);shortgetPathParam(int radix, String prefix, short defvalue)获取请求URL分段中含prefix段的short值
例如请求URL /pipes/user/query/type:a
获取type参数: short type = request.getPathParam(16, "type:", (short)0); //type = 10doublegetPathParam(String prefix, double defvalue)获取请求URL分段中含prefix段的double值
例如请求URL /pipes/user/query/point:40.0
获取time参数: double point = request.getPathParam("point:", 0.0);floatgetPathParam(String prefix, float defvalue)获取请求URL分段中含prefix段的float值
例如请求URL /pipes/user/query/point:40.0
获取time参数: float point = request.getPathParam("point:", 0.0f);intgetPathParam(String prefix, int defvalue)获取请求URL分段中含prefix段的int值
例如请求URL /pipes/user/query/offset:0/limit:50
获取offset参数: int offset = request.getPathParam("offset:", 0);
获取limit参数: int limit = request.getPathParam("limit:", 20);longgetPathParam(String prefix, long defvalue)获取请求URL分段中含prefix段的long值
例如请求URL /pipes/user/query/time:1453104341363/id:40
获取time参数: long time = request.getPathParam("time:", 0L);shortgetPathParam(String prefix, short defvalue)获取请求URL分段中含prefix段的short值
例如请求URL /pipes/user/query/type:10
获取type参数: short type = request.getPathParam("type:", (short)0);StringgetPathParam(String prefix, String defvalue)获取请求URL分段中含prefix段的值
例如请求URL /pipes/user/query/name:hello
获取name参数: String name = request.getPathParam("name:", "none");String[]getPathParams(String prefix)从prefix之后截取getPath再对"/"进行分隔StringgetProtocol()获取协议名 http、https、ws、wss等byte[]getQueryBytes()获取请求参数的byte[]StringgetRemoteAddr()获取客户端地址IP, 与getRemoteAddress() 的区别在于:本方法优先取header中指定为RemoteAddress名的值, 没有则返回getRemoteAddress()的getHostAddress()。SocketAddressgetRemoteAddress()获取客户端地址IPprotected SerializablegetRequestid()StringgetRequestPath()获取请求的URLprotected ConvertgetRespConvert()protected ConvertTypegetRespConvertType()StringgetSessionid(boolean autoCreate)获取sessionidshortgetShortHeader(int radix, String name, int defaultValue)获取指定的header的short值, 没有返回默认short值shortgetShortHeader(int radix, String name, short defaultValue)获取指定的header的short值, 没有返回默认short值shortgetShortHeader(String name, int defaultValue)获取指定的header的short值, 没有返回默认short值shortgetShortHeader(String name, short defaultValue)获取指定的header的short值, 没有返回默认short值shortgetShortParameter(int radix, String name, short defaultValue)获取指定的参数short值, 没有返回默认short值shortgetShortParameter(String name, int defaultValue)获取指定的参数short值, 没有返回默认short值shortgetShortParameter(String name, short defaultValue)获取指定的参数short值, 没有返回默认short值protected HttpRequestinitWebRequest(WebRequest req, boolean needPath)voidinvalidateSession()使sessionid失效protected booleanisChunked()protected booleanisExpect()booleanisMultipart()是否上传文件请求protected booleanisWebSocket()Iterable<MultiPart>multiParts()获取文件上传信息列表protected intpipelineHeaderLength()protected voidprepare()protected intreadHeader(ByteBuffer buf, int pipelineHeaderLength)返回值:Integer.MIN_VALUE: 帧数据; -1:数据不合法; 0:解析完毕; >0: 需再读取的字节数。protected intreadMethodUriLine(ByteBuffer buf)protected voidrecycle()protected HttpRequestremoveHeader(String name)protected HttpRequestremoveParameter(String name)protected voidsetAnnotations(Annotation[] annotations)<T extends Serializable>
HttpRequestsetCurrentUserid(T userid)设置当前用户ID, 通常在HttpServlet.preExecute方法里设置currentUserid
数据类型只能是int、long、String、JavaBeanHttpRequestsetCurrentUserSupplier(Supplier supplier)建议使用 setCurrentUserid, 通过userid从Service或缓存中获取用户信息
设置当前用户信息, 通常在HttpServlet.preExecute方法里设置currentUser
数据类型由@HttpUserType指定protected HttpRequestsetHeader(String name, String value)protected voidsetKeepAlive(boolean keepAlive)protected HttpRequestsetLocale(String locale)protected HttpRequestsetMethod(String method)protected HttpRequestsetParameter(String name, String value)protected HttpRequestsetRemoteAddr(String remoteAddr)protected HttpRequestsetRequestPath(String path)protected voidskipBodyParse()protected static StringtoDecodeString(ByteArray bytes, int offset, int len, Charset charset)StringtoString()protected voidunzipEncoding()protected voidupdateBody(byte[] body)-
从类继承的方法 org.redkale.net.Request
getAnnotation, getAnnotations, getAnnotationsByType, getAttribute, getAttributes, getContext, getCreatetime, getCreateTime, getSubobject, getSubobjectIfAbsent, getSubobjects, getTraceid, isKeepAlive, newInputStream, pipeline, removeAttribute, removeSubobject, setAttribute, setSubobject, traceid
-
-
-
-
字段详细资料
-
CURRUSERID_NIL
protected static final Serializable CURRUSERID_NIL
-
READ_STATE_ROUTE
protected static final int READ_STATE_ROUTE
- 另请参阅:
- 常量字段值
-
READ_STATE_HEADER
protected static final int READ_STATE_HEADER
- 另请参阅:
- 常量字段值
-
READ_STATE_BODY
protected static final int READ_STATE_BODY
- 另请参阅:
- 常量字段值
-
READ_STATE_END
protected static final int READ_STATE_END
- 另请参阅:
- 常量字段值
-
EMPTY_BYTES
protected static final byte[] EMPTY_BYTES
-
MAX_CHUNK_HEADER_SIZE
protected static final int MAX_CHUNK_HEADER_SIZE
- 另请参阅:
- 常量字段值
-
headerLength
protected int headerLength
-
headerHalfLen
protected int headerHalfLen
-
contentType
protected String contentType
-
contentLength
protected long contentLength
-
contentEncoding
protected String contentEncoding
-
host
protected String host
-
cookie
@Comment("\u539f\u59cb\u7684cookie\u5b57\u7b26\u4e32\uff0c\u89e3\u6790\u540e\u503c\u8d4b\u7ed9HttpCookie[] cookies") protected String cookie
-
cookies
protected HttpCookie[] cookies
-
chunked
protected boolean chunked
-
chunkedCR
protected boolean chunkedCR
-
chunkedLength
protected int chunkedLength
-
chunkedCurrOffset
protected int chunkedCurrOffset
-
chunkedHalfLenBytes
protected byte[] chunkedHalfLenBytes
-
rpc
protected boolean rpc
-
readState
protected int readState
-
currentUserid
protected Serializable currentUserid
-
currentUserSupplier
protected Supplier<Serializable> currentUserSupplier
-
reqConvertType
protected ConvertType reqConvertType
-
reqConvert
protected Convert reqConvert
-
respConvertType
protected ConvertType respConvertType
-
respConvert
protected Convert respConvert
-
headers
protected final HttpHeaders headers
-
getmethod
protected boolean getmethod
-
protocol
protected String protocol
-
requestPath
protected String requestPath
-
queryBytes
protected byte[] queryBytes
-
newSessionid
protected String newSessionid
-
params
protected final HttpParameters params
-
boundary
protected boolean boundary
-
moduleid
protected int moduleid
-
actionid
protected int actionid
-
remoteAddr
protected String remoteAddr
-
locale
protected String locale
-
-
构造器详细资料
-
HttpRequest
public HttpRequest(HttpContext context)
-
HttpRequest
protected HttpRequest(HttpContext context, ByteArray headerBytes, ByteArray bodyBytes)
-
HttpRequest
protected HttpRequest(HttpContext context, WebRequest req)
-
-
方法详细资料
-
initWebRequest
protected HttpRequest initWebRequest(WebRequest req, boolean needPath)
-
createSimpleRequest
public WebRequest createSimpleRequest(String contextPath)
-
isWebSocket
protected boolean isWebSocket()
-
isExpect
protected boolean isExpect()
-
isChunked
protected boolean isChunked()
-
setKeepAlive
protected void setKeepAlive(boolean keepAlive)
-
setAnnotations
protected void setAnnotations(Annotation[] annotations)
-
getRespConvertType
protected ConvertType getRespConvertType()
-
getRespConvert
protected Convert getRespConvert()
-
pipelineHeaderLength
protected int pipelineHeaderLength()
- 覆盖:
pipelineHeaderLength在类中Request<HttpContext>
-
readHeader
protected int readHeader(ByteBuffer buf, int pipelineHeaderLength)
从类复制的说明:Request返回值:Integer.MIN_VALUE: 帧数据; -1:数据不合法; 0:解析完毕; >0: 需再读取的字节数。- 指定者:
readHeader在类中Request<HttpContext>- 参数:
buf- ByteBuffer对象pipelineHeaderLength- 同一Channel的pipelien模式下上一个Request的header长度- 返回:
- 缺少的字节数
-
readMethodUriLine
protected int readMethodUriLine(ByteBuffer buf)
-
getRequestid
protected final Serializable getRequestid()
- 指定者:
getRequestid在类中Request<HttpContext>
-
prepare
protected void prepare()
- 指定者:
prepare在类中Request<HttpContext>
-
recycle
protected void recycle()
- 覆盖:
recycle在类中Request<HttpContext>
-
skipBodyParse
protected void skipBodyParse()
-
array
protected ByteArray array()
-
unzipEncoding
protected void unzipEncoding()
-
setMethod
protected HttpRequest setMethod(String method)
-
setRequestPath
protected HttpRequest setRequestPath(String path)
-
setRemoteAddr
protected HttpRequest setRemoteAddr(String remoteAddr)
-
setLocale
protected HttpRequest setLocale(String locale)
-
setParameter
protected HttpRequest setParameter(String name, String value)
-
setHeader
protected HttpRequest setHeader(String name, String value)
-
addHeader
protected HttpRequest addHeader(String name, String value)
-
removeParameter
protected HttpRequest removeParameter(String name)
-
removeHeader
protected HttpRequest removeHeader(String name)
-
toDecodeString
protected static String toDecodeString(ByteArray bytes, int offset, int len, Charset charset)
-
setCurrentUserid
public <T extends Serializable> HttpRequest setCurrentUserid(T userid)
设置当前用户ID, 通常在HttpServlet.preExecute方法里设置currentUserid
数据类型只能是int、long、String、JavaBean- 类型参数:
T- 泛型- 参数:
userid- 用户ID- 返回:
- HttpRequest
- 从以下版本开始:
- 2.1.0
-
currentIntUserid
@ClassDepends public int currentIntUserid()
获取当前用户ID的int值- 返回:
- 用户ID
- 从以下版本开始:
- 2.4.0
-
currentLongUserid
@ClassDepends public long currentLongUserid()
获取当前用户ID的long值- 返回:
- 用户ID
- 从以下版本开始:
- 2.7.0
-
currentStringUserid
@ClassDepends public String currentStringUserid()
获取当前用户ID的String值- 返回:
- 用户ID
- 从以下版本开始:
- 2.8.0
-
currentUserid
@ClassDepends public <T extends Serializable> T currentUserid(Class<T> type)
获取当前用户ID- 类型参数:
T- 数据类型只能是int、long、String、JavaBean- 参数:
type- 类型- 返回:
- 用户ID
- 从以下版本开始:
- 2.1.0
-
setCurrentUserSupplier
public HttpRequest setCurrentUserSupplier(Supplier supplier)
建议使用 setCurrentUserid, 通过userid从Service或缓存中获取用户信息
设置当前用户信息, 通常在HttpServlet.preExecute方法里设置currentUser
数据类型由@HttpUserType指定- 参数:
supplier- currentUser对象方法- 返回:
- HttpRequest
- 从以下版本开始:
- 2.4.0
-
currentUser
public <T> T currentUser()
建议使用 currentUserid, 通过userid从Service或缓存中获取用户信息
获取当前用户信息
数据类型由@HttpUserType指定- 类型参数:
T- @HttpUserType指定的用户信息类型- 返回:
- 用户信息
-
getModuleid
public int getModuleid()
获取模块ID,来自@HttpServlet.moduleid()- 返回:
- 模块ID
-
getActionid
public int getActionid()
获取操作ID,来自@HttpMapping.actionid()- 返回:
- 模块ID
-
getRemoteAddress
public SocketAddress getRemoteAddress()
获取客户端地址IP- 返回:
- 地址
-
getRemoteAddr
public String getRemoteAddr()
获取客户端地址IP, 与getRemoteAddress() 的区别在于:本方法优先取header中指定为RemoteAddress名的值, 没有则返回getRemoteAddress()的getHostAddress()。
本方法适用于服务前端有如nginx的代理服务器进行中转,通过getRemoteAddress()是获取不到客户端的真实IP。- 返回:
- 地址
-
getLocale
public String getLocale()
获取国际化Locale,值可以取之于header或parameter- 返回:
- 国际化Locale
-
getBodyUTF8
public String getBodyUTF8()
获取请求内容的UTF-8编码字符串- 返回:
- 内容
-
getBodyJson
public <T> T getBodyJson(Type type)
获取请求内容的JavaBean对象- 类型参数:
T- 泛型- 参数:
type- 类型- 返回:
- 内容
-
getBodyJson
public <T> T getBodyJson(Convert convert, Type type)
获取请求内容的JavaBean对象- 类型参数:
T- 泛型- 参数:
convert- Converttype- 类型- 返回:
- 内容
-
getBody
public byte[] getBody()
获取请求内容的byte[]- 返回:
- 内容
-
getDirectBody
protected ByteArray getDirectBody()
直接获取body对象- 返回:
- body对象
-
updateBody
protected void updateBody(byte[] body)
-
getMultiContext
public final MultiContext getMultiContext()
获取文件上传对象- 返回:
- 文件上传对象
-
isMultipart
public final boolean isMultipart()
是否上传文件请求- 返回:
- boolean
-
multiParts
public final Iterable<MultiPart> multiParts() throws IOException
获取文件上传信息列表- 返回:
- 文件上传对象集合
- 抛出:
IOException- IO异常
-
getSessionid
public String getSessionid(boolean autoCreate)
获取sessionid- 参数:
autoCreate- 无sessionid是否自动创建- 返回:
- sessionid
-
changeSessionid
public String changeSessionid()
更新sessionid- 返回:
- 新的sessionid值
-
changeSessionid
public String changeSessionid(String newSessionid)
指定值更新sessionid- 参数:
newSessionid- 新sessionid值- 返回:
- 新的sessionid值
-
invalidateSession
public void invalidateSession()
使sessionid失效
-
getCookies
public HttpCookie[] getCookies()
获取所有Cookie对象- 返回:
- cookie对象数组
-
getCookie
public String getCookie(String name, String dfvalue)
获取Cookie值, 没有返回默认值- 参数:
name- cookie名dfvalue- 默认cookie值- 返回:
- cookie值
-
getProtocol
public String getProtocol()
获取协议名 http、https、ws、wss等- 返回:
- protocol
-
getMethod
public String getMethod()
获取请求方法 GET、POST等- 返回:
- method
-
getContentType
public String getContentType()
获取Content-Type的header值- 返回:
- contentType
-
getContentLength
public long getContentLength()
获取请求内容的长度, 为-1表示内容长度不确定- 返回:
- 内容长度
-
getHost
public String getHost()
获取Host的Header值- 返回:
- Host
-
getRequestPath
public String getRequestPath()
获取请求的URL- 返回:
- 请求的URL
-
getQueryBytes
public byte[] getQueryBytes()
获取请求参数的byte[]- 返回:
- byte[]
-
getPathLastParam
public String getPathLastParam()
截取getRequestPath最后的一个/后面的部分- 返回:
- String
-
getPathLastParam
public short getPathLastParam(short defvalue)
获取请求URL最后的一个/后面的部分的short值
例如请求URL /pipes/user/query/2
获取type参数: short type = request.getPathLastParam((short)0); //type = 2- 参数:
defvalue- 默认short值- 返回:
- short值
-
getPathLastParam
public short getPathLastParam(int radix, short defvalue)获取请求URL最后的一个/后面的部分的short值
例如请求URL /pipes/user/query/2
获取type参数: short type = request.getPathLastParam(16, (short)0); //type = 2- 参数:
radix- 进制数defvalue- 默认short值- 返回:
- short值
-
getPathLastParam
public int getPathLastParam(int defvalue)
获取请求URL最后的一个/后面的部分的int值
例如请求URL /pipes/user/query/2
获取type参数: int type = request.getPathLastParam(0); //type = 2- 参数:
defvalue- 默认int值- 返回:
- int值
-
getPathLastParam
public int getPathLastParam(int radix, int defvalue)获取请求URL最后的一个/后面的部分的int值
例如请求URL /pipes/user/query/2
获取type参数: int type = request.getPathLastParam(16, 0); //type = 2- 参数:
radix- 进制数defvalue- 默认int值- 返回:
- int值
-
getPathLastParam
public float getPathLastParam(float defvalue)
获取请求URL最后的一个/后面的部分的float值
例如请求URL /pipes/user/query/2
获取type参数: float type = request.getPathLastParam(0.0f); //type = 2.0f- 参数:
defvalue- 默认float值- 返回:
- float值
-
getPathLastParam
public long getPathLastParam(long defvalue)
获取请求URL最后的一个/后面的部分的int值
例如请求URL /pipes/user/query/2
获取type参数: long type = request.getPathLastParam(0L); //type = 2- 参数:
defvalue- 默认long值- 返回:
- long值
-
getPathLastParam
public long getPathLastParam(int radix, long defvalue)获取请求URL最后的一个/后面的部分的int值
例如请求URL /pipes/user/query/2
获取type参数: long type = request.getPathLastParam(16, 0L); //type = 2- 参数:
radix- 进制数defvalue- 默认long值- 返回:
- long值
-
getPathLastParam
public double getPathLastParam(double defvalue)
获取请求URL最后的一个/后面的部分的double值
例如请求URL /pipes/user/query/2
获取type参数: double type = request.getPathLastParam(0.0); //type = 2.0- 参数:
defvalue- 默认double值- 返回:
- double值
-
getPathParams
public String[] getPathParams(String prefix)
从prefix之后截取getPath再对"/"进行分隔- 参数:
prefix- 前缀- 返回:
- String[]
-
getPathParam
public String getPathParam(String prefix, String defvalue)
获取请求URL分段中含prefix段的值
例如请求URL /pipes/user/query/name:hello
获取name参数: String name = request.getPathParam("name:", "none");- 参数:
prefix- prefix段前缀defvalue- 默认值- 返回:
- prefix截断后的值
-
getPathParam
public short getPathParam(String prefix, short defvalue)
获取请求URL分段中含prefix段的short值
例如请求URL /pipes/user/query/type:10
获取type参数: short type = request.getPathParam("type:", (short)0);- 参数:
prefix- prefix段前缀defvalue- 默认short值- 返回:
- short值
-
getPathParam
public short getPathParam(int radix, String prefix, short defvalue)获取请求URL分段中含prefix段的short值
例如请求URL /pipes/user/query/type:a
获取type参数: short type = request.getPathParam(16, "type:", (short)0); //type = 10- 参数:
radix- 进制数prefix- prefix段前缀defvalue- 默认short值- 返回:
- short值
-
getPathParam
public int getPathParam(String prefix, int defvalue)
获取请求URL分段中含prefix段的int值
例如请求URL /pipes/user/query/offset:0/limit:50
获取offset参数: int offset = request.getPathParam("offset:", 0);
获取limit参数: int limit = request.getPathParam("limit:", 20);- 参数:
prefix- prefix段前缀defvalue- 默认int值- 返回:
- int值
-
getPathParam
public int getPathParam(int radix, String prefix, int defvalue)获取请求URL分段中含prefix段的int值
例如请求URL /pipes/user/query/offset:0/limit:50
获取offset参数: int offset = request.getPathParam("offset:", 0);
获取limit参数: int limit = request.getPathParam(16, "limit:", 20); // limit = 16- 参数:
radix- 进制数prefix- prefix段前缀defvalue- 默认int值- 返回:
- int值
-
getPathParam
public float getPathParam(String prefix, float defvalue)
获取请求URL分段中含prefix段的float值
例如请求URL /pipes/user/query/point:40.0
获取time参数: float point = request.getPathParam("point:", 0.0f);- 参数:
prefix- prefix段前缀defvalue- 默认float值- 返回:
- float值
-
getPathParam
public long getPathParam(String prefix, long defvalue)
获取请求URL分段中含prefix段的long值
例如请求URL /pipes/user/query/time:1453104341363/id:40
获取time参数: long time = request.getPathParam("time:", 0L);- 参数:
prefix- prefix段前缀defvalue- 默认long值- 返回:
- long值
-
getPathParam
public long getPathParam(int radix, String prefix, long defvalue)获取请求URL分段中含prefix段的long值
例如请求URL /pipes/user/query/time:1453104341363/id:40
获取time参数: long time = request.getPathParam(16, "time:", 0L);- 参数:
radix- 进制数prefix- prefix段前缀defvalue- 默认long值- 返回:
- long值
-
getPathParam
public double getPathParam(String prefix, double defvalue)
获取请求URL分段中含prefix段的double值
例如请求URL /pipes/user/query/point:40.0
获取time参数: double point = request.getPathParam("point:", 0.0);- 参数:
prefix- prefix段前缀defvalue- 默认double值- 返回:
- double值
-
getHeaders
@ClassDepends public HttpHeaders getHeaders()
获取请求Header总对象- 返回:
- AnyValue
-
getHeaderNames
public String[] getHeaderNames()
获取所有的header名- 返回:
- header名数组
-
getHeader
@ClassDepends public String getHeader(String name, String defaultValue)
获取指定的header值, 没有返回默认值- 参数:
name- header名defaultValue- 默认值- 返回:
- header值
-
getJsonHeader
@ClassDepends public <T> T getJsonHeader(Type type, String name)
获取指定的header的json值- 类型参数:
T- 泛型- 参数:
type- 反序列化的类名name- header名- 返回:
- header值
-
getJsonHeader
@ClassDepends public <T> T getJsonHeader(JsonConvert convert, Type type, String name)
获取指定的header的json值- 类型参数:
T- 泛型- 参数:
convert- JsonConvert对象type- 反序列化的类名name- header名- 返回:
- header值
-
getBooleanHeader
@ClassDepends public boolean getBooleanHeader(String name, boolean defaultValue)
获取指定的header的boolean值, 没有返回默认boolean值- 参数:
name- header名defaultValue- 默认boolean值- 返回:
- header值
-
getShortHeader
@ClassDepends public short getShortHeader(String name, short defaultValue)
获取指定的header的short值, 没有返回默认short值- 参数:
name- header名defaultValue- 默认short值- 返回:
- header值
-
getShortHeader
@ClassDepends public short getShortHeader(int radix, String name, short defaultValue)
获取指定的header的short值, 没有返回默认short值- 参数:
radix- 进制数name- header名defaultValue- 默认short值- 返回:
- header值
-
getShortHeader
@ClassDepends public short getShortHeader(String name, int defaultValue)
获取指定的header的short值, 没有返回默认short值- 参数:
name- header名defaultValue- 默认short值- 返回:
- header值
-
getShortHeader
@ClassDepends public short getShortHeader(int radix, String name, int defaultValue)
获取指定的header的short值, 没有返回默认short值- 参数:
radix- 进制数name- header名defaultValue- 默认short值- 返回:
- header值
-
getIntHeader
@ClassDepends public int getIntHeader(String name, int defaultValue)
获取指定的header的int值, 没有返回默认int值- 参数:
name- header名defaultValue- 默认int值- 返回:
- header值
-
getIntHeader
@ClassDepends public int getIntHeader(int radix, String name, int defaultValue)
获取指定的header的int值, 没有返回默认int值- 参数:
radix- 进制数name- header名defaultValue- 默认int值- 返回:
- header值
-
getLongHeader
@ClassDepends public long getLongHeader(String name, long defaultValue)
获取指定的header的long值, 没有返回默认long值- 参数:
name- header名defaultValue- 默认long值- 返回:
- header值
-
getLongHeader
@ClassDepends public long getLongHeader(int radix, String name, long defaultValue)
获取指定的header的long值, 没有返回默认long值- 参数:
radix- 进制数name- header名defaultValue- 默认long值- 返回:
- header值
-
getFloatHeader
@ClassDepends public float getFloatHeader(String name, float defaultValue)
获取指定的header的float值, 没有返回默认float值- 参数:
name- header名defaultValue- 默认float值- 返回:
- header值
-
getDoubleHeader
@ClassDepends public double getDoubleHeader(String name, double defaultValue)
获取指定的header的double值, 没有返回默认double值- 参数:
name- header名defaultValue- 默认double值- 返回:
- header值
-
getParameters
@ClassDepends public HttpParameters getParameters()
获取请求参数总对象- 返回:
- AnyValue
-
getParametersToString
public String getParametersToString()
将请求参数转换成String, 字符串格式为: bean1={}&id=13&name=xxx
不会返回null,没有参数返回空字符串- 返回:
- String
-
getParametersToString
public String getParametersToString(String prefix)
将请求参数转换成String, 字符串格式为: bean1={}&id=13&name=xxx
不会返回null,没有参数返回空字符串- 参数:
prefix- 拼接前缀, 如果无参数,返回的字符串不会含有拼接前缀- 返回:
- String
-
getParameterNames
public String[] getParameterNames()
获取所有参数名- 返回:
- 参数名数组
-
getParameter
public String getParameter(String name, String defaultValue)
获取指定的参数值, 没有返回默认值- 参数:
name- 参数名defaultValue- 默认值- 返回:
- 参数值
-
getJsonParameter
public <T> T getJsonParameter(Type type, String name)
获取指定的参数json值- 类型参数:
T- 泛型- 参数:
type- 反序列化的类名name- 参数名- 返回:
- 参数值
-
getJsonParameter
public <T> T getJsonParameter(JsonConvert convert, Type type, String name)
获取指定的参数json值- 类型参数:
T- 泛型- 参数:
convert- JsonConvert对象type- 反序列化的类名name- 参数名- 返回:
- 参数值
-
getBooleanParameter
public boolean getBooleanParameter(String name, boolean defaultValue)
获取指定的参数boolean值, 没有返回默认boolean值- 参数:
name- 参数名defaultValue- 默认boolean值- 返回:
- 参数值
-
getShortParameter
public short getShortParameter(String name, short defaultValue)
获取指定的参数short值, 没有返回默认short值- 参数:
name- 参数名defaultValue- 默认short值- 返回:
- 参数值
-
getShortParameter
public short getShortParameter(int radix, String name, short defaultValue)获取指定的参数short值, 没有返回默认short值- 参数:
radix- 进制数name- 参数名defaultValue- 默认short值- 返回:
- 参数值
-
getShortParameter
public short getShortParameter(String name, int defaultValue)
获取指定的参数short值, 没有返回默认short值- 参数:
name- 参数名defaultValue- 默认short值- 返回:
- 参数值
-
getIntParameter
public int getIntParameter(String name, int defaultValue)
获取指定的参数int值, 没有返回默认int值- 参数:
name- 参数名defaultValue- 默认int值- 返回:
- 参数值
-
getIntParameter
public int getIntParameter(int radix, String name, int defaultValue)获取指定的参数int值, 没有返回默认int值- 参数:
radix- 进制数name- 参数名defaultValue- 默认int值- 返回:
- 参数值
-
getLongParameter
public long getLongParameter(String name, long defaultValue)
获取指定的参数long值, 没有返回默认long值- 参数:
name- 参数名defaultValue- 默认long值- 返回:
- 参数值
-
getLongParameter
public long getLongParameter(int radix, String name, long defaultValue)获取指定的参数long值, 没有返回默认long值- 参数:
radix- 进制数name- 参数名defaultValue- 默认long值- 返回:
- 参数值
-
getFloatParameter
public float getFloatParameter(String name, float defaultValue)
获取指定的参数float值, 没有返回默认float值- 参数:
name- 参数名defaultValue- 默认float值- 返回:
- 参数值
-
getDoubleParameter
public double getDoubleParameter(String name, double defaultValue)
获取指定的参数double值, 没有返回默认double值- 参数:
name- 参数名defaultValue- 默认double值- 返回:
- 参数值
-
getFlipper
@ClassDepends public Flipper getFlipper()
获取翻页对象 同 getFlipper("flipper", false, 0);- 返回:
- Flipper翻页对象
-
getFlipper
public Flipper getFlipper(boolean autoCreate)
获取翻页对象 同 getFlipper("flipper", autoCreate, 0);- 参数:
autoCreate- 无参数时是否创建新Flipper对象- 返回:
- Flipper翻页对象
-
getFlipper
public Flipper getFlipper(int maxLimit)
获取翻页对象 同 getFlipper("flipper", false, maxLimit);- 参数:
maxLimit- 最大行数, 小于1则值为Flipper.DEFAULT_LIMIT- 返回:
- Flipper翻页对象
-
getFlipper
public Flipper getFlipper(boolean autoCreate, int maxLimit)
获取翻页对象 同 getFlipper("flipper", autoCreate, maxLimit)- 参数:
autoCreate- 无参数时是否创建新Flipper对象maxLimit- 最大行数, 小于1则值为Flipper.DEFAULT_LIMIT- 返回:
- Flipper翻页对象
-
getFlipper
public Flipper getFlipper(String name, boolean autoCreate, int maxLimit)
获取翻页对象 https://redkale.org/pipes/users/list?flipper={'offset':0,'limit':20, 'sort':'createtime ASC'}- 参数:
name- Flipper对象的参数名,默认为 "flipper"autoCreate- 无参数时是否创建新Flipper对象maxLimit- 最大行数, 小于1则值为Flipper.DEFAULT_LIMIT- 返回:
- Flipper翻页对象
-
-