diff options
Diffstat (limited to 'org.eclipse.jgit.http.apache')
6 files changed, 89 insertions, 62 deletions
diff --git a/org.eclipse.jgit.http.apache/.classpath b/org.eclipse.jgit.http.apache/.classpath index a14ade4efd..110168ffa1 100644 --- a/org.eclipse.jgit.http.apache/.classpath +++ b/org.eclipse.jgit.http.apache/.classpath @@ -1,6 +1,6 @@ <?xml version="1.0" encoding="UTF-8"?> <classpath> - <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.7"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/> <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> <classpathentry kind="src" path="src"/> <classpathentry kind="src" path="resources"/> diff --git a/org.eclipse.jgit.http.apache/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.jgit.http.apache/.settings/org.eclipse.jdt.core.prefs index cd620c394e..80cfbbbd3b 100644 --- a/org.eclipse.jgit.http.apache/.settings/org.eclipse.jdt.core.prefs +++ b/org.eclipse.jgit.http.apache/.settings/org.eclipse.jdt.core.prefs @@ -7,9 +7,9 @@ org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nul org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled org.eclipse.jdt.core.compiler.codegen.methodParameters=do not generate -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.8 org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve -org.eclipse.jdt.core.compiler.compliance=1.7 +org.eclipse.jdt.core.compiler.compliance=1.8 org.eclipse.jdt.core.compiler.debug.lineNumber=generate org.eclipse.jdt.core.compiler.debug.localVariable=generate org.eclipse.jdt.core.compiler.debug.sourceFile=generate @@ -112,7 +112,7 @@ org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=error org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=ignore org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=error -org.eclipse.jdt.core.compiler.source=1.7 +org.eclipse.jdt.core.compiler.source=1.8 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 diff --git a/org.eclipse.jgit.http.apache/META-INF/MANIFEST.MF b/org.eclipse.jgit.http.apache/META-INF/MANIFEST.MF index fa1d6f11b5..978be2795b 100644 --- a/org.eclipse.jgit.http.apache/META-INF/MANIFEST.MF +++ b/org.eclipse.jgit.http.apache/META-INF/MANIFEST.MF @@ -2,30 +2,36 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 Bundle-Name: %Bundle-Name Bundle-SymbolicName: org.eclipse.jgit.http.apache -Bundle-Version: 4.5.3.qualifier -Bundle-RequiredExecutionEnvironment: JavaSE-1.7 +Bundle-Version: 4.6.2.qualifier +Bundle-RequiredExecutionEnvironment: JavaSE-1.8 Bundle-Localization: plugin Bundle-Vendor: %Provider-Name Bundle-ActivationPolicy: lazy -Import-Package: org.apache.http;version="[4.1.0,5.0.0)", - org.apache.http.client;version="[4.1.0,5.0.0)", - org.apache.http.client.methods;version="[4.1.0,5.0.0)", - org.apache.http.client.params;version="[4.1.0,5.0.0)", - org.apache.http.conn;version="[4.1.0,5.0.0)", - org.apache.http.conn.params;version="[4.1.0,5.0.0)", - org.apache.http.conn.scheme;version="[4.1.0,5.0.0)", - org.apache.http.conn.ssl;version="[4.1.0,5.0.0)", - org.apache.http.entity;version="[4.1.0,5.0.0)", - org.apache.http.impl.client;version="[4.1.0,5.0.0)", - org.apache.http.impl.client.cache;version="[4.1.0,5.0.0)", - org.apache.http.params;version="[4.1.0,5.0.0)", - org.eclipse.jgit.nls;version="[4.5.3,4.6.0)", - org.eclipse.jgit.transport.http;version="[4.5.3,4.6.0)", - org.eclipse.jgit.util;version="[4.5.3,4.6.0)" -Export-Package: org.eclipse.jgit.transport.http.apache;version="4.5.3"; - uses:="org.eclipse.jgit.transport.http, - javax.net.ssl, - org.apache.http.client, +Import-Package: org.apache.http;version="[4.3.0,5.0.0)", + org.apache.http.client;version="[4.3.0,5.0.0)", + org.apache.http.client.config;version="[4.3.0,5.0.0)", + org.apache.http.client.methods;version="[4.3.0,5.0.0)", + org.apache.http.client.params;version="[4.3.0,5.0.0)", + org.apache.http.config;version="[4.3.0,5.0.0)", + org.apache.http.conn;version="[4.3.0,5.0.0)", + org.apache.http.conn.params;version="[4.3.0,5.0.0)", + org.apache.http.conn.scheme;version="[4.3.0,5.0.0)", + org.apache.http.conn.socket;version="[4.3.0,5.0.0)", + org.apache.http.conn.ssl;version="[4.3.0,5.0.0)", + org.apache.http.entity;version="[4.3.0,5.0.0)", + org.apache.http.impl.client;version="[4.3.0,5.0.0)", + org.apache.http.impl.client.cache;version="[4.3.0,5.0.0)", + org.apache.http.impl.conn;version="[4.3.0,5.0.0)", + org.apache.http.params;version="[4.3.0,5.0.0)", + org.eclipse.jgit.nls;version="[4.6.2,4.7.0)", + org.eclipse.jgit.transport.http;version="[4.6.2,4.7.0)", + org.eclipse.jgit.util;version="[4.6.2,4.7.0)" +Export-Package: org.eclipse.jgit.transport.http.apache;version="4.6.2"; + uses:="org.apache.http.client, + org.eclipse.jgit.transport.http, + org.apache.http.entity, org.apache.http.client.methods, + javax.net.ssl, + org.eclipse.jgit.util, org.apache.http", org.eclipse.jgit.transport.http.apache.internal;x-internal:=true diff --git a/org.eclipse.jgit.http.apache/pom.xml b/org.eclipse.jgit.http.apache/pom.xml index 7c2de007ac..dfd8585b76 100644 --- a/org.eclipse.jgit.http.apache/pom.xml +++ b/org.eclipse.jgit.http.apache/pom.xml @@ -48,7 +48,7 @@ <parent> <groupId>org.eclipse.jgit</groupId> <artifactId>org.eclipse.jgit-parent</artifactId> - <version>4.5.3-SNAPSHOT</version> + <version>4.6.2-SNAPSHOT</version> </parent> <artifactId>org.eclipse.jgit.http.apache</artifactId> diff --git a/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java b/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java index 2d9d17a890..281154fb1a 100644 --- a/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java +++ b/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/HttpClientConnection.java @@ -80,19 +80,21 @@ import org.apache.http.HttpHost; import org.apache.http.HttpResponse; import org.apache.http.client.ClientProtocolException; import org.apache.http.client.HttpClient; +import org.apache.http.client.config.RequestConfig; import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpHead; import org.apache.http.client.methods.HttpPost; import org.apache.http.client.methods.HttpPut; import org.apache.http.client.methods.HttpUriRequest; -import org.apache.http.client.params.ClientPNames; -import org.apache.http.conn.params.ConnRoutePNames; -import org.apache.http.conn.scheme.Scheme; -import org.apache.http.conn.ssl.SSLSocketFactory; +import org.apache.http.config.Registry; +import org.apache.http.config.RegistryBuilder; +import org.apache.http.conn.socket.ConnectionSocketFactory; +import org.apache.http.conn.socket.PlainConnectionSocketFactory; +import org.apache.http.conn.ssl.SSLConnectionSocketFactory; import org.apache.http.conn.ssl.X509HostnameVerifier; -import org.apache.http.impl.client.DefaultHttpClient; -import org.apache.http.params.CoreConnectionPNames; -import org.apache.http.params.HttpParams; +import org.apache.http.impl.client.HttpClientBuilder; +import org.apache.http.impl.client.HttpClients; +import org.apache.http.impl.conn.BasicHttpClientConnectionManager; import org.eclipse.jgit.transport.http.HttpConnection; import org.eclipse.jgit.transport.http.apache.internal.HttpApacheText; import org.eclipse.jgit.util.TemporaryBuffer; @@ -131,29 +133,39 @@ public class HttpClientConnection implements HttpConnection { SSLContext ctx; private HttpClient getClient() { - if (client == null) - client = new DefaultHttpClient(); - HttpParams params = client.getParams(); - if (proxy != null && !Proxy.NO_PROXY.equals(proxy)) { - isUsingProxy = true; - InetSocketAddress adr = (InetSocketAddress) proxy.address(); - params.setParameter(ConnRoutePNames.DEFAULT_PROXY, - new HttpHost(adr.getHostName(), adr.getPort())); - } - if (timeout != null) - params.setIntParameter(CoreConnectionPNames.CONNECTION_TIMEOUT, - timeout.intValue()); - if (readTimeout != null) - params.setIntParameter(CoreConnectionPNames.SO_TIMEOUT, - readTimeout.intValue()); - if (followRedirects != null) - params.setBooleanParameter(ClientPNames.HANDLE_REDIRECTS, - followRedirects.booleanValue()); - if (hostnameverifier != null) { - SSLSocketFactory sf; - sf = new SSLSocketFactory(getSSLContext(), hostnameverifier); - Scheme https = new Scheme("https", 443, sf); //$NON-NLS-1$ - client.getConnectionManager().getSchemeRegistry().register(https); + if (client == null) { + HttpClientBuilder clientBuilder = HttpClients.custom(); + RequestConfig.Builder configBuilder = RequestConfig.custom(); + if (proxy != null && !Proxy.NO_PROXY.equals(proxy)) { + isUsingProxy = true; + InetSocketAddress adr = (InetSocketAddress) proxy.address(); + clientBuilder.setProxy( + new HttpHost(adr.getHostName(), adr.getPort())); + } + if (timeout != null) { + configBuilder.setConnectTimeout(timeout.intValue()); + } + if (readTimeout != null) { + configBuilder.setSocketTimeout(readTimeout.intValue()); + } + if (followRedirects != null) { + configBuilder + .setRedirectsEnabled(followRedirects.booleanValue()); + } + if (hostnameverifier != null) { + SSLConnectionSocketFactory sslConnectionFactory = new SSLConnectionSocketFactory( + getSSLContext(), hostnameverifier); + clientBuilder.setSSLSocketFactory(sslConnectionFactory); + Registry<ConnectionSocketFactory> registry = RegistryBuilder + .<ConnectionSocketFactory> create() + .register("https", sslConnectionFactory) + .register("http", PlainConnectionSocketFactory.INSTANCE) + .build(); + clientBuilder.setConnectionManager( + new BasicHttpClientConnectionManager(registry)); + } + clientBuilder.setDefaultRequestConfig(configBuilder.build()); + client = clientBuilder.build(); } return client; @@ -283,11 +295,11 @@ public class HttpClientConnection implements HttpConnection { } public void setConnectTimeout(int timeout) { - this.timeout = new Integer(timeout); + this.timeout = Integer.valueOf(timeout); } public void setReadTimeout(int readTimeout) { - this.readTimeout = new Integer(readTimeout); + this.readTimeout = Integer.valueOf(readTimeout); } public String getContentType() { @@ -311,12 +323,21 @@ public class HttpClientConnection implements HttpConnection { } public int getContentLength() { - return Integer.parseInt(resp.getFirstHeader("content-length") //$NON-NLS-1$ - .getValue()); + Header contentLength = resp.getFirstHeader("content-length"); //$NON-NLS-1$ + if (contentLength == null) { + return -1; + } + + try { + int l = Integer.parseInt(contentLength.getValue()); + return l < 0 ? -1 : l; + } catch (NumberFormatException e) { + return -1; + } } public void setInstanceFollowRedirects(boolean followRedirects) { - this.followRedirects = new Boolean(followRedirects); + this.followRedirects = Boolean.valueOf(followRedirects); } public void setDoOutput(boolean dooutput) { diff --git a/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/TemporaryBufferEntity.java b/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/TemporaryBufferEntity.java index 377e5ca572..93328c96ca 100644 --- a/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/TemporaryBufferEntity.java +++ b/org.eclipse.jgit.http.apache/src/org/eclipse/jgit/transport/http/apache/TemporaryBufferEntity.java @@ -105,7 +105,7 @@ public class TemporaryBufferEntity extends AbstractHttpEntity * @param contentLength */ public void setContentLength(int contentLength) { - this.contentLength = new Integer(contentLength); + this.contentLength = Integer.valueOf(contentLength); } /** |