public static List<String> alpnProtocolNames(List<Protocol> protocols) { List<String> names = new ArrayList<>(protocols.size()); for (int i = 0, size = protocols.size(); i < size; i++) { Protocol protocol = protocols.get(i); if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN. names.add(protocol.toString()); } return names; }
/** * Returns the concatenation of 8-bit, length prefixed protocol names. * http://tools.ietf.org/html/draft-agl-tls-nextprotoneg-04#page-4 */ static byte[] concatLengthPrefixed(List<Protocol> protocols) { Buffer result = new Buffer(); for (int i = 0, size = protocols.size(); i < size; i++) { Protocol protocol = protocols.get(i); if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN. result.writeByte(protocol.toString().length()); result.writeUtf8(protocol.toString()); } return result.readByteArray(); }
public static List<String> alpnProtocolNames(List<Protocol> protocols) { List<String> names = new ArrayList<>(protocols.size()); for (int i = 0, size = protocols.size(); i < size; i++) { Protocol protocol = protocols.get(i); if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN. names.add(protocol.toString()); } return names; }
/** * Returns the concatenation of 8-bit, length prefixed protocol names. * http://tools.ietf.org/html/draft-agl-tls-nextprotoneg-04#page-4 */ static byte[] concatLengthPrefixed(List<Protocol> protocols) { Buffer result = new Buffer(); for (int i = 0, size = protocols.size(); i < size; i++) { Protocol protocol = protocols.get(i); if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN. result.writeByte(protocol.toString().length()); result.writeUtf8(protocol.toString()); } return result.readByteArray(); }
private Headers getHeaders() throws IOException { if (responseHeaders == null) { Response response = getResponse(true); Headers headers = response.headers(); responseHeaders = headers.newBuilder() .add(SELECTED_PROTOCOL, response.protocol().toString()) .add(RESPONSE_SOURCE, responseSourceHeader(response)) .build(); } return responseHeaders; }
if (logger.isLoggable(Level.INFO)) { logger.info(MockWebServer.this + " received request: " + request + " and responded: " + response + " protocol is " + protocol.toString());
transaction.setProtocol(response.protocol().toString()); transaction.setResponseCode(response.code()); transaction.setResponseMessage(response.message());
@Override public HttpVersion getProtocol() { if (protocol == null) { String protocol = this.response.protocol().toString().split("/")[0]; boolean keepAlive = KEEP_ALIVE.equalsIgnoreCase(this.response .header("Connection")); if (this.response.protocol() == Protocol.HTTP_1_0) { return new HttpVersion(protocol, 1, 0, keepAlive); } else if (this.response.protocol() == Protocol.HTTP_1_1) { return new HttpVersion(protocol, 1, 1, keepAlive); } else if (this.response.protocol() == Protocol.HTTP_2) { return new HttpVersion(protocol, 2, 0, keepAlive); } else if (this.response.protocol() == Protocol.SPDY_3) { return new HttpVersion(protocol, 3, 0, keepAlive); } else { this.protocol = new HttpVersion(protocol, keepAlive); } } return protocol; }
public static List<String> alpnProtocolNames(List<Protocol> protocols) { List<String> names = new ArrayList<>(protocols.size()); for (int i = 0, size = protocols.size(); i < size; i++) { Protocol protocol = protocols.get(i); if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN. names.add(protocol.toString()); } return names; }
public static List<String> alpnProtocolNames(List<Protocol> protocols) { List<String> names = new ArrayList<>(protocols.size()); for (int i = 0, size = protocols.size(); i < size; i++) { Protocol protocol = protocols.get(i); if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN. names.add(protocol.toString()); } return names; }
@Override public String getProtocolVersion() { // see https://tools.ietf.org/html/rfc7230#section-2.6 return response.protocol().toString().toUpperCase(Locale.ROOT); }
/** * Returns the concatenation of 8-bit, length prefixed protocol names. * http://tools.ietf.org/html/draft-agl-tls-nextprotoneg-04#page-4 */ static byte[] concatLengthPrefixed(List<Protocol> protocols) { Buffer result = new Buffer(); for (int i = 0, size = protocols.size(); i < size; i++) { Protocol protocol = protocols.get(i); if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN. result.writeByte(protocol.toString().length()); result.writeUtf8(protocol.toString()); } return result.readByteArray(); } }
/** * Returns the concatenation of 8-bit, length prefixed protocol names. * http://tools.ietf.org/html/draft-agl-tls-nextprotoneg-04#page-4 */ static byte[] concatLengthPrefixed(List<Protocol> protocols) { Buffer result = new Buffer(); for (int i = 0, size = protocols.size(); i < size; i++) { Protocol protocol = protocols.get(i); if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN. result.writeByte(protocol.toString().length()); result.writeUtf8(protocol.toString()); } return result.readByteArray(); }
/** * Returns the concatenation of 8-bit, length prefixed protocol names. * http://tools.ietf.org/html/draft-agl-tls-nextprotoneg-04#page-4 */ static byte[] concatLengthPrefixed(List<Protocol> protocols) { Buffer result = new Buffer(); for (int i = 0, size = protocols.size(); i < size; i++) { Protocol protocol = protocols.get(i); if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN. result.writeByte(protocol.toString().length()); result.writeUtf8(protocol.toString()); } return result.readByteArray(); } }
/** * Returns the concatenation of 8-bit, length prefixed protocol names. * http://tools.ietf.org/html/draft-agl-tls-nextprotoneg-04#page-4 */ static byte[] concatLengthPrefixed(List<Protocol> protocols) { Buffer result = new Buffer(); for (int i = 0, size = protocols.size(); i < size; i++) { Protocol protocol = protocols.get(i); if (protocol == Protocol.HTTP_1_0) continue; // No HTTP/1.0 for ALPN. result.writeByte(protocol.toString().length()); result.writeUtf8(protocol.toString()); } return result.readByteArray(); }
@Override protected String protocol(Chain chain) { Connection connection = chain.connection(); Protocol protocol = connection != null ? connection.protocol() : Protocol.HTTP_1_1; return protocol.toString(); }
HermesResponse fromOkHttpResponse(Response response) throws IOException { return hermesResponse() .withHeaderSupplier(response::header) .withHttpStatus(response.code()) .withBody(response.body().string()) .withProtocol(response.protocol().toString()) .build(); } }
private Headers getHeaders() throws IOException { if (responseHeaders == null) { Response response = getResponse(true); Headers headers = response.headers(); responseHeaders = headers.newBuilder() .add(SELECTED_PROTOCOL, response.protocol().toString()) .add(RESPONSE_SOURCE, responseSourceHeader(response)) .build(); } return responseHeaders; }
private Headers getHeaders() throws IOException { if (responseHeaders == null) { Response response = getResponse(true); Headers headers = response.headers(); responseHeaders = headers.newBuilder() .add(SELECTED_PROTOCOL, response.protocol().toString()) .add(RESPONSE_SOURCE, responseSourceHeader(response)) .build(); } return responseHeaders; }
private Headers getHeaders() throws IOException { if (responseHeaders == null) { Response response = getResponse(true); Headers headers = response.headers(); responseHeaders = headers.newBuilder() .add(SELECTED_PROTOCOL, response.protocol().toString()) .add(RESPONSE_SOURCE, responseSourceHeader(response)) .build(); } return responseHeaders; }