diff --git a/httpcomponents.diff b/httpcomponents.diff index 8cc8e732..fdae30ee 100644 --- a/httpcomponents.diff +++ b/httpcomponents.diff @@ -177,6 +177,88 @@ Index: httpclient/httpclient/src/main/java/org/apache/http/client/methods/Aborta + } + +} +Index: httpclient/httpclient/src/main/java/org/apache/http/client/methods/BasicAbortableHttpEntityEnclosingRequest.java +=================================================================== +--- httpclient/httpclient/src/main/java/org/apache/http/client/methods/BasicAbortableHttpEntityEnclosingRequest.java (revision 0) ++++ httpclient/httpclient/src/main/java/org/apache/http/client/methods/BasicAbortableHttpEntityEnclosingRequest.java (working copy) +@@ -0,0 +1,77 @@ ++/* ++ * ==================================================================== ++ * Licensed to the Apache Software Foundation (ASF) under one ++ * or more contributor license agreements. See the NOTICE file ++ * distributed with this work for additional information ++ * regarding copyright ownership. The ASF licenses this file ++ * to you under the Apache License, Version 2.0 (the ++ * "License"); you may not use this file except in compliance ++ * with the License. You may obtain a copy of the License at ++ * ++ * http://www.apache.org/licenses/LICENSE-2.0 ++ * ++ * Unless required by applicable law or agreed to in writing, ++ * software distributed under the License is distributed on an ++ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY ++ * KIND, either express or implied. See the License for the ++ * specific language governing permissions and limitations ++ * under the License. ++ * ==================================================================== ++ * ++ * This software consists of voluntary contributions made by many ++ * individuals on behalf of the Apache Software Foundation. For more ++ * information on the Apache Software Foundation, please see ++ * . ++ * ++ */ ++package org.apache.http.client.methods; ++ ++import org.apache.http.Header; ++import org.apache.http.HttpEntity; ++import org.apache.http.HttpEntityEnclosingRequest; ++import org.apache.http.ProtocolVersion; ++import org.apache.http.RequestLine; ++import org.apache.http.annotation.NotThreadSafe; ++import org.apache.http.protocol.HTTP; ++ ++/** ++ * @since 4.3 ++ */ ++@NotThreadSafe ++public class BasicAbortableHttpEntityEnclosingRequest extends ++ BasicAbortableHttpRequest implements HttpEntityEnclosingRequest { ++ ++ private HttpEntity entity; ++ ++ public BasicAbortableHttpEntityEnclosingRequest(final String method, ++ final String uri) { ++ super(method, uri); ++ } ++ ++ public BasicAbortableHttpEntityEnclosingRequest(final String method, ++ final String uri, final ProtocolVersion ver) { ++ super(method, uri, ver); ++ } ++ ++ public BasicAbortableHttpEntityEnclosingRequest(RequestLine requestline) { ++ super(requestline); ++ } ++ ++ @Override ++ public boolean expectContinue() { ++ Header expect = getFirstHeader(HTTP.EXPECT_DIRECTIVE); ++ return expect != null ++ && HTTP.EXPECT_CONTINUE.equalsIgnoreCase(expect.getValue()); ++ } ++ ++ @Override ++ public void setEntity(HttpEntity entity) { ++ this.entity = entity; ++ ++ } ++ ++ @Override ++ public HttpEntity getEntity() { ++ return this.entity; ++ } ++} Index: httpclient/httpclient/src/main/java/org/apache/http/client/methods/BasicAbortableHttpRequest.java =================================================================== --- httpclient/httpclient/src/main/java/org/apache/http/client/methods/BasicAbortableHttpRequest.java (revision 0) @@ -521,44 +603,6 @@ Index: httpclient/httpclient/src/main/java/org/apache/http/client/methods/HttpRe public String toString() { return getMethod() + " " + getURI() + " " + getProtocolVersion(); } -Index: httpclient/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java -=================================================================== ---- httpclient/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java (revision 1427210) -+++ httpclient/httpclient/src/main/java/org/apache/http/impl/client/AbstractHttpClient.java (working copy) -@@ -37,6 +37,7 @@ - import org.apache.http.HttpHost; - import org.apache.http.HttpRequest; - import org.apache.http.HttpRequestInterceptor; -+import org.apache.http.HttpResponse; - import org.apache.http.HttpResponseInterceptor; - import org.apache.http.annotation.GuardedBy; - import org.apache.http.annotation.ThreadSafe; -@@ -821,6 +822,7 @@ - } - - try { -+ HttpResponse response = director.execute(target, request, execContext); - if (connectionBackoffStrategy != null && backoffManager != null) { - HttpHost targetForRoute = (target != null) ? target - : (HttpHost) determineParams(request).getParameter( -@@ -830,7 +832,7 @@ - CloseableHttpResponse out; - try { - out = CloseableHttpResponseProxy.newProxy( -- director.execute(target, request, execContext)); -+ response); - } catch (RuntimeException re) { - if (connectionBackoffStrategy.shouldBackoff(re)) { - backoffManager.backOff(route); -@@ -852,7 +854,7 @@ - return out; - } else { - return CloseableHttpResponseProxy.newProxy( -- director.execute(target, request, execContext)); -+ response); - } - } catch(HttpException httpException) { - throw new ClientProtocolException(httpException); Index: httpclient/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java =================================================================== --- httpclient/httpclient/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandler.java (revision 1427210) @@ -572,44 +616,6 @@ Index: httpclient/httpclient/src/main/java/org/apache/http/impl/client/DefaultUs SSLSession sslsession = ((SocketClientConnection) conn).getSSLSession(); if (sslsession != null) { userPrincipal = sslsession.getLocalPrincipal(); -Index: httpclient/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java -=================================================================== ---- httpclient/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java (revision 1427210) -+++ httpclient/httpclient/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java (working copy) -@@ -163,7 +163,7 @@ - private ServiceUnavailableRetryStrategy serviceUnavailStrategy; - private Lookup authSchemeRegistry; - private Lookup cookieSpecRegistry; -- private Map authShemes; -+ private Map authSchemes; - private Map cookieSpecs; - private CookieStore cookieStore; - private CredentialsProvider credentialsProvider; -@@ -362,10 +362,10 @@ - - public final HttpClientBuilder registerAuthScheme( - final String name, final AuthSchemeProvider authSchemeProvider) { -- if (this.authShemes == null) { -- this.authShemes = new HashMap(); -+ if (this.authSchemes == null) { -+ this.authSchemes = new HashMap(); - } -- this.authShemes.put(name, authSchemeProvider); -+ this.authSchemes.put(name, authSchemeProvider); - return this; - } - -@@ -653,8 +653,8 @@ - .register(AuthSchemes.SPNEGO, new SPNegoSchemeFactory()) - .register(AuthSchemes.KERBEROS, new KerberosSchemeFactory()) - .build(); -- if (authShemes != null) { -- for (Map.Entry entry: authShemes.entrySet()) { -+ if (authSchemes != null) { -+ for (Map.Entry entry: authSchemes.entrySet()) { - b.register(entry.getKey(), entry.getValue()); - } - } Index: httpclient/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java =================================================================== --- httpclient/httpclient/src/main/java/org/apache/http/impl/conn/DefaultClientConnectionFactory.java (revision 1427210) diff --git a/modules/src/test/java/org/archive/modules/fetcher/FetchHTTPTests.java b/modules/src/test/java/org/archive/modules/fetcher/FetchHTTPTests.java index 22b90c6c..122513bd 100644 --- a/modules/src/test/java/org/archive/modules/fetcher/FetchHTTPTests.java +++ b/modules/src/test/java/org/archive/modules/fetcher/FetchHTTPTests.java @@ -610,7 +610,11 @@ public class FetchHTTPTests extends ProcessorTestBase { assertTrue(curi.getFetchDuration() >= 2000 && curi.getFetchDuration() < 2200); } - // see http://stackoverflow.com/questions/100841/artificially-create-a-connection-timeout-error + /* + * See http://stackoverflow.com/questions/100841/artificially-create-a-connection-timeout-error + * This test seems to fail if not connected to internet, because + * connection fails immediately insted of timing out. + */ public void testConnectionTimeout() throws Exception { CrawlURI curi = makeCrawlURI("http://10.255.255.1/"); fetcher().setSoTimeoutMs(300);