本文整理了Java中io.netty.handler.codec.http.HttpResponse.protocolVersion()
方法的一些代码示例,展示了HttpResponse.protocolVersion()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。HttpResponse.protocolVersion()
方法的具体详情如下:
包路径:io.netty.handler.codec.http.HttpResponse
类名称:HttpResponse
方法名:protocolVersion
暂无
代码示例来源:origin: AsyncHttpClient/async-http-client
@Override
public String getProtocolName() {
return response.protocolVersion().protocolName();
}
代码示例来源:origin: AsyncHttpClient/async-http-client
@Override
public int getProtocolMajorVersion() {
return response.protocolVersion().majorVersion();
}
代码示例来源:origin: AsyncHttpClient/async-http-client
@Override
public int getProtocolMinorVersion() {
return response.protocolVersion().minorVersion();
}
代码示例来源:origin: AsyncHttpClient/async-http-client
@Override
public String getProtocolText() {
return response.protocolVersion().text();
}
代码示例来源:origin: wildfly/wildfly
private static void appendInitialLine(StringBuilder buf, HttpResponse res) {
buf.append(res.protocolVersion());
buf.append(' ');
buf.append(res.status());
buf.append(StringUtil.NEWLINE);
}
代码示例来源:origin: eclipse-vertx/vert.x
private Throwable validateMessage(Object msg) {
if (msg instanceof HttpObject) {
HttpObject obj = (HttpObject) msg;
DecoderResult result = obj.decoderResult();
if (result.isFailure()) {
return result.cause();
} else if (obj instanceof HttpResponse) {
io.netty.handler.codec.http.HttpVersion version = ((HttpResponse) obj).protocolVersion();
if (version != io.netty.handler.codec.http.HttpVersion.HTTP_1_0 && version != io.netty.handler.codec.http.HttpVersion.HTTP_1_1) {
return new IllegalStateException("Unsupported HTTP version: " + version);
}
}
}
return null;
}
代码示例来源:origin: wildfly/wildfly
@Override
protected void encodeInitialLine(ByteBuf buf, HttpResponse response) throws Exception {
response.protocolVersion().encode(buf);
buf.writeByte(SP);
response.status().encode(buf);
ByteBufUtil.writeShortBE(buf, CRLF_SHORT);
}
代码示例来源:origin: eclipse-vertx/vert.x
return;
response = new DefaultFullHttpResponse(resp.protocolVersion(), status);
response.headers().add(resp.headers());
代码示例来源:origin: wildfly/wildfly
if (isPassthru(res.protocolVersion(), code, acceptEncoding)) {
if (isFull) {
out.add(ReferenceCountUtil.retain(res));
HttpResponse newRes = new DefaultHttpResponse(res.protocolVersion(), res.status());
newRes.headers().set(res.headers());
out.add(newRes);
代码示例来源:origin: wildfly/wildfly
} else if (message instanceof HttpResponse) {
copy = new DefaultHttpResponse(r.protocolVersion(), r.status());
} else {
throw new CodecException("Object of class " + message.getClass().getName() +
代码示例来源:origin: eclipse-vertx/vert.x
private HttpClientResponseImpl beginResponse(HttpResponse resp) {
HttpVersion version;
if (resp.protocolVersion() == io.netty.handler.codec.http.HttpVersion.HTTP_1_0) {
version = io.vertx.core.http.HttpVersion.HTTP_1_0;
} else {
io.netty.handler.codec.http.HttpVersion protocolVersion = resp.protocolVersion();
String requestConnectionHeader = request.headers().get(HttpHeaderNames.CONNECTION);
代码示例来源:origin: wildfly/wildfly
/**
* Create a new object to contain the response data.
*
* @param streamId The stream associated with the response
* @param http2Headers The initial set of HTTP/2 headers to create the response with
* @param validateHttpHeaders <ul>
* <li>{@code true} to validate HTTP headers in the http-codec</li>
* <li>{@code false} not to validate HTTP headers in the http-codec</li>
* </ul>
* @return A new response object which represents headers for a chunked response
* @throws Http2Exception see {@link #addHttp2ToHttpHeaders(int, Http2Headers,
* HttpHeaders, HttpVersion, boolean, boolean)}
*/
public static HttpResponse toHttpResponse(final int streamId,
final Http2Headers http2Headers,
final boolean validateHttpHeaders) throws Http2Exception {
final HttpResponseStatus status = parseStatus(http2Headers.status());
// HTTP/2 does not define a way to carry the version or reason phrase that is included in an
// HTTP/1.1 status line.
final HttpResponse msg = new DefaultHttpResponse(HttpVersion.HTTP_1_1, status, validateHttpHeaders);
try {
addHttp2ToHttpHeaders(streamId, http2Headers, msg.headers(), msg.protocolVersion(), false, true);
} catch (final Http2Exception e) {
throw e;
} catch (final Throwable t) {
throw streamError(streamId, PROTOCOL_ERROR, t, "HTTP/2 to HTTP/1.x headers conversion error");
}
return msg;
}
代码示例来源:origin: wildfly/wildfly
@Override
protected void encodeInitialLine(final ByteBuf buf, final HttpMessage message)
throws Exception {
if (message instanceof HttpRequest) {
HttpRequest request = (HttpRequest) message;
ByteBufUtil.copy(request.method().asciiName(), buf);
buf.writeByte(SP);
buf.writeCharSequence(request.uri(), CharsetUtil.UTF_8);
buf.writeByte(SP);
buf.writeCharSequence(request.protocolVersion().toString(), CharsetUtil.US_ASCII);
ByteBufUtil.writeShortBE(buf, CRLF_SHORT);
} else if (message instanceof HttpResponse) {
HttpResponse response = (HttpResponse) message;
buf.writeCharSequence(response.protocolVersion().toString(), CharsetUtil.US_ASCII);
buf.writeByte(SP);
ByteBufUtil.copy(response.status().codeAsText(), buf);
buf.writeByte(SP);
buf.writeCharSequence(response.status().reasonPhrase(), CharsetUtil.US_ASCII);
ByteBufUtil.writeShortBE(buf, CRLF_SHORT);
} else {
throw new UnsupportedMessageTypeException("Unsupported type "
+ StringUtil.simpleClassName(message));
}
}
}
代码示例来源:origin: wildfly/wildfly
frameHeaders.set(SpdyHeaders.HttpNames.VERSION, httpResponse.protocolVersion().text());
代码示例来源:origin: io.vertx/vertx-core
private Throwable validateMessage(Object msg) {
if (msg instanceof HttpObject) {
HttpObject obj = (HttpObject) msg;
DecoderResult result = obj.decoderResult();
if (result.isFailure()) {
return result.cause();
} else if (obj instanceof HttpResponse) {
io.netty.handler.codec.http.HttpVersion version = ((HttpResponse) obj).protocolVersion();
if (version != io.netty.handler.codec.http.HttpVersion.HTTP_1_0 && version != io.netty.handler.codec.http.HttpVersion.HTTP_1_1) {
return new IllegalStateException("Unsupported HTTP version: " + version);
}
}
}
return null;
}
代码示例来源:origin: io.vertx/vertx-core
return;
response = new DefaultFullHttpResponse(resp.protocolVersion(), status);
response.headers().add(resp.headers());
代码示例来源:origin: io.vertx/vertx-core
private HttpClientResponseImpl beginResponse(HttpResponse resp) {
HttpVersion version;
if (resp.protocolVersion() == io.netty.handler.codec.http.HttpVersion.HTTP_1_0) {
version = io.vertx.core.http.HttpVersion.HTTP_1_0;
} else {
io.netty.handler.codec.http.HttpVersion protocolVersion = resp.protocolVersion();
String requestConnectionHeader = request.headers().get(HttpHeaderNames.CONNECTION);
代码示例来源:origin: org.apache.activemq/artemis-jms-client-all
private static void appendInitialLine(StringBuilder buf, HttpResponse res) {
buf.append(res.protocolVersion());
buf.append(' ');
buf.append(res.status());
buf.append(StringUtil.NEWLINE);
}
代码示例来源:origin: io.netty/netty-codec-http
private static void appendInitialLine(StringBuilder buf, HttpResponse res) {
buf.append(res.protocolVersion());
buf.append(' ');
buf.append(res.status());
buf.append(StringUtil.NEWLINE);
}
代码示例来源:origin: io.netty/netty-codec-http
@Override
protected void encodeInitialLine(ByteBuf buf, HttpResponse response) throws Exception {
response.protocolVersion().encode(buf);
buf.writeByte(SP);
response.status().encode(buf);
ByteBufUtil.writeShortBE(buf, CRLF_SHORT);
}
内容来源于网络,如有侵权,请联系作者删除!