@JsonIgnore public String getBodyAsString() { if (body != null) { return body.toString(); } else { return null; } }
@JsonIgnore public byte[] getRawBytes() { return toString().getBytes(UTF_8); }
private ByteBuf getBody(HttpResponse response) { ByteBuf content = Unpooled.buffer(0, 0); Body body = response.getBody(); if (body != null) { Object bodyContents = body.getValue(); Charset bodyCharset = body.getCharset(ContentTypeMapper.getCharsetFromContentTypeHeader(response.getFirstHeader(CONTENT_TYPE.toString()))); if (bodyContents instanceof byte[]) { content = Unpooled.copiedBuffer((byte[]) bodyContents); } else if (bodyContents instanceof String) { content = Unpooled.copiedBuffer(((String) bodyContents).getBytes(bodyCharset)); } else if (body.toString() != null) { content = Unpooled.copiedBuffer(body.toString().getBytes(bodyCharset)); } } return content; }
private ByteBuf getBody(HttpRequest httpRequest) { ByteBuf content = Unpooled.buffer(0, 0); Body body = httpRequest.getBody(); if (body != null) { Object bodyContents = body.getValue(); Charset bodyCharset = body.getCharset(ContentTypeMapper.getCharsetFromContentTypeHeader(httpRequest.getFirstHeader(CONTENT_TYPE.toString()))); if (bodyContents instanceof byte[]) { content = Unpooled.copiedBuffer((byte[]) bodyContents); } else if (bodyContents instanceof String) { content = Unpooled.copiedBuffer(((String) bodyContents).getBytes(bodyCharset)); } else if (body.toString() != null) { content = Unpooled.copiedBuffer(body.toString().getBytes(bodyCharset)); } } return content; }
@JsonIgnore public String getBodyAsString() { if (body != null) { return body.toString(); } else { return null; } }
@JsonIgnore public byte[] getRawBytes() { return toString().getBytes(UTF_8); }
private ByteBuf getBody(HttpResponse response) { ByteBuf content = Unpooled.buffer(0, 0); Body body = response.getBody(); if (body != null) { Object bodyContents = body.getValue(); Charset bodyCharset = body.getCharset(ContentTypeMapper.getCharsetFromContentTypeHeader(response.getFirstHeader(CONTENT_TYPE.toString()))); if (bodyContents instanceof byte[]) { content = Unpooled.copiedBuffer((byte[]) bodyContents); } else if (bodyContents instanceof String) { content = Unpooled.copiedBuffer(((String) bodyContents).getBytes(bodyCharset)); } else if (body.toString() != null) { content = Unpooled.copiedBuffer(body.toString().getBytes(bodyCharset)); } } return content; }
private ByteBuf getBody(HttpRequest httpRequest) { ByteBuf content = Unpooled.buffer(0, 0); Body body = httpRequest.getBody(); if (body != null) { Object bodyContents = body.getValue(); Charset bodyCharset = body.getCharset(ContentTypeMapper.getCharsetFromContentTypeHeader(httpRequest.getFirstHeader(CONTENT_TYPE.toString()))); if (bodyContents instanceof byte[]) { content = Unpooled.copiedBuffer((byte[]) bodyContents); } else if (bodyContents instanceof String) { content = Unpooled.copiedBuffer(((String) bodyContents).getBytes(bodyCharset)); } else if (body.toString() != null) { content = Unpooled.copiedBuffer(body.toString().getBytes(bodyCharset)); } } return content; }