This commit is contained in:
@@ -41,7 +41,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
|
||||
protected boolean rpc;
|
||||
|
||||
protected Convert currConvert;
|
||||
protected Convert respConvert;
|
||||
|
||||
@Comment("Method GET/POST/...")
|
||||
protected String method;
|
||||
@@ -163,8 +163,8 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
protected Convert getCurrConvert() {
|
||||
return this.currConvert == null ? this.jsonConvert : this.currConvert;
|
||||
protected Convert getRespConvert() {
|
||||
return this.respConvert == null ? this.jsonConvert : this.respConvert;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -216,6 +216,9 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
case "content-length":
|
||||
this.contentLength = Long.decode(value);
|
||||
break;
|
||||
case "convert-type": //redkale特有的
|
||||
respConvert = ConvertFactory.findConvert(ConvertType.valueOf(value));
|
||||
break;
|
||||
case "Host":
|
||||
case "host":
|
||||
this.host = value;
|
||||
@@ -664,7 +667,7 @@ public class HttpRequest extends Request<HttpContext> {
|
||||
this.remoteAddr = null;
|
||||
|
||||
this.attachment = null;
|
||||
this.currConvert = jsonConvert;
|
||||
this.respConvert = 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.getCurrConvert().convertTo(getBodyBufferSupplier(), obj));
|
||||
finish(request.getRespConvert().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.getCurrConvert().convertMapTo(getBodyBufferSupplier(), objs));
|
||||
finish(request.getRespConvert().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.getCurrConvert().convertTo(getBodyBufferSupplier(), type, obj));
|
||||
finish(request.getRespConvert().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.getCurrConvert().convertTo(getBodyBufferSupplier(), objs));
|
||||
finish(request.getRespConvert().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.getCurrConvert();
|
||||
if (convert == null) convert = request.getRespConvert();
|
||||
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.getCurrConvert(), (Type) null, future);
|
||||
finish(request.getRespConvert(), (Type) null, future);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -489,7 +489,7 @@ public class HttpResponse extends Response<HttpContext, HttpRequest> {
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public void finish(final Object obj) {
|
||||
finish(request.getCurrConvert(), (Type) null, obj);
|
||||
finish(request.getRespConvert(), (Type) null, obj);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user