Java 类org.apache.http.impl.DefaultBHttpClientConnection 实例源码

项目:remote-files-sync    文件:BasicConnFactory.java   
/**
 * @deprecated (4.3) no longer used.
 */
@Deprecated
protected HttpClientConnection create(final Socket socket, final HttpParams params) throws IOException {
    final int bufsize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024);
    final DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(bufsize);
    conn.bind(socket);
    return conn;
}
项目:java-binrepo-proxy    文件:ElementalReverseProxy.java   
@Override
    public void run() {
        System.out.println("Listening on port " + this.serversocket.getLocalPort());
        while (!Thread.interrupted()) {
            try {
                final int bufsize = 8 * 1024;
                // Set up incoming HTTP connection
                final Socket insocket = this.serversocket.accept();
                final DefaultBHttpServerConnection inconn = new DefaultBHttpServerConnection(bufsize);
                System.out.println("Incoming connection from " + insocket.getInetAddress());
                inconn.bind(insocket);

                // Set up outgoing HTTP connection
                final Socket outsocket;
                if (this.target.getSchemeName().equals("https")) {
                    SSLContext sslcontext = SSLContexts.createSystemDefault();
                    SocketFactory sf = sslcontext.getSocketFactory();
                    outsocket = (SSLSocket) sf.createSocket(this.target.getHostName(), 443);
//                    // Enforce TLS and disable SSL
//                    socket.setEnabledProtocols(new String[] {
//                            "TLSv1",
//                            "TLSv1.1",
//                            "TLSv1.2" });
//                    // Enforce strong ciphers
//                    socket.setEnabledCipherSuites(new String[] {
//                            "TLS_RSA_WITH_AES_256_CBC_SHA",
//                            "TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
//                            "TLS_DHE_DSS_WITH_AES_256_CBC_SHA" });
                } else {
                    outsocket = new Socket(this.target.getHostName(), this.target.getPort());
                }
                final DefaultBHttpClientConnection outconn = new DefaultBHttpClientConnection(bufsize);
                outconn.bind(outsocket);
                System.out.println("Outgoing connection to " + outsocket.getInetAddress());

                // Start worker thread
                final Thread t = new ProxyThread(this.httpService, inconn, outconn);
                t.setDaemon(true);
                t.start();
            } catch (final InterruptedIOException ex) {
                break;
            } catch (final IOException e) {
                System.err.println("I/O error initialising connection thread: "
                        + e.getMessage());
                break;
            }
        }
    }
项目:Visit    文件:BasicConnFactory.java   
/**
 * @deprecated (4.3) no longer used.
 */
@Deprecated
protected HttpClientConnection create(final Socket socket, final HttpParams params) throws IOException {
    final int bufsize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024);
    final DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(bufsize);
    conn.bind(socket);
    return conn;
}
项目:ZTLib    文件:BasicConnFactory.java   
/**
 * @deprecated (4.3) no longer used.
 */
@Deprecated
protected HttpClientConnection create(final Socket socket, final HttpParams params) throws IOException {
    final int bufsize = params.getIntParameter(CoreConnectionPNames.SOCKET_BUFFER_SIZE, 8 * 1024);
    final DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(bufsize);
    conn.bind(socket);
    return conn;
}
项目:java-binrepo-proxy    文件:HttpCoreTransportServer.java   
@Override
    public void run() {
        LOG.info("Listening on port {}", this.serversocket.getLocalPort());
        while (!Thread.interrupted()) {
            try {
                final int bufsize = 8 * 1024;
                // Set up incoming HTTP connection
                final Socket insocket = this.serversocket.accept();
                final DefaultBHttpServerConnection inconn = new DefaultBHttpServerConnection(bufsize);
                System.out.println("Incoming connection from " + insocket.getInetAddress());
                inconn.bind(insocket);

                // Set up outgoing HTTP connection
                final Socket outsocket;
                if (this.target.getSchemeName().equals("https")) {
                    SSLContext sslcontext = SSLContexts.createSystemDefault();
                    SocketFactory sf = sslcontext.getSocketFactory();
                    outsocket = (SSLSocket) sf.createSocket(this.target.getHostName(), 443);
//                    // Enforce TLS and disable SSL
//                    socket.setEnabledProtocols(new String[] {
//                            "TLSv1",
//                            "TLSv1.1",
//                            "TLSv1.2" });
//                    // Enforce strong ciphers
//                    socket.setEnabledCipherSuites(new String[] {
//                            "TLS_RSA_WITH_AES_256_CBC_SHA",
//                            "TLS_DHE_RSA_WITH_AES_256_CBC_SHA",
//                            "TLS_DHE_DSS_WITH_AES_256_CBC_SHA" });
                } else {
                    outsocket = new Socket(this.target.getHostName(), this.target.getPort());
                }
                final DefaultBHttpClientConnection outconn = new DefaultBHttpClientConnection(bufsize);
                outconn.bind(outsocket);
                LOG.info("Outgoing connection to {}", outsocket.getInetAddress());

                // Start worker thread
                final Thread t = new ElementalReverseProxy.ProxyThread(this.httpService, inconn, outconn);
                t.setDaemon(true);
                t.start();
            } catch (final InterruptedIOException ex) {
                break;
            } catch (final IOException e) {
                LOG.error("I/O error initialising connection thread: {}",
                        e.getMessage());
                break;
            }
        }
    }
项目:webarchive-commons    文件:ApacheHttp43SLR.java   
protected InputStream doSeekLoad(long offset, int maxLength, URL url)
          throws IOException {

try {
    SocketAddress endpoint = new InetSocketAddress(url.getHost(), getPort(url));

    socket = new Socket();
    socket.connect(endpoint, connectTimeout);

    activeConn = new DefaultBHttpClientConnection(BUFF_SIZE);
    activeConn.bind(socket);
    activeConn.setSocketTimeout(readTimeout);

    HttpRequest request = new BasicHttpRequest("GET", url.getFile(), HttpVersion.HTTP_1_1);

    String rangeHeader = makeRangeHeader(offset, maxLength);

    if (rangeHeader != null) {
        request.setHeader("Range", rangeHeader);
    }

    if (this.isNoKeepAlive()) {
        request.setHeader("Connection", "close");
    } else {
        request.setHeader("Connection", "keep-alive");
    }

    if (this.getCookie() != null) {
        request.setHeader("Cookie", this.getCookie());
    }

    request.setHeader("Accept", "*/*");
    request.setHeader("Host", url.getHost());

    activeConn.sendRequestHeader(request);
    activeConn.flush();

    response = activeConn.receiveResponseHeader();

    int code = response.getStatusLine().getStatusCode();

    connectedUrl = url.toString();

    if (code > 300 && code < 400) {
        Header header = response.getFirstHeader("Location");

        doClose();

        if (header != null) {
            URL redirectURL = new URL(header.getValue());
            return doSeekLoad(offset, maxLength, redirectURL);
        }
    }

    if (code != 200 && code != 206) {
        throw new BadHttpStatusException(code, connectedUrl + " " + rangeHeader);
    }

    activeConn.receiveResponseEntity(response);

    return response.getEntity().getContent();

} catch (HttpException e) {
    doClose();
    throw new IOException(e);

      } catch (IOException io) {

    if (saveErrHeader != null) {
        errHeader = getHeaderValue(saveErrHeader);  
    }

    connectedUrl = url.toString();

    doClose();
    throw io;
      }
  }