Example usage for com.squareup.okhttp Protocol SPDY_3

List of usage examples for com.squareup.okhttp Protocol SPDY_3

Introduction

In this page you can find the example usage for com.squareup.okhttp Protocol SPDY_3.

Prototype

Protocol SPDY_3

To view the source code for com.squareup.okhttp Protocol SPDY_3.

Click Source Link

Document

Chromium's binary-framed protocol that includes header compression, multiplexing multiple requests on the same socket, and server-push.

Usage

From source file:co.paralleluniverse.fibers.okhttp.CallTest.java

License:Open Source License

@Test
public void canceledBeforeIOSignalsOnFailure_SPDY_3() throws Exception {
    enableProtocol(Protocol.SPDY_3);
    canceledBeforeIOSignalsOnFailure();
}

From source file:co.paralleluniverse.fibers.okhttp.CallTest.java

License:Open Source License

@Test
public void canceledBeforeResponseReadSignalsOnFailure_SPDY_3() throws Exception {
    enableProtocol(Protocol.SPDY_3);
    canceledBeforeResponseReadSignalsOnFailure();
}

From source file:co.paralleluniverse.fibers.okhttp.CallTest.java

License:Open Source License

@Test
public void canceledAfterResponseIsDeliveredBreaksStreamButSignalsOnce_SPDY_3() throws Exception {
    enableProtocol(Protocol.SPDY_3);
    canceledAfterResponseIsDeliveredBreaksStreamButSignalsOnce();
}

From source file:twitter4j.AlternativeHttpClientImpl.java

License:Apache License

private void prepareOkHttpClient() {
    if (okHttpClient == null) {
        okHttpClient = new OkHttpClient();

        //set protocols
        List<Protocol> protocols = new ArrayList<Protocol>();
        protocols.add(Protocol.HTTP_1_1);
        if (sPreferHttp2)
            protocols.add(Protocol.HTTP_2);
        if (sPreferSpdy)
            protocols.add(Protocol.SPDY_3);
        okHttpClient.setProtocols(protocols);

        //connectionPool setup
        okHttpClient.setConnectionPool(new ConnectionPool(MAX_CONNECTIONS, KEEP_ALIVE_DURATION_MS));

        //redirect disable
        okHttpClient.setFollowSslRedirects(false);

        //for proxy
        if (isProxyConfigured()) {
            if (CONF.getHttpProxyUser() != null && !CONF.getHttpProxyUser().equals("")) {
                if (logger.isDebugEnabled()) {
                    logger.debug("Proxy AuthUser: " + CONF.getHttpProxyUser());
                    logger.debug("Proxy AuthPassword: " + CONF.getHttpProxyPassword().replaceAll(".", "*"));
                }//from w  w w.j  a va  2 s  .c o  m
                Authenticator.setDefault(new Authenticator() {
                    @Override
                    protected PasswordAuthentication getPasswordAuthentication() {
                        if (getRequestorType().equals(RequestorType.PROXY)) {
                            return new PasswordAuthentication(CONF.getHttpProxyUser(),
                                    CONF.getHttpProxyPassword().toCharArray());
                        } else {
                            return null;
                        }
                    }
                });
            }
            final Proxy proxy = new Proxy(Proxy.Type.HTTP,
                    InetSocketAddress.createUnresolved(CONF.getHttpProxyHost(), CONF.getHttpProxyPort()));
            if (logger.isDebugEnabled()) {
                logger.debug("Opening proxied connection(" + CONF.getHttpProxyHost() + ":"
                        + CONF.getHttpProxyPort() + ")");
            }
            okHttpClient.setProxy(proxy);
        }

        //connection timeout
        if (CONF.getHttpConnectionTimeout() > 0) {
            okHttpClient.setConnectTimeout(CONF.getHttpConnectionTimeout(), TimeUnit.MILLISECONDS);
        }

        //read timeout
        if (CONF.getHttpReadTimeout() > 0) {
            okHttpClient.setReadTimeout(CONF.getHttpReadTimeout(), TimeUnit.MILLISECONDS);
        }
    }
}