/**
* Method to easily create a request.
* @param httpMethod the {@link HttpMethod} desired.
* @param uri string representation of the desired URI.
* @param headers any associated headers as a {@link HttpHeaders} object. Can be null.
* @param content the content that accompanies the request. Can be null.
* @return A {@link FullHttpRequest} object that defines the request required by the input.
*/
private FullHttpRequest buildRequest(HttpMethod httpMethod, String uri, HttpHeaders headers, ByteBuffer content) {
ByteBuf contentBuf;
if (content != null) {
contentBuf = Unpooled.wrappedBuffer(content);
} else {
contentBuf = Unpooled.buffer(0);
}
FullHttpRequest httpRequest = new DefaultFullHttpRequest(HttpVersion.HTTP_1_1, httpMethod, uri, contentBuf);
if (headers != null) {
httpRequest.headers().set(headers);
}
if (HttpMethod.POST.equals(httpMethod) && !HttpUtil.isContentLengthSet(httpRequest)) {
HttpUtil.setTransferEncodingChunked(httpRequest, true);
}
return httpRequest;
}
FrontendIntegrationTest.java 文件源码
java
阅读 34
收藏 0
点赞 0
评论 0
项目:ambry
作者:
评论列表
文章目录