This commit is contained in:
@@ -41,6 +41,8 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
|
||||
protected boolean rpc;
|
||||
|
||||
protected Convert currConvert;
|
||||
|
||||
@Comment("Method GET/POST/...")
|
||||
protected String method;
|
||||
|
||||
@@ -161,8 +163,8 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
protected JsonConvert getJsonConvert() {
|
||||
return this.jsonConvert;
|
||||
protected Convert getCurrConvert() {
|
||||
return this.currConvert == null ? this.jsonConvert : this.currConvert;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -567,7 +569,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
public <T> T getBodyJson(Convert convert, java.lang.reflect.Type type) {
|
||||
if (array.size() < 1) return null;
|
||||
return (T) convert.convertFrom(type, array.directBytes());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取请求内容的byte[]
|
||||
@@ -662,6 +664,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
this.remoteAddr = null;
|
||||
|
||||
this.attachment = null;
|
||||
this.currConvert = jsonConvert;
|
||||
|
||||
this.headers.clear();
|
||||
this.params.clear();
|
||||
|
||||
@@ -315,7 +315,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
public void finishJson(final Object obj) {
|
||||
this.contentType = this.jsonContentType;
|
||||
if (this.recycleListener != null) this.output = obj;
|
||||
finish(request.getJsonConvert().convertTo(getBodyBufferSupplier(), obj));
|
||||
finish(request.getCurrConvert().convertTo(getBodyBufferSupplier(), obj));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -327,7 +327,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
public void finishMapJson(final Object... objs) {
|
||||
this.contentType = this.jsonContentType;
|
||||
if (this.recycleListener != null) this.output = objs;
|
||||
finish(request.getJsonConvert().convertMapTo(getBodyBufferSupplier(), objs));
|
||||
finish(request.getCurrConvert().convertMapTo(getBodyBufferSupplier(), objs));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -364,7 +364,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
public void finishJson(final Type type, final Object obj) {
|
||||
this.contentType = this.jsonContentType;
|
||||
this.output = obj;
|
||||
finish(request.getJsonConvert().convertTo(getBodyBufferSupplier(), type, obj));
|
||||
finish(request.getCurrConvert().convertTo(getBodyBufferSupplier(), type, obj));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -388,7 +388,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
public void finishJson(final Object... objs) {
|
||||
this.contentType = this.jsonContentType;
|
||||
if (this.recycleListener != null) this.output = objs;
|
||||
finish(request.getJsonConvert().convertTo(getBodyBufferSupplier(), objs));
|
||||
finish(request.getCurrConvert().convertTo(getBodyBufferSupplier(), objs));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -407,7 +407,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
this.header.addValue("retinfo", ret.getRetinfo());
|
||||
}
|
||||
Convert convert = ret == null ? null : ret.convert();
|
||||
if (convert == null) convert = request.getJsonConvert();
|
||||
if (convert == null) convert = request.getCurrConvert();
|
||||
finish(convert.convertTo(getBodyBufferSupplier(), ret));
|
||||
}
|
||||
|
||||
@@ -456,7 +456,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
* @param future 输出对象的句柄
|
||||
*/
|
||||
public void finishJson(final CompletableFuture future) {
|
||||
finish(request.getJsonConvert(), (Type) null, future);
|
||||
finish(request.getCurrConvert(), (Type) null, future);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -489,7 +489,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void finish(final Object obj) {
|
||||
finish(request.getJsonConvert(), (Type) null, obj);
|
||||
finish(request.getCurrConvert(), (Type) null, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user