|
|
@ -96,7 +96,8 @@ import org.eclipse.jgit.util.TemporaryBuffer; |
|
|
|
import org.eclipse.jgit.util.TemporaryBuffer.LocalFile; |
|
|
|
import org.eclipse.jgit.util.TemporaryBuffer.LocalFile; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* A {@link HttpConnection} which uses {@link HttpClient} |
|
|
|
* A {@link org.eclipse.jgit.transport.http.HttpConnection} which uses |
|
|
|
|
|
|
|
* {@link org.apache.http.client.HttpClient} |
|
|
|
* |
|
|
|
* |
|
|
|
* @since 3.3 |
|
|
|
* @since 3.3 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -188,6 +189,8 @@ public class HttpClientConnection implements HttpConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* Constructor for HttpClientConnection. |
|
|
|
|
|
|
|
* |
|
|
|
* @param urlStr |
|
|
|
* @param urlStr |
|
|
|
* @throws MalformedURLException |
|
|
|
* @throws MalformedURLException |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -196,6 +199,8 @@ public class HttpClientConnection implements HttpConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* Constructor for HttpClientConnection. |
|
|
|
|
|
|
|
* |
|
|
|
* @param urlStr |
|
|
|
* @param urlStr |
|
|
|
* @param proxy |
|
|
|
* @param proxy |
|
|
|
* @throws MalformedURLException |
|
|
|
* @throws MalformedURLException |
|
|
@ -206,6 +211,8 @@ public class HttpClientConnection implements HttpConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
|
|
|
|
* Constructor for HttpClientConnection. |
|
|
|
|
|
|
|
* |
|
|
|
* @param urlStr |
|
|
|
* @param urlStr |
|
|
|
* @param proxy |
|
|
|
* @param proxy |
|
|
|
* @param cl |
|
|
|
* @param cl |
|
|
@ -218,17 +225,20 @@ public class HttpClientConnection implements HttpConnection { |
|
|
|
this.proxy = proxy; |
|
|
|
this.proxy = proxy; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public int getResponseCode() throws IOException { |
|
|
|
public int getResponseCode() throws IOException { |
|
|
|
execute(); |
|
|
|
execute(); |
|
|
|
return resp.getStatusLine().getStatusCode(); |
|
|
|
return resp.getStatusLine().getStatusCode(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public URL getURL() { |
|
|
|
public URL getURL() { |
|
|
|
return url; |
|
|
|
return url; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String getResponseMessage() throws IOException { |
|
|
|
public String getResponseMessage() throws IOException { |
|
|
|
execute(); |
|
|
|
execute(); |
|
|
@ -257,6 +267,7 @@ public class HttpClientConnection implements HttpConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public Map<String, List<String>> getHeaderFields() { |
|
|
|
public Map<String, List<String>> getHeaderFields() { |
|
|
|
Map<String, List<String>> ret = new HashMap<>(); |
|
|
|
Map<String, List<String>> ret = new HashMap<>(); |
|
|
@ -269,11 +280,13 @@ public class HttpClientConnection implements HttpConnection { |
|
|
|
return ret; |
|
|
|
return ret; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setRequestProperty(String name, String value) { |
|
|
|
public void setRequestProperty(String name, String value) { |
|
|
|
req.addHeader(name, value); |
|
|
|
req.addHeader(name, value); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setRequestMethod(String method) throws ProtocolException { |
|
|
|
public void setRequestMethod(String method) throws ProtocolException { |
|
|
|
this.method = method; |
|
|
|
this.method = method; |
|
|
@ -291,21 +304,25 @@ public class HttpClientConnection implements HttpConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setUseCaches(boolean usecaches) { |
|
|
|
public void setUseCaches(boolean usecaches) { |
|
|
|
// not needed
|
|
|
|
// not needed
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setConnectTimeout(int timeout) { |
|
|
|
public void setConnectTimeout(int timeout) { |
|
|
|
this.timeout = Integer.valueOf(timeout); |
|
|
|
this.timeout = Integer.valueOf(timeout); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setReadTimeout(int readTimeout) { |
|
|
|
public void setReadTimeout(int readTimeout) { |
|
|
|
this.readTimeout = Integer.valueOf(readTimeout); |
|
|
|
this.readTimeout = Integer.valueOf(readTimeout); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String getContentType() { |
|
|
|
public String getContentType() { |
|
|
|
HttpEntity responseEntity = resp.getEntity(); |
|
|
|
HttpEntity responseEntity = resp.getEntity(); |
|
|
@ -317,18 +334,21 @@ public class HttpClientConnection implements HttpConnection { |
|
|
|
return null; |
|
|
|
return null; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public InputStream getInputStream() throws IOException { |
|
|
|
public InputStream getInputStream() throws IOException { |
|
|
|
return resp.getEntity().getContent(); |
|
|
|
return resp.getEntity().getContent(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// will return only the first field
|
|
|
|
// will return only the first field
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String getHeaderField(String name) { |
|
|
|
public String getHeaderField(String name) { |
|
|
|
Header header = resp.getFirstHeader(name); |
|
|
|
Header header = resp.getFirstHeader(name); |
|
|
|
return (header == null) ? null : header.getValue(); |
|
|
|
return (header == null) ? null : header.getValue(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public int getContentLength() { |
|
|
|
public int getContentLength() { |
|
|
|
Header contentLength = resp.getFirstHeader("content-length"); //$NON-NLS-1$
|
|
|
|
Header contentLength = resp.getFirstHeader("content-length"); //$NON-NLS-1$
|
|
|
@ -344,16 +364,19 @@ public class HttpClientConnection implements HttpConnection { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setInstanceFollowRedirects(boolean followRedirects) { |
|
|
|
public void setInstanceFollowRedirects(boolean followRedirects) { |
|
|
|
this.followRedirects = Boolean.valueOf(followRedirects); |
|
|
|
this.followRedirects = Boolean.valueOf(followRedirects); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setDoOutput(boolean dooutput) { |
|
|
|
public void setDoOutput(boolean dooutput) { |
|
|
|
// TODO: check whether we can really ignore this.
|
|
|
|
// TODO: check whether we can really ignore this.
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setFixedLengthStreamingMode(int contentLength) { |
|
|
|
public void setFixedLengthStreamingMode(int contentLength) { |
|
|
|
if (entity != null) |
|
|
|
if (entity != null) |
|
|
@ -362,6 +385,7 @@ public class HttpClientConnection implements HttpConnection { |
|
|
|
entity.setContentLength(contentLength); |
|
|
|
entity.setContentLength(contentLength); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public OutputStream getOutputStream() throws IOException { |
|
|
|
public OutputStream getOutputStream() throws IOException { |
|
|
|
if (entity == null) |
|
|
|
if (entity == null) |
|
|
@ -369,6 +393,7 @@ public class HttpClientConnection implements HttpConnection { |
|
|
|
return entity.getBuffer(); |
|
|
|
return entity.getBuffer(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setChunkedStreamingMode(int chunklen) { |
|
|
|
public void setChunkedStreamingMode(int chunklen) { |
|
|
|
if (entity == null) |
|
|
|
if (entity == null) |
|
|
@ -376,26 +401,31 @@ public class HttpClientConnection implements HttpConnection { |
|
|
|
entity.setChunked(true); |
|
|
|
entity.setChunked(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public String getRequestMethod() { |
|
|
|
public String getRequestMethod() { |
|
|
|
return method; |
|
|
|
return method; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public boolean usingProxy() { |
|
|
|
public boolean usingProxy() { |
|
|
|
return isUsingProxy; |
|
|
|
return isUsingProxy; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void connect() throws IOException { |
|
|
|
public void connect() throws IOException { |
|
|
|
execute(); |
|
|
|
execute(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void setHostnameVerifier(final HostnameVerifier hostnameverifier) { |
|
|
|
public void setHostnameVerifier(final HostnameVerifier hostnameverifier) { |
|
|
|
this.hostnameverifier = hostnameverifier; |
|
|
|
this.hostnameverifier = hostnameverifier; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** {@inheritDoc} */ |
|
|
|
@Override |
|
|
|
@Override |
|
|
|
public void configure(KeyManager[] km, TrustManager[] tm, |
|
|
|
public void configure(KeyManager[] km, TrustManager[] tm, |
|
|
|
SecureRandom random) throws KeyManagementException { |
|
|
|
SecureRandom random) throws KeyManagementException { |
|
|
|