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; }
protocol = protocolString != null ? Protocol.get(protocolString) : Protocol.HTTP_1_1;
private static String protocols() { return Joiner.on(", ").join(Protocol.values()); }
/** * 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(); }
handshake = unverifiedHandshake; protocol = maybeProtocol != null ? Protocol.get(maybeProtocol) : Protocol.HTTP_1_1; success = true;
private static String protocols() { return Joiner.on(", ").join(Protocol.values()); }
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; }
handshake = unverifiedHandshake; protocol = maybeProtocol != null ? Protocol.get(maybeProtocol) : Protocol.HTTP_1_1; success = true;
/** * 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(); }
protocol = protocolString != null ? Protocol.get(protocolString) : Protocol.HTTP_1_1;
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 void run() throws Exception { ServerSocket serverSocket = new ServerSocket(8888); serverSocket.setReuseAddress(true); while (true) { Socket socket = null; try { socket = serverSocket.accept(); SSLSocket sslSocket = doSsl(socket); String protocolString = Platform.get().getSelectedProtocol(sslSocket); Protocol protocol = protocolString != null ? Protocol.get(protocolString) : null; if (protocol != Protocol.HTTP_2) { throw new ProtocolException("Protocol " + protocol + " unsupported"); } Http2Connection connection = new Http2Connection.Builder(false) .socket(sslSocket) .listener(this) .build(); connection.start(); } catch (IOException e) { logger.log(Level.INFO, "Http2Server connection failure: " + e); Util.closeQuietly(socket); } catch (Exception e) { logger.log(Level.WARNING, "Http2Server unexpected failure", e); Util.closeQuietly(socket); } } }
if (logger.isLoggable(Level.INFO)) { logger.info(MockWebServer.this + " received request: " + request + " and responded: " + response + " protocol is " + protocol.toString());
handshake = unverifiedHandshake; protocol = maybeProtocol != null ? Protocol.get(maybeProtocol) : Protocol.HTTP_1_1; success = true;
transaction.setProtocol(response.protocol().toString()); transaction.setResponseCode(response.code()); transaction.setResponseMessage(response.message());
handshake = unverifiedHandshake; protocol = maybeProtocol != null ? Protocol.get(maybeProtocol) : Protocol.HTTP_1_1; success = true;
@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; }
handshake = unverifiedHandshake; protocol = maybeProtocol != null ? Protocol.get(maybeProtocol) : Protocol.HTTP_1_1; success = true;
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; }
handshake = unverifiedHandshake; protocol = maybeProtocol != null ? Protocol.get(maybeProtocol) : Protocol.HTTP_1_1; success = true;