blob: 35be6fa1c673a25a3c0c9c4e80d2bd7a079a84c9 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
/*******************************************************************************
* Copyright (c) 2011 Tasktop Technologies and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Tasktop Technologies - initial API and implementation
*******************************************************************************/
package org.eclipse.mylyn.commons.repositories.http.core;
import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.Socket;
import java.net.UnknownHostException;
import javax.net.SocketFactory;
import org.apache.http.conn.ConnectTimeoutException;
import org.apache.http.conn.scheme.SchemeSocketFactory;
import org.apache.http.params.HttpConnectionParams;
import org.apache.http.params.HttpParams;
import org.eclipse.mylyn.commons.core.net.NetUtil;
import org.eclipse.mylyn.commons.core.operations.MonitoredOperation;
/**
* @author Steffen Pingel
*/
class PollingProtocolSocketFactory implements SchemeSocketFactory {
private final static SocketFactory factory = SocketFactory.getDefault();
public Socket createSocket(HttpParams params) throws IOException {
return factory.createSocket();
}
public Socket connectSocket(Socket sock, InetSocketAddress remoteAddress, InetSocketAddress localAddress,
HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
if (params == null) {
throw new IllegalArgumentException("Parameters may not be null"); //$NON-NLS-1$
}
final Socket socket = sock != null ? sock : factory.createSocket();
int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
socket.bind(localAddress);
NetUtil.connect(socket, remoteAddress, connTimeout, MonitoredOperation.getCurrentOperation());
return socket;
}
public boolean isSecure(Socket sock) throws IllegalArgumentException {
return false;
}
}
|