void writeResponse(final MaybeReq req, final Channel ctx, final boolean isKeepAlive, final int code, final MediaType contentType, final byte[] content) { startResponse(respOrNull(req), ctx, code, isKeepAlive, contentType); writeContentLengthAndBody(req, ctx, content); }
@SuppressWarnings("unused") private void writeOnBufferAsJson(MaybeReq req, Channel ctx, int code, boolean isKeepAlive, Object value) { startResponse(respOrNull(req), ctx, code, isKeepAlive, MediaType.JSON); Buf output = ctx.output(); synchronized (output) { writeJsonBody(req, output.unwrap(), value); } }
void writeHttpResp(final MaybeReq req, final Channel ctx, final boolean isKeepAlive, int code, final MediaType contentType, final Object value) { Object result = value; Resp resp = respOrNull(req); if (resp != null) { if (resp.body() != null) { byte[] bytes = Msc.toBytes(resp.body()); writeResponse(req, ctx, isKeepAlive, code, contentType, bytes); return; } else if (resp.result() != null) { result = resp.result(); } } if (contentType == MediaType.JSON) { writeJsonResponse(req, resp, ctx, isKeepAlive, code, contentType, result); } else { byte[] bytes = Msc.toBytes(result); writeResponse(req, ctx, isKeepAlive, code, contentType, bytes); } }
void writeResponse(final MaybeReq req, final Channel ctx, final boolean isKeepAlive, final int code, final MediaType contentType, final byte[] content) { startResponse(respOrNull(req), ctx, code, isKeepAlive, contentType); writeContentLengthAndBody(req, ctx, content); }
@SuppressWarnings("unused") private void writeOnBufferAsJson(MaybeReq req, Channel ctx, int code, boolean isKeepAlive, Object value) { startResponse(respOrNull(req), ctx, code, isKeepAlive, MediaType.JSON); Buf output = ctx.output(); synchronized (output) { writeJsonBody(req, output.unwrap(), value); } }
void writeHttpResp(final MaybeReq req, final Channel ctx, final boolean isKeepAlive, int code, final MediaType contentType, final Object value) { Object result = value; Resp resp = respOrNull(req); if (resp != null) { if (resp.body() != null) { byte[] bytes = Msc.toBytes(resp.body()); writeResponse(req, ctx, isKeepAlive, code, contentType, bytes); return; } else if (resp.result() != null) { result = resp.result(); } } if (contentType == MediaType.JSON) { writeJsonResponse(req, resp, ctx, isKeepAlive, code, contentType, result); } else { byte[] bytes = Msc.toBytes(result); writeResponse(req, ctx, isKeepAlive, code, contentType, bytes); } }