This commit is contained in:
@@ -32,11 +32,12 @@ public class HttpSimpleRequestCoder implements MessageCoder<HttpSimpleRequest> {
|
|||||||
byte[] requestURI = MessageCoder.getBytes(data.getRequestURI()); //long-string
|
byte[] requestURI = MessageCoder.getBytes(data.getRequestURI()); //long-string
|
||||||
byte[] remoteAddr = MessageCoder.getBytes(data.getRemoteAddr());//short-string
|
byte[] remoteAddr = MessageCoder.getBytes(data.getRemoteAddr());//short-string
|
||||||
byte[] sessionid = MessageCoder.getBytes(data.getSessionid());//short-string
|
byte[] sessionid = MessageCoder.getBytes(data.getSessionid());//short-string
|
||||||
|
byte[] contentType = MessageCoder.getBytes(data.getContentType());//short-string
|
||||||
byte[] headers = MessageCoder.getBytes(data.getHeaders());
|
byte[] headers = MessageCoder.getBytes(data.getHeaders());
|
||||||
byte[] params = MessageCoder.getBytes(data.getParams());
|
byte[] params = MessageCoder.getBytes(data.getParams());
|
||||||
byte[] body = MessageCoder.getBytes(data.getBody());
|
byte[] body = MessageCoder.getBytes(data.getBody());
|
||||||
int count = 4 + requestURI.length + 2 + remoteAddr.length + 2 + sessionid.length
|
int count = 4 + requestURI.length + 2 + remoteAddr.length + 2 + sessionid.length
|
||||||
+ headers.length + params.length + 4 + body.length;
|
+ 2 + contentType.length + headers.length + params.length + 4 + body.length;
|
||||||
byte[] bs = new byte[count];
|
byte[] bs = new byte[count];
|
||||||
ByteBuffer buffer = ByteBuffer.wrap(bs);
|
ByteBuffer buffer = ByteBuffer.wrap(bs);
|
||||||
buffer.putInt(requestURI.length);
|
buffer.putInt(requestURI.length);
|
||||||
@@ -45,6 +46,8 @@ public class HttpSimpleRequestCoder implements MessageCoder<HttpSimpleRequest> {
|
|||||||
if (remoteAddr.length > 0) buffer.put(remoteAddr);
|
if (remoteAddr.length > 0) buffer.put(remoteAddr);
|
||||||
buffer.putChar((char) sessionid.length);
|
buffer.putChar((char) sessionid.length);
|
||||||
if (sessionid.length > 0) buffer.put(sessionid);
|
if (sessionid.length > 0) buffer.put(sessionid);
|
||||||
|
buffer.putChar((char) contentType.length);
|
||||||
|
if (contentType.length > 0) buffer.put(contentType);
|
||||||
buffer.put(headers);
|
buffer.put(headers);
|
||||||
buffer.put(params);
|
buffer.put(params);
|
||||||
buffer.putInt(body.length);
|
buffer.putInt(body.length);
|
||||||
@@ -60,6 +63,7 @@ public class HttpSimpleRequestCoder implements MessageCoder<HttpSimpleRequest> {
|
|||||||
req.setRequestURI(MessageCoder.getLongString(buffer));
|
req.setRequestURI(MessageCoder.getLongString(buffer));
|
||||||
req.setRemoteAddr(MessageCoder.getShortString(buffer));
|
req.setRemoteAddr(MessageCoder.getShortString(buffer));
|
||||||
req.setSessionid(MessageCoder.getShortString(buffer));
|
req.setSessionid(MessageCoder.getShortString(buffer));
|
||||||
|
req.setContentType(MessageCoder.getShortString(buffer));
|
||||||
req.setHeaders(MessageCoder.getMap(buffer));
|
req.setHeaders(MessageCoder.getMap(buffer));
|
||||||
req.setParams(MessageCoder.getMap(buffer));
|
req.setParams(MessageCoder.getMap(buffer));
|
||||||
int len = buffer.getInt();
|
int len = buffer.getInt();
|
||||||
|
|||||||
@@ -100,6 +100,7 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
if (req.getBody() != null) this.array.write(req.getBody());
|
if (req.getBody() != null) this.array.write(req.getBody());
|
||||||
if (req.getHeaders() != null) this.headers.putAll(req.getHeaders());
|
if (req.getHeaders() != null) this.headers.putAll(req.getHeaders());
|
||||||
if (req.getParams() != null) this.params.putAll(req.getParams());
|
if (req.getParams() != null) this.params.putAll(req.getParams());
|
||||||
|
this.contentType = req.getContentType();
|
||||||
this.remoteAddr = req.getRemoteAddr();
|
this.remoteAddr = req.getRemoteAddr();
|
||||||
this.requestURI = req.getRequestURI();
|
this.requestURI = req.getRequestURI();
|
||||||
if (req.getSessionid() != null && !req.getSessionid().isEmpty()) {
|
if (req.getSessionid() != null && !req.getSessionid().isEmpty()) {
|
||||||
@@ -114,6 +115,7 @@ public class HttpRequest extends Request<HttpContext> {
|
|||||||
req.setHeaders(headers.isEmpty() ? null : headers);
|
req.setHeaders(headers.isEmpty() ? null : headers);
|
||||||
req.setParams(params.isEmpty() ? null : params);
|
req.setParams(params.isEmpty() ? null : params);
|
||||||
req.setRemoteAddr(getRemoteAddr());
|
req.setRemoteAddr(getRemoteAddr());
|
||||||
|
req.setContentType(getContentType());
|
||||||
req.setRequestURI(this.requestURI);
|
req.setRequestURI(this.requestURI);
|
||||||
req.setSessionid(getSessionid(false));
|
req.setSessionid(getSessionid(false));
|
||||||
return req;
|
return req;
|
||||||
|
|||||||
@@ -35,14 +35,18 @@ public class HttpSimpleRequest implements java.io.Serializable {
|
|||||||
protected String sessionid;
|
protected String sessionid;
|
||||||
|
|
||||||
@ConvertColumn(index = 4)
|
@ConvertColumn(index = 4)
|
||||||
|
@Comment("Content-Type")
|
||||||
|
protected String contentType;
|
||||||
|
|
||||||
|
@ConvertColumn(index = 5)
|
||||||
@Comment("http header信息")
|
@Comment("http header信息")
|
||||||
protected Map<String, String> headers;
|
protected Map<String, String> headers;
|
||||||
|
|
||||||
@ConvertColumn(index = 5)
|
@ConvertColumn(index = 6)
|
||||||
@Comment("参数信息")
|
@Comment("参数信息")
|
||||||
protected Map<String, String> params;
|
protected Map<String, String> params;
|
||||||
|
|
||||||
@ConvertColumn(index = 6)
|
@ConvertColumn(index = 7)
|
||||||
@Comment("http body信息")
|
@Comment("http body信息")
|
||||||
protected byte[] body; //对应HttpRequest.array
|
protected byte[] body; //对应HttpRequest.array
|
||||||
|
|
||||||
@@ -61,6 +65,11 @@ public class HttpSimpleRequest implements java.io.Serializable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HttpSimpleRequest contentType(String contentType) {
|
||||||
|
this.contentType = contentType;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public HttpSimpleRequest headers(Map<String, String> headers) {
|
public HttpSimpleRequest headers(Map<String, String> headers) {
|
||||||
this.headers = headers;
|
this.headers = headers;
|
||||||
return this;
|
return this;
|
||||||
@@ -108,6 +117,11 @@ public class HttpSimpleRequest implements java.io.Serializable {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public HttpSimpleRequest clearContentType() {
|
||||||
|
this.contentType = null;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
public String getRequestURI() {
|
public String getRequestURI() {
|
||||||
return requestURI;
|
return requestURI;
|
||||||
}
|
}
|
||||||
@@ -132,6 +146,14 @@ public class HttpSimpleRequest implements java.io.Serializable {
|
|||||||
this.remoteAddr = remoteAddr;
|
this.remoteAddr = remoteAddr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getContentType() {
|
||||||
|
return contentType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setContentType(String contentType) {
|
||||||
|
this.contentType = contentType;
|
||||||
|
}
|
||||||
|
|
||||||
public Map<String, String> getHeaders() {
|
public Map<String, String> getHeaders() {
|
||||||
return headers;
|
return headers;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user