本文整理匯總了Java中io.netty.handler.codec.http.HttpRequest.getProtocolVersion方法的典型用法代碼示例。如果您正苦於以下問題:Java HttpRequest.getProtocolVersion方法的具體用法?Java HttpRequest.getProtocolVersion怎麽用?Java HttpRequest.getProtocolVersion使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類io.netty.handler.codec.http.HttpRequest
的用法示例。
在下文中一共展示了HttpRequest.getProtocolVersion方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: get
import io.netty.handler.codec.http.HttpRequest; //導入方法依賴的package包/類
@Override
public FullHttpResponse get(ChannelHandlerContext channelHandlerContext, QueryDecoder queryDecoder, PathProvider path, HttpRequest httpRequest) throws Exception
{
CloudNet.getLogger().debug("HTTP Request from " + channelHandlerContext.channel().remoteAddress());
StringBuilder stringBuilder = new StringBuilder();
try (InputStream inputStream = WebsiteDocumentation.class.getClassLoader().getResourceAsStream("files/api-doc.txt");
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream, StandardCharsets.UTF_8)))
{
String input;
while ((input = bufferedReader.readLine()) != null)
{
stringBuilder.append(input).append(System.lineSeparator());
}
}
String output = stringBuilder.substring(0);
ByteBuf byteBuf = Unpooled.wrappedBuffer(output.getBytes(StandardCharsets.UTF_8));
FullHttpResponse fullHttpResponse = new DefaultFullHttpResponse(httpRequest.getProtocolVersion(), HttpResponseStatus.OK, byteBuf);
fullHttpResponse.headers().set("Content-Type", "text/plain");
return fullHttpResponse;
}