Refine search
@Override public Socket createSocket(String host, int port, InetAddress localAddress, int localPort, HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException { if (params == null) { throw new IllegalArgumentException("Parameters may not be null"); } int timeout = params.getConnectionTimeout(); SocketFactory socketfactory = getSSLContext().getSocketFactory(); if (timeout == 0) { return socketfactory.createSocket(host, port, localAddress, localPort); } else { Socket socket = socketfactory.createSocket(); SocketAddress localaddr = new InetSocketAddress(localAddress, localPort); SocketAddress remoteaddr = new InetSocketAddress(host, port); socket.bind(localaddr); socket.connect(remoteaddr, timeout); return socket; } }
httpConnection = new HttpConnection(hostConfiguration); httpConnection.setHttpConnectionManager(this); httpConnection.getParams().setDefaults(this.params); } else {
assertNotOpen(); usingSecureSocket = isSecure() && !isProxied(); socket.setTcpNoDelay(this.params.getTcpNoDelay()); socket.setSoTimeout(this.params.getSoTimeout()); int linger = this.params.getLinger(); if (linger >= 0) { socket.setSoLinger(linger > 0, linger); int sndBufSize = this.params.getSendBufferSize(); if (sndBufSize >= 0) { socket.setSendBufferSize(sndBufSize); int rcvBufSize = this.params.getReceiveBufferSize(); if (rcvBufSize >= 0) { socket.setReceiveBufferSize(rcvBufSize);
public Socket createSocket(final String host, final int port, final InetAddress localAddress, final int localPort, final HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException { InetSocketAddress socksAddr = new InetSocketAddress(socksHost, socksPort); Proxy proxy = new Proxy(Proxy.Type.SOCKS, socksAddr); int timeout = params.getConnectionTimeout(); Socket socket = new Socket(proxy); socket.setSoTimeout(timeout); SocketAddress localaddr = new InetSocketAddress(localAddress, localPort); SocketAddress remoteaddr = new InetSocketAddress(host, port); socket.bind(localaddr); socket.connect(remoteaddr, timeout); return socket; }
throw new IllegalArgumentException("Parameters may not be null"); int timeout = params.getConnectionTimeout(); if (timeout == 0) { Socket s=new Socket(); s.connect(new InetSocketAddress(host,port),timeout); return s;
throw new IllegalArgumentException("Parameters may not be null"); int timeout = params.getConnectionTimeout(); Log_OC.d(TAG, " ... with connection timeout " + timeout + " and socket timeout " + params.getSoTimeout()); Socket socket = socketfactory.createSocket(); enableSecureProtocols(socket); SocketAddress localaddr = new InetSocketAddress(localAddress, localPort); SocketAddress remoteaddr = new InetSocketAddress(getInetAddressForHost(host), port); socket.setSoTimeout(params.getSoTimeout() * 5); socket.bind(localaddr); ServerNameIndicator.setServerNameIndication(host, (SSLSocket) socket); socket.connect(remoteaddr, timeout); verifyPeerIdentity(host, port, socket); return socket;
/** * Set the {@link Socket}'s timeout, via {@link Socket#setSoTimeout}. If the * connection is already open, the SO_TIMEOUT is changed. If no connection * is open, then subsequent connections will use the timeout value. * <p> * Note: This is not a connection timeout but a timeout on network traffic! * * @param timeout the timeout value * @throws SocketException - if there is an error in the underlying * protocol, such as a TCP error. * * @deprecated Use {@link HttpConnectionParams#setSoTimeout(int)}, * {@link HttpConnection#getParams()}. */ public void setSoTimeout(int timeout) throws SocketException, IllegalStateException { this.params.setSoTimeout(timeout); if (this.socket != null) { this.socket.setSoTimeout(timeout); } }
throws IOException { LOG.trace("enter HttpConnection.isResponseAvailable(int)"); assertOpen(); boolean result = false; if (this.inputStream.available() > 0) { } else { try { this.socket.setSoTimeout(timeout); inputStream.mark(1); int byteRead = inputStream.read(); socket.setSoTimeout(this.params.getSoTimeout()); } catch (IOException ioe) { LOG.debug("An error ocurred while resetting soTimeout, we will assume that"
if (inputStream.available() <= 0) { try { socket.setSoTimeout(1); inputStream.mark(1); int byteRead = inputStream.read(); socket.setSoTimeout(this.params.getSoTimeout());
throw new IllegalArgumentException("Parameters may not be null"); int timeout = params.getConnectionTimeout(); if (timeout == 0) { Socket sslSocket = SSLSocketFactory.getDefault().createSocket( host, port, localAddress, localPort); sslSocket.setSoTimeout(params.getSoTimeout()); verifyHostName(host, (SSLSocket) sslSocket, hostNameVerifier); return sslSocket; this, host, port, localAddress, localPort, timeout); sslSocket.setSoTimeout(params.getSoTimeout()); verifyHostName(host, (SSLSocket) sslSocket, hostNameVerifier); return sslSocket;
throw new IllegalArgumentException("Parameters may not be null"); int timeout = params.getConnectionTimeout(); if (timeout == 0) { return createSocket(host, port);
public HttpConnection getConnectionWithTimeout( HostConfiguration hostConfiguration, long timeout) { httpConnection = new HttpConnection(hostConfiguration); httpConnection.setHttpConnectionManager(this); httpConnection.getParams().setDefaults(connectionParams); return httpConnection; }
writeRequestLine(state, conn); writeRequestHeaders(state, conn); conn.writeLine(); // close head if (Wire.HEADER_WIRE.enabled()) { Wire.HEADER_WIRE.output("\r\n"); conn.flushRequestOutputStream(); int readTimeout = conn.getParams().getSoTimeout(); try { conn.setSocketTimeout(RESPONSE_WAIT_TIME_MS);
InputStream is = conn.getResponseInputStream(); if (Wire.CONTENT_WIRE.enabled()) { is = new WireLogInputStream(is, Wire.CONTENT_WIRE); if ((len > 0) && ("chunked".equalsIgnoreCase(encodings[len - 1].getName()))) { if (conn.isResponseAvailable(conn.getParams().getSoTimeout())) { result = new ChunkedInputStream(is, this); } else {
/** * Creates a new connection and returns it for use of the calling method. * * @param hostConfiguration the configuration for the connection * @return a new connection or <code>null</code> if none are available */ public synchronized HttpConnection createConnection(HostConfiguration hostConfiguration) { HostConnectionPool hostPool = getHostPool(hostConfiguration, true); if (LOG.isDebugEnabled()) { LOG.debug("Allocating new connection, hostConfig=" + hostConfiguration); } HttpConnectionWithReference connection = new HttpConnectionWithReference( hostConfiguration); connection.getParams().setDefaults(MultiThreadedHttpConnectionManager.this.params); connection.setHttpConnectionManager(MultiThreadedHttpConnectionManager.this); numConnections++; hostPool.numConnections++; // store a reference to this connection so that it can be cleaned up // in the event it is not correctly released storeReferenceToConnection(connection, hostConfiguration, this); return connection; }
/** * Use custom {@link ZapHttpConnection} to allow for socket exposure. */ @Override public HttpConnection getConnectionWithTimeout( HostConfiguration hostConfiguration, long timeout) { if (httpConnection == null) { httpConnection = new ZapHttpConnection(hostConfiguration); httpConnection.setHttpConnectionManager(this); httpConnection.getParams().setDefaults(this.getParams()); } return super.getConnectionWithTimeout(hostConfiguration, timeout); } }
/** * Sets the connection timeout. This is the maximum time that may be spent * until a connection is established. The connection will fail after this * amount of time. * @param timeout The timeout in milliseconds. 0 means timeout is not used. * * @deprecated Use {@link HttpConnectionParams#setConnectionTimeout(int)}, * {@link HttpConnection#getParams()}. */ public void setConnectionTimeout(int timeout) { this.params.setConnectionTimeout(timeout); }
/** * Returns the {@link Socket}'s timeout, via {@link Socket#getSoTimeout}, if the * connection is already open. If no connection is open, return the value subsequent * connection will use. * <p> * Note: This is not a connection timeout but a timeout on network traffic! * * @return the timeout value * * @deprecated Use {@link HttpConnectionParams#getSoTimeout()}, * {@link HttpConnection#getParams()}. */ public int getSoTimeout() throws SocketException { return this.params.getSoTimeout(); }
protected void initHttpHeaders(XmlRpcRequest pRequest) throws XmlRpcClientException { config = (XmlRpcHttpClientConfig) pRequest.getConfig(); method = new PostMethod(config.getServerURL().toString()); super.initHttpHeaders(pRequest); if (config.getConnectionTimeout() != 0) client.getHttpConnectionManager().getParams().setConnectionTimeout(config.getConnectionTimeout()); if (config.getReplyTimeout() != 0) client.getHttpConnectionManager().getParams().setSoTimeout(config.getConnectionTimeout()); method.getParams().setVersion(HttpVersion.HTTP_1_1); }
public Socket createSocket(final String host, final int port, final InetAddress localAddress, final int localPort, final HttpConnectionParams params) throws IOException, UnknownHostException, ConnectTimeoutException { InetSocketAddress socksAddr = new InetSocketAddress(socksHost, socksPort); Proxy proxy = new Proxy(Proxy.Type.SOCKS, socksAddr); int timeout = params.getConnectionTimeout(); Socket socket = new Socket(proxy); socket.setSoTimeout(timeout); SocketAddress localaddr = new InetSocketAddress(localAddress, localPort); SocketAddress remoteaddr = new InetSocketAddress(host, port); socket.bind(localaddr); socket.connect(remoteaddr, timeout); return socket; }