Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/AutoCloseInputStream.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/ChunkedInputStream.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/ChunkedOutputStream.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/CircularRedirectException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/ConnectMethod.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/ConnectTimeoutException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/ConnectionPoolTimeoutException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/ContentLengthInputStream.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/Cookie.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/Credentials.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/DefaultHttpMethodRetryHandler.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/DefaultMethodRetryHandler.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/Header.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HeaderElement.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HeaderGroup.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HostConfiguration.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpClient.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpClientError.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpConnection.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpConnectionManager.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpConstants.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpContentTooLargeException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpHost.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpMethod.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpMethodBase.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpMethodDirector.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpMethodRetryHandler.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpParser.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpRecoverableException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpState.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpStatus.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpURL.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpVersion.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/HttpsURL.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/InvalidRedirectLocationException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/MethodRetryHandler.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/MultiThreadedHttpConnectionManager.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/NTCredentials.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/NameValuePair.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/NoHttpResponseException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/ProtocolException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/ProxyClient.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/ProxyHost.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/RedirectException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/ResponseConsumedWatcher.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/SimpleHttpConnectionManager.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/StatusLine.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/URI.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/URIException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/UsernamePasswordCredentials.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/Wire.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/WireLogInputStream.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/WireLogOutputStream.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/AuthChallengeException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/AuthChallengeParser.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/AuthChallengeProcessor.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/AuthPolicy.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/AuthScheme.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/AuthSchemeBase.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/AuthScope.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/AuthState.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/AuthenticationException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/BasicScheme.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/CredentialsNotAvailableException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/CredentialsProvider.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/DigestScheme.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/HttpAuthRealm.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/HttpAuthenticator.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/InvalidCredentialsException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/MalformedChallengeException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/NTLM.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/NTLMScheme.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/RFC2617Scheme.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/auth/package.html'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/Cookie2.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/CookieAttributeHandler.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/CookieOrigin.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/CookiePathComparator.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/CookiePolicy.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/CookieSpec.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/CookieSpecBase.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/CookieVersionSupport.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/IgnoreCookiesSpec.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/MalformedCookieException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/NetscapeDraftSpec.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/RFC2109Spec.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/RFC2965Spec.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/cookie/package.html'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/ByteArrayRequestEntity.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/DeleteMethod.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/EntityEnclosingMethod.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/ExpectContinueMethod.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/FileRequestEntity.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/GetMethod.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/HeadMethod.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/InputStreamRequestEntity.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/MultipartPostMethod.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/OptionsMethod.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/PostMethod.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/PutMethod.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/RequestEntity.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/StringRequestEntity.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/TraceMethod.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/multipart/ByteArrayPartSource.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/multipart/FilePart.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/multipart/FilePartSource.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/multipart/MultipartRequestEntity.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/multipart/Part.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/multipart/PartBase.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/multipart/PartSource.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/multipart/StringPart.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/multipart/package.html'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/methods/package.html'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/package.html'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/params/DefaultHttpParams.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/params/DefaultHttpParamsFactory.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/params/HostParams.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/params/HttpClientParams.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/params/HttpConnectionManagerParams.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/params/HttpConnectionParams.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/params/HttpMethodParams.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/params/HttpParams.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/params/HttpParamsFactory.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/params/package.html'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/protocol/ControllerThreadSocketFactory.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/protocol/DefaultProtocolSocketFactory.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/protocol/Protocol.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/protocol/ProtocolSocketFactory.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/protocol/ReflectionSocketFactory.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/protocol/SSLProtocolSocketFactory.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/protocol/SecureProtocolSocketFactory.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/protocol/package.html'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/DateParseException.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/DateParser.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/DateUtil.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/EncodingUtil.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/ExceptionUtil.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/HttpURLConnection.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/IdleConnectionHandler.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/IdleConnectionTimeoutThread.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/LangUtils.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/ParameterFormatter.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/ParameterParser.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/TimeoutController.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/URIUtil.java'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 96f14f440726936ee35b0547416534e59d3db24c refers to a dead (removed) revision in file `3rdParty_sources/commons-httpclient/org/apache/commons/httpclient/util/package.html'.
Fisheye: No comparison available. Pass `N' to diff?
Index: 3rdParty_sources/httpclient/org/apache/http/auth/AUTH.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/auth/AUTH.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/auth/AUTH.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,64 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * An authentication scheme should be able to support the following + * functions: + *
+ * Authentication schemes may be stateful involving a series of + * challenge-response exchanges. + *
+ * IMPORTANT: implementations of this interface MUST also implement {@link ContextAwareAuthScheme}
+ * interface in order to remain API compatible with newer versions of HttpClient.
+ *
+ * @since 4.0
+ */
+
+public interface AuthScheme {
+
+ /**
+ * Processes the given challenge token. Some authentication schemes
+ * may involve multiple challenge-response exchanges. Such schemes must be able
+ * to maintain the state information when dealing with sequential challenges
+ *
+ * @param header the challenge header
+ */
+ void processChallenge(final Header header) throws MalformedChallengeException;
+
+ /**
+ * Returns textual designation of the given authentication scheme.
+ *
+ * @return the name of the given authentication scheme
+ */
+ String getSchemeName();
+
+ /**
+ * Returns authentication parameter with the given name, if available.
+ *
+ * @param name The name of the parameter to be returned
+ *
+ * @return the parameter with the given name
+ */
+ String getParameter(final String name);
+
+ /**
+ * Returns authentication realm. If the concept of an authentication
+ * realm is not applicable to the given authentication scheme, returns
+ *
+ * Please note that custom authentication preferences, if used, need to be updated accordingly
+ * for the new {@link AuthScheme authentication scheme} to take effect.
+ *
+ * This parameter expects a value of type {@link String}.
+ */
+ public static final String CREDENTIAL_CHARSET = "http.auth.credential-charset";
+
+ /**
+ * Defines the order of preference for supported {@link AuthScheme}s when
+ * authenticating with the target host.
+ *
+ * This parameter expects a value of type {@link java.util.Collection}. The
+ * collection is expected to contain {@link String} instances representing
+ * a name of an authentication scheme as returned by
+ * {@link AuthScheme#getSchemeName()}.
+ */
+ public static final String TARGET_AUTH_PREF = "http.auth.target-scheme-pref";
+
+ /**
+ * Defines the order of preference for supported {@link AuthScheme}s when
+ * authenticating with the proxy host.
+ *
+ * This parameter expects a value of type {@link java.util.Collection}. The
+ * collection is expected to contain {@link String} instances representing
+ * a name of an authentication scheme as returned by
+ * {@link AuthScheme#getSchemeName()}.
+ */
+ public static final String PROXY_AUTH_PREF = "http.auth.proxy-scheme-pref";
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/auth/params/AuthParamBean.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/auth/params/AuthParamBean.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/auth/params/AuthParamBean.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,50 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * Implementations of this interface must be thread-safe. Access to shared
+ * data must be synchronized as methods of this interface may be executed
+ * from multiple threads.
+ *
+ * @since 4.0
+ *
+ * @deprecated (4.2) use {@link AuthenticationStrategy}
+ */
+@Deprecated
+public interface AuthenticationHandler {
+
+ /**
+ * Determines if the given HTTP response response represents
+ * an authentication challenge that was sent back as a result
+ * of authentication failure
+ * @param response HTTP response.
+ * @param context HTTP context.
+ * @return
+ * Implementations of this interface must be thread-safe. Access to shared data must be
+ * synchronized as methods of this interface may be executed from multiple threads.
+ *
+ * @since 4.2
+ */
+public interface AuthenticationStrategy {
+
+ /**
+ * Determines if the given HTTP response response represents
+ * an authentication challenge that was sent back as a result
+ * of authentication failure.
+ *
+ * @param authhost authentication host.
+ * @param response HTTP response.
+ * @param context HTTP context.
+ * @return
+ * Implementations of this interface must be thread-safe. Access to shared
+ * data must be synchronized as methods of this interface may be executed
+ * from multiple threads.
+ *
+ * @since 4.0
+ */
+public interface CredentialsProvider {
+
+ /**
+ * Sets the {@link Credentials credentials} for the given authentication
+ * scope. Any previous credentials for the given scope will be overwritten.
+ *
+ * @param authscope the {@link AuthScope authentication scope}
+ * @param credentials the authentication {@link Credentials credentials}
+ * for the given scope.
+ *
+ * @see #getCredentials(AuthScope)
+ */
+ void setCredentials(AuthScope authscope, Credentials credentials);
+
+ /**
+ * Get the {@link Credentials credentials} for the given authentication scope.
+ *
+ * @param authscope the {@link AuthScope authentication scope}
+ * @return the credentials
+ *
+ * @see #setCredentials(AuthScope, Credentials)
+ */
+ Credentials getCredentials(AuthScope authscope);
+
+ /**
+ * Clears all credentials.
+ */
+ void clear();
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/HttpClient.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/HttpClient.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/HttpClient.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,281 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * Implementations of this interface must be thread-safe. Access to shared
+ * data must be synchronized as methods of this interface may be executed
+ * from multiple threads.
+ *
+ * @since 4.0
+ */
+public interface HttpRequestRetryHandler {
+
+ /**
+ * Determines if a method should be retried after an IOException
+ * occurs during execution.
+ *
+ * @param exception the exception that occurred
+ * @param executionCount the number of times this method has been
+ * unsuccessfully executed
+ * @param context the context for the request execution
+ *
+ * @return
+ * Implementations of this interface must be thread-safe. Access to shared
+ * data must be synchronized as methods of this interface may be executed
+ * from multiple threads.
+ *
+ * @since 4.0
+ *
+ * @deprecated (4.1) use {@link RedirectStrategy}
+ */
+@Deprecated
+public interface RedirectHandler {
+
+ /**
+ * Determines if a request should be redirected to a new location
+ * given the response from the target server.
+ *
+ * @param response the response received from the target server
+ * @param context the context for the request execution
+ *
+ * @return
+ * Implementations of this interface must be thread-safe. Access to shared
+ * data must be synchronized as methods of this interface may be executed
+ * from multiple threads.
+ *
+ * @since 4.1
+ */
+public interface RedirectStrategy {
+
+ /**
+ * Determines if a request should be redirected to a new location
+ * given the response from the target server.
+ *
+ * @param request the executed request
+ * @param response the response received from the target server
+ * @param context the context for the request execution
+ *
+ * @return
+ * The HTTP DELETE method is defined in section 9.7 of
+ * RFC2616:
+ *
+ * The HTTP GET method is defined in section 9.3 of
+ * RFC2616:
+ *
+ * The HTTP HEAD method is defined in section 9.4 of
+ * RFC2616:
+ *
+ * The HTTP OPTIONS method is defined in section 9.2 of
+ * RFC2616:
+ *
+ * The HTTP PATCH method is defined in RF5789: null
.
+ *
+ * @return the authentication realm
+ */
+ String getRealm();
+
+ /**
+ * Tests if the authentication scheme is provides authorization on a per
+ * connection basis instead of usual per request basis
+ *
+ * @return true if the scheme is connection based, false
+ * if the scheme is request based.
+ */
+ boolean isConnectionBased();
+
+ /**
+ * Authentication process may involve a series of challenge-response exchanges.
+ * This method tests if the authorization process has been completed, either
+ * successfully or unsuccessfully, that is, all the required authorization
+ * challenges have been processed in their entirety.
+ *
+ * @return true if the authentication process has been completed,
+ * false otherwise.
+ */
+ boolean isComplete();
+
+ /**
+ * Produces an authorization string for the given set of {@link Credentials}.
+ *
+ * @param credentials The set of credentials to be used for athentication
+ * @param request The request being authenticated
+ * @throws AuthenticationException if authorization string cannot
+ * be generated due to an authentication failure
+ *
+ * @return the authorization string
+ *
+ * @deprecated (4.1) Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, org.apache.http.protocol.HttpContext)}
+ */
+ @Deprecated
+ Header authenticate(Credentials credentials, HttpRequest request)
+ throws AuthenticationException;
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/auth/AuthSchemeFactory.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/auth/AuthSchemeFactory.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/auth/AuthSchemeFactory.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,48 @@
+/*
+ * ====================================================================
+ * 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
+ * true
if {@link AuthOption}s are available, false
+ * otherwise.
+ *
+ * @since 4.2
+ */
+ public boolean hasAuthOptions() {
+ return this.authOptions != null && !this.authOptions.isEmpty();
+ }
+
+ /**
+ * Updates the auth state with a queue of {@link AuthOption}s.
+ *
+ * @param authOptions a queue of auth options. May not be null or empty.
+ *
+ * @since 4.2
+ */
+ public void update(final Queuenull
.
+ *
+ */
+
+package org.apache.http.auth;
+
+import org.apache.http.annotation.Immutable;
+
+import org.apache.http.ProtocolException;
+
+/**
+ * Signals a failure in authentication process
+ *
+ *
+ * @since 4.0
+ */
+@Immutable
+public class AuthenticationException extends ProtocolException {
+
+ private static final long serialVersionUID = -6794031905674764776L;
+
+ /**
+ * Creates a new AuthenticationException with a null detail message.
+ */
+ public AuthenticationException() {
+ super();
+ }
+
+ /**
+ * Creates a new AuthenticationException with the specified message.
+ *
+ * @param message the exception detail message
+ */
+ public AuthenticationException(String message) {
+ super(message);
+ }
+
+ /**
+ * Creates a new AuthenticationException with the specified detail message and cause.
+ *
+ * @param message the exception detail message
+ * @param cause the Throwable that caused this exception, or null
+ * if the cause is unavailable, unknown, or not a Throwable
+ */
+ public AuthenticationException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/auth/BasicUserPrincipal.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/auth/BasicUserPrincipal.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/auth/BasicUserPrincipal.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,89 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * true
if user authentication is required,
+ * false
otherwise.
+ */
+ boolean isAuthenticationRequested(
+ HttpResponse response,
+ HttpContext context);
+
+ /**
+ * Extracts from the given HTTP response a collection of authentication
+ * challenges, each of which represents an authentication scheme supported
+ * by the authentication host.
+ *
+ * @param response HTTP response.
+ * @param context HTTP context.
+ * @return a collection of challenges keyed by names of corresponding
+ * authentication schemes.
+ * @throws MalformedChallengeException if one of the authentication
+ * challenges is not valid or malformed.
+ */
+ Maptrue
if user authentication is required,
+ * false
otherwise.
+ */
+ boolean isAuthenticationRequested(
+ HttpHost authhost,
+ HttpResponse response,
+ HttpContext context);
+
+ /**
+ * Extracts from the given HTTP response a collection of authentication
+ * challenges, each of which represents an authentication scheme supported
+ * by the authentication host.
+ *
+ * @param authhost authentication host.
+ * @param response HTTP response.
+ * @param context HTTP context.
+ * @return a collection of challenges keyed by names of corresponding
+ * authentication schemes.
+ * @throws MalformedChallengeException if one of the authentication
+ * challenges is not valid or malformed.
+ */
+ MapThrowable
that resulted or by examining the resulting
+ * response (e.g. for its status code).
+ *
+ * @since 4.2
+ *
+ */
+public interface ConnectionBackoffStrategy {
+
+ /**
+ * Determines whether seeing the given Throwable
as
+ * a result of request execution should result in a backoff
+ * signal.
+ * @param t the Throwable
that happened
+ * @return true
if a backoff signal should be
+ * given
+ */
+ boolean shouldBackoff(Throwable t);
+
+ /**
+ * Determines whether receiving the given {@link HttpResponse} as
+ * a result of request execution should result in a backoff
+ * signal. Implementations MUST restrict themselves to examining
+ * the response header and MUST NOT consume any of the response
+ * body, if any.
+ * @param resp the HttpResponse
that was received
+ * @return true
if a backoff signal should be
+ * given
+ */
+ boolean shouldBackoff(HttpResponse resp);
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/CookieStore.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/CookieStore.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/CookieStore.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,71 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ *
+ * HttpClient httpclient = new DefaultHttpClient();
+ *
+ * // Prepare a request object
+ * HttpGet httpget = new HttpGet("http://www.apache.org/");
+ *
+ * // Execute the request
+ * HttpResponse response = httpclient.execute(httpget);
+ *
+ * // Examine the response status
+ * System.out.println(response.getStatusLine());
+ *
+ * // Get hold of the response entity
+ * HttpEntity entity = response.getEntity();
+ *
+ * // If the response does not enclose an entity, there is no need
+ * // to worry about connection release
+ * if (entity != null) {
+ * InputStream instream = entity.getContent();
+ * try {
+ *
+ * BufferedReader reader = new BufferedReader(
+ * new InputStreamReader(instream));
+ * // do something useful with the response
+ * System.out.println(reader.readLine());
+ *
+ * } catch (IOException ex) {
+ *
+ * // In case of an IOException the connection will be released
+ * // back to the connection manager automatically
+ * throw ex;
+ *
+ * } catch (RuntimeException ex) {
+ *
+ * // In case of an unexpected exception you may want to abort
+ * // the HTTP request in order to shut down the underlying
+ * // connection and release it back to the connection manager.
+ * httpget.abort();
+ * throw ex;
+ *
+ * } finally {
+ *
+ * // Closing the input stream will trigger connection release
+ * instream.close();
+ *
+ * }
+ *
+ * // When HttpClient instance is no longer needed,
+ * // shut down the connection manager to ensure
+ * // immediate deallocation of all system resources
+ * httpclient.getConnectionManager().shutdown();
+ * }
+ *
+ *
+ * @since 4.0
+ */
+public interface HttpClient {
+
+
+ /**
+ * Obtains the parameters for this client.
+ * These parameters will become defaults for all requests being
+ * executed with this client, and for the parameters of
+ * dependent objects in this client.
+ *
+ * @return the default parameters
+ */
+ HttpParams getParams();
+
+ /**
+ * Obtains the connection manager used by this client.
+ *
+ * @return the connection manager
+ */
+ ClientConnectionManager getConnectionManager();
+
+ /**
+ * Executes a request using the default context.
+ *
+ * @param request the request to execute
+ *
+ * @return the response to the request. This is always a final response,
+ * never an intermediate response with an 1xx status code.
+ * Whether redirects or authentication challenges will be returned
+ * or handled automatically depends on the implementation and
+ * configuration of this client.
+ * @throws IOException in case of a problem or the connection was aborted
+ * @throws ClientProtocolException in case of an http protocol error
+ */
+ HttpResponse execute(HttpUriRequest request)
+ throws IOException, ClientProtocolException;
+
+ /**
+ * Executes a request using the given context.
+ * The route to the target will be determined by the HTTP client.
+ *
+ * @param request the request to execute
+ * @param context the context to use for the execution, or
+ * null
to use the default context
+ *
+ * @return the response to the request. This is always a final response,
+ * never an intermediate response with an 1xx status code.
+ * Whether redirects or authentication challenges will be returned
+ * or handled automatically depends on the implementation and
+ * configuration of this client.
+ * @throws IOException in case of a problem or the connection was aborted
+ * @throws ClientProtocolException in case of an http protocol error
+ */
+ HttpResponse execute(HttpUriRequest request, HttpContext context)
+ throws IOException, ClientProtocolException;
+
+ /**
+ * Executes a request to the target using the default context.
+ *
+ * @param target the target host for the request.
+ * Implementations may accept null
+ * if they can still determine a route, for example
+ * to a default target or by inspecting the request.
+ * @param request the request to execute
+ *
+ * @return the response to the request. This is always a final response,
+ * never an intermediate response with an 1xx status code.
+ * Whether redirects or authentication challenges will be returned
+ * or handled automatically depends on the implementation and
+ * configuration of this client.
+ * @throws IOException in case of a problem or the connection was aborted
+ * @throws ClientProtocolException in case of an http protocol error
+ */
+ HttpResponse execute(HttpHost target, HttpRequest request)
+ throws IOException, ClientProtocolException;
+
+ /**
+ * Executes a request to the target using the given context.
+ *
+ * @param target the target host for the request.
+ * Implementations may accept null
+ * if they can still determine a route, for example
+ * to a default target or by inspecting the request.
+ * @param request the request to execute
+ * @param context the context to use for the execution, or
+ * null
to use the default context
+ *
+ * @return the response to the request. This is always a final response,
+ * never an intermediate response with an 1xx status code.
+ * Whether redirects or authentication challenges will be returned
+ * or handled automatically depends on the implementation and
+ * configuration of this client.
+ * @throws IOException in case of a problem or the connection was aborted
+ * @throws ClientProtocolException in case of an http protocol error
+ */
+ HttpResponse execute(HttpHost target, HttpRequest request,
+ HttpContext context)
+ throws IOException, ClientProtocolException;
+
+ /**
+ * Executes a request using the default context and processes the
+ * response using the given response handler.
+ *
+ * @param request the request to execute
+ * @param responseHandler the response handler
+ *
+ * @return the response object as generated by the response handler.
+ * @throws IOException in case of a problem or the connection was aborted
+ * @throws ClientProtocolException in case of an http protocol error
+ */
+ null
+ * if they can still determine a route, for example
+ * to a default target or by inspecting the request.
+ * @param request the request to execute
+ * @param responseHandler the response handler
+ *
+ * @return the response object as generated by the response handler.
+ * @throws IOException in case of a problem or the connection was aborted
+ * @throws ClientProtocolException in case of an http protocol error
+ */
+ null
+ * if they can still determine a route, for example
+ * to a default target or by inspecting the request.
+ * @param request the request to execute
+ * @param responseHandler the response handler
+ * @param context the context to use for the execution, or
+ * null
to use the default context
+ *
+ * @return the response object as generated by the response handler.
+ * @throws IOException in case of a problem or the connection was aborted
+ * @throws ClientProtocolException in case of an http protocol error
+ */
+ true
if the method should be retried, false
+ * otherwise
+ */
+ boolean retryRequest(IOException exception, int executionCount, HttpContext context);
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/HttpResponseException.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/HttpResponseException.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/HttpResponseException.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,52 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * true
if the request should be redirected, false
+ * otherwise
+ */
+ boolean isRedirectRequested(HttpResponse response, HttpContext context);
+
+ /**
+ * Determines the location request is expected to be redirected to
+ * given the response from the target server and the current request
+ * execution context.
+ *
+ * @param response the response received from the target server
+ * @param context the context for the request execution
+ *
+ * @return redirect URI
+ */
+ URI getLocationURI(HttpResponse response, HttpContext context)
+ throws ProtocolException;
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/RedirectStrategy.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/RedirectStrategy.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/RedirectStrategy.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,81 @@
+/*
+ * ====================================================================
+ * 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
+ * true
if the request should be redirected, false
+ * otherwise
+ */
+ boolean isRedirected(
+ HttpRequest request,
+ HttpResponse response,
+ HttpContext context) throws ProtocolException;
+
+ /**
+ * Determines the redirect location given the response from the target
+ * server and the current request execution context and generates a new
+ * request to be sent to the location.
+ *
+ * @param request the executed request
+ * @param response the response received from the target server
+ * @param context the context for the request execution
+ *
+ * @return redirected request
+ */
+ HttpUriRequest getRedirect(
+ HttpRequest request,
+ HttpResponse response,
+ HttpContext context) throws ProtocolException;
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/RequestDirector.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/RequestDirector.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/RequestDirector.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,74 @@
+/*
+ * ====================================================================
+ * 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
+ *
Note:
+ * For the time being, a new director is instantiated for each request.
+ * This is the same behavior as for HttpMethodDirector
+ * in HttpClient 3.
+ *
+ * @param target the target host for the request.
+ * Implementations may accept null
+ * if they can still determine a route, for example
+ * to a default target or by inspecting the request.
+ * @param request the request to execute
+ * @param context the context for executing the request
+ *
+ * @return the final response to the request.
+ * This is never an intermediate response with status code 1xx.
+ *
+ * @throws HttpException in case of a problem
+ * @throws IOException in case of an IO problem
+ * or if the connection was aborted
+ */
+ HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
+ throws HttpException, IOException;
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/ResponseHandler.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/ResponseHandler.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/ResponseHandler.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,54 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * true
if the method should be retried, false
+ * otherwise
+ */
+ boolean retryRequest(HttpResponse response, int executionCount, HttpContext context);
+
+ /**
+ * @return The interval between the subsequent auto-retries.
+ */
+ long getRetryInterval();
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/UserTokenHandler.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/UserTokenHandler.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/UserTokenHandler.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,58 @@
+/*
+ * ====================================================================
+ * 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
+ * null
if the context does not contain any resources or details
+ * specific to the current user.
+ *
+ * The user token will be used to ensure that user specific resources will not
+ * be shared with or reused by other users.
+ *
+ * @since 4.0
+ */
+public interface UserTokenHandler {
+
+ /**
+ * The token object returned by this method is expected to uniquely
+ * identify the current user if the context is user specific or to be
+ * null
if it is not.
+ *
+ * @param context the execution context
+ *
+ * @return user token that uniquely identifies the user or
+ * null if the context is not user specific.
+ */
+ Object getUserToken(HttpContext context);
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/entity/DecompressingEntity.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/entity/DecompressingEntity.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/entity/DecompressingEntity.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,102 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ *
deflate
means a zlib
stream as defined in RFC1950. Some server
+ * implementations have misinterpreted RFC2616 to mean that a deflate
stream as
+ * defined in RFC1951 should be used (or maybe they did that since that's how IE behaves?). It's
+ * confusing that deflate
in HTTP 1.1 means zlib
streams rather than
+ * deflate
streams. We handle both types in here, since that's what is seen on the
+ * internet. Moral - prefer gzip
!
+ *
+ * @see GzipDecompressingEntity
+ *
+ * @since 4.1
+ */
+public class DeflateDecompressingEntity extends DecompressingEntity {
+
+ /**
+ * Creates a new {@link DeflateDecompressingEntity} which will wrap the specified
+ * {@link HttpEntity}.
+ *
+ * @param entity
+ * a non-null {@link HttpEntity} to be wrapped
+ */
+ public DeflateDecompressingEntity(final HttpEntity entity) {
+ super(entity);
+ }
+
+ /**
+ * Returns the non-null InputStream that should be returned to by all requests to
+ * {@link #getContent()}.
+ *
+ * @return a non-null InputStream
+ * @throws IOException if there was a problem
+ */
+ @Override
+ InputStream getDecompressingInputStream(final InputStream wrapped) throws IOException {
+ /*
+ * A zlib stream will have a header.
+ *
+ * CMF | FLG [| DICTID ] | ...compressed data | ADLER32 |
+ *
+ * * CMF is one byte.
+ *
+ * * FLG is one byte.
+ *
+ * * DICTID is four bytes, and only present if FLG.FDICT is set.
+ *
+ * Sniff the content. Does it look like a zlib stream, with a CMF, etc? c.f. RFC1950,
+ * section 2.2. http://tools.ietf.org/html/rfc1950#page-4
+ *
+ * We need to see if it looks like a proper zlib stream, or whether it is just a deflate
+ * stream. RFC2616 calls zlib streams deflate. Confusing, isn't it? That's why some servers
+ * implement deflate Content-Encoding using deflate streams, rather than zlib streams.
+ *
+ * We could start looking at the bytes, but to be honest, someone else has already read
+ * the RFCs and implemented that for us. So we'll just use the JDK libraries and exception
+ * handling to do this. If that proves slow, then we could potentially change this to check
+ * the first byte - does it look like a CMF? What about the second byte - does it look like
+ * a FLG, etc.
+ */
+
+ /* We read a small buffer to sniff the content. */
+ byte[] peeked = new byte[6];
+
+ PushbackInputStream pushback = new PushbackInputStream(wrapped, peeked.length);
+
+ int headerLength = pushback.read(peeked);
+
+ if (headerLength == -1) {
+ throw new IOException("Unable to read the response");
+ }
+
+ /* We try to read the first uncompressed byte. */
+ byte[] dummy = new byte[1];
+
+ Inflater inf = new Inflater();
+
+ try {
+ int n;
+ while ((n = inf.inflate(dummy)) == 0) {
+ if (inf.finished()) {
+
+ /* Not expecting this, so fail loudly. */
+ throw new IOException("Unable to read the response");
+ }
+
+ if (inf.needsDictionary()) {
+
+ /* Need dictionary - then it must be zlib stream with DICTID part? */
+ break;
+ }
+
+ if (inf.needsInput()) {
+ inf.setInput(peeked);
+ }
+ }
+
+ if (n == -1) {
+ throw new IOException("Unable to read the response");
+ }
+
+ /*
+ * We read something without a problem, so it's a valid zlib stream. Just need to reset
+ * and return an unused InputStream now.
+ */
+ pushback.unread(peeked, 0, headerLength);
+ return new InflaterInputStream(pushback);
+ } catch (DataFormatException e) {
+
+ /* Presume that it's an RFC1951 deflate stream rather than RFC1950 zlib stream and try
+ * again. */
+ pushback.unread(peeked, 0, headerLength);
+ return new InflaterInputStream(pushback, new Inflater(true));
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public Header getContentEncoding() {
+
+ /* This HttpEntityWrapper has dealt with the Content-Encoding. */
+ return null;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public long getContentLength() {
+
+ /* Length of inflated content is unknown. */
+ return -1;
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/entity/GzipDecompressingEntity.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/entity/GzipDecompressingEntity.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/entity/GzipDecompressingEntity.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,79 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ *
+ * The DELETE method requests that the origin server delete the resource
+ * identified by the Request-URI. [...] The client cannot
+ * be guaranteed that the operation has been carried out, even if the
+ * status code returned from the origin server indicates that the action
+ * has been completed successfully.
+ *
+ *
+ * @since 4.0
+ */
+@NotThreadSafe // HttpRequestBase is @NotThreadSafe
+public class HttpDelete extends HttpRequestBase {
+
+ public final static String METHOD_NAME = "DELETE";
+
+
+ public HttpDelete() {
+ super();
+ }
+
+ public HttpDelete(final URI uri) {
+ super();
+ setURI(uri);
+ }
+
+ /**
+ * @throws IllegalArgumentException if the uri is invalid.
+ */
+ public HttpDelete(final String uri) {
+ super();
+ setURI(URI.create(uri));
+ }
+
+ @Override
+ public String getMethod() {
+ return METHOD_NAME;
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpEntityEnclosingRequestBase.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -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
+ *
+ * The GET method means retrieve whatever information (in the form of an
+ * entity) is identified by the Request-URI. If the Request-URI refers
+ * to a data-producing process, it is the produced data which shall be
+ * returned as the entity in the response and not the source text of the
+ * process, unless that text happens to be the output of the process.
+ *
+ *
+ * The HEAD method is identical to GET except that the server MUST NOT
+ * return a message-body in the response. The metainformation contained
+ * in the HTTP headers in response to a HEAD request SHOULD be identical
+ * to the information sent in response to a GET request. This method can
+ * be used for obtaining metainformation about the entity implied by the
+ * request without transferring the entity-body itself. This method is
+ * often used for testing hypertext links for validity, accessibility,
+ * and recent modification.
+ *
+ *
+ * The OPTIONS method represents a request for information about the
+ * communication options available on the request/response chain
+ * identified by the Request-URI. This method allows the client to
+ * determine the options and/or requirements associated with a resource,
+ * or the capabilities of a server, without implying a resource action
+ * or initiating a resource retrieval.
+ *
+ * The PATCH
+ * method requests that a set of changes described in the request entity be
+ * applied to the resource identified by the Request- URI. Differs from the PUT
+ * method in the way the server processes the enclosed entity to modify the
+ * resource identified by the Request-URI. In a PUT request, the enclosed entity
+ * origin server, and the client is requesting that the stored version be
+ * replaced. With PATCH, however, the enclosed entity contains a set of
+ * instructions describing how a resource currently residing on the origin
+ * server should be modified to produce a new version.
+ *
+ * The HTTP POST method is defined in section 9.5 of + * RFC2616: + *
+ * The POST method is used to request that the origin server accept the entity + * enclosed in the request as a new subordinate of the resource identified by + * the Request-URI in the Request-Line. POST is designed to allow a uniform + * method to cover the following functions: + *+ * + * + * @since 4.0 + */ +@NotThreadSafe +public class HttpPost extends HttpEntityEnclosingRequestBase { + + public final static String METHOD_NAME = "POST"; + + public HttpPost() { + super(); + } + + public HttpPost(final URI uri) { + super(); + setURI(uri); + } + + /** + * @throws IllegalArgumentException if the uri is invalid. + */ + public HttpPost(final String uri) { + super(); + setURI(URI.create(uri)); + } + + @Override + public String getMethod() { + return METHOD_NAME; + } + +} Index: 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpPut.java =================================================================== diff -u --- 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpPut.java (revision 0) +++ 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpPut.java (revision 96f14f440726936ee35b0547416534e59d3db24c) @@ -0,0 +1,76 @@ +/* + * ==================================================================== + * 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 + *+ *
+ *- Annotation of existing resources
+ *- Posting a message to a bulletin board, newsgroup, mailing list, or + * similar group of articles
+ *- Providing a block of data, such as the result of submitting a form, + * to a data-handling process
+ *- Extending a database through an append operation
+ *
+ * The HTTP PUT method is defined in section 9.6 of + * RFC2616: + *
+ * The PUT method requests that the enclosed entity be stored under the + * supplied Request-URI. If the Request-URI refers to an already + * existing resource, the enclosed entity SHOULD be considered as a + * modified version of the one residing on the origin server. + *+ * + * + * @since 4.0 + */ +@NotThreadSafe +public class HttpPut extends HttpEntityEnclosingRequestBase { + + public final static String METHOD_NAME = "PUT"; + + public HttpPut() { + super(); + } + + public HttpPut(final URI uri) { + super(); + setURI(uri); + } + + /** + * @throws IllegalArgumentException if the uri is invalid. + */ + public HttpPut(final String uri) { + super(); + setURI(URI.create(uri)); + } + + @Override + public String getMethod() { + return METHOD_NAME; + } + +} Index: 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpRequestBase.java =================================================================== diff -u --- 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpRequestBase.java (revision 0) +++ 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpRequestBase.java (revision 96f14f440726936ee35b0547416534e59d3db24c) @@ -0,0 +1,203 @@ +/* + * ==================================================================== + * 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 + *
+ * Please note URI remains unchanged in the course of request execution and
+ * is not updated if the request is redirected to another location.
+ */
+ public URI getURI() {
+ return this.uri;
+ }
+
+ public RequestLine getRequestLine() {
+ String method = getMethod();
+ ProtocolVersion ver = getProtocolVersion();
+ URI uri = getURI();
+ String uritext = null;
+ if (uri != null) {
+ uritext = uri.toASCIIString();
+ }
+ if (uritext == null || uritext.length() == 0) {
+ uritext = "/";
+ }
+ return new BasicRequestLine(method, uritext, ver);
+ }
+
+ public void setURI(final URI uri) {
+ this.uri = uri;
+ }
+
+ public void setConnectionRequest(final ClientConnectionRequest connRequest)
+ throws IOException {
+ if (this.aborted) {
+ throw new IOException("Request already aborted");
+ }
+ this.abortLock.lock();
+ try {
+ this.connRequest = connRequest;
+ } finally {
+ this.abortLock.unlock();
+ }
+ }
+
+ public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger)
+ throws IOException {
+ if (this.aborted) {
+ throw new IOException("Request already aborted");
+ }
+ this.abortLock.lock();
+ try {
+ this.releaseTrigger = releaseTrigger;
+ } finally {
+ this.abortLock.unlock();
+ }
+ }
+
+ private void cleanup() {
+ if (this.connRequest != null) {
+ this.connRequest.abortRequest();
+ this.connRequest = null;
+ }
+ if (this.releaseTrigger != null) {
+ try {
+ this.releaseTrigger.abortConnection();
+ } catch (IOException ex) {
+ }
+ this.releaseTrigger = null;
+ }
+ }
+
+ public void abort() {
+ if (this.aborted) {
+ return;
+ }
+ this.abortLock.lock();
+ try {
+ this.aborted = true;
+ cleanup();
+ } finally {
+ this.abortLock.unlock();
+ }
+ }
+
+ public boolean isAborted() {
+ return this.aborted;
+ }
+
+ /**
+ * Resets internal state of the request making it reusable.
+ *
+ * @since 4.2
+ */
+ public void reset() {
+ this.abortLock.lock();
+ try {
+ cleanup();
+ this.aborted = false;
+ } finally {
+ this.abortLock.unlock();
+ }
+ }
+
+ /**
+ * A convenience method to simplify migration from HttpClient 3.1 API. This method is
+ * equivalent to {@link #reset()}.
+ *
+ * @since 4.2
+ */
+ public void releaseConnection() {
+ reset();
+ }
+
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ HttpRequestBase clone = (HttpRequestBase) super.clone();
+ clone.abortLock = new ReentrantLock();
+ clone.aborted = false;
+ clone.releaseTrigger = null;
+ clone.connRequest = null;
+ clone.headergroup = (HeaderGroup) CloneUtils.clone(this.headergroup);
+ clone.params = (HttpParams) CloneUtils.clone(this.params);
+ return clone;
+ }
+
+ @Override
+ public String toString() {
+ return getMethod() + " " + getURI() + " " + getProtocolVersion();
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpTrace.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpTrace.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpTrace.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,79 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * The HTTP TRACE method is defined in section 9.6 of + * RFC2616: + *
+ * The TRACE method is used to invoke a remote, application-layer loop- + * back of the request message. The final recipient of the request + * SHOULD reflect the message received back to the client as the + * entity-body of a 200 (OK) response. The final recipient is either the + * origin server or the first proxy or gateway to receive a Max-Forwards + * value of zero (0) in the request (see section 14.31). A TRACE request + * MUST NOT include an entity. + *+ * + * + * @since 4.0 + */ +@NotThreadSafe +public class HttpTrace extends HttpRequestBase { + + public final static String METHOD_NAME = "TRACE"; + + public HttpTrace() { + super(); + } + + public HttpTrace(final URI uri) { + super(); + setURI(uri); + } + + /** + * @throws IllegalArgumentException if the uri is invalid. + */ + public HttpTrace(final String uri) { + super(); + setURI(URI.create(uri)); + } + + @Override + public String getMethod() { + return METHOD_NAME; + } + +} Index: 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpUriRequest.java =================================================================== diff -u --- 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpUriRequest.java (revision 0) +++ 3rdParty_sources/httpclient/org/apache/http/client/methods/HttpUriRequest.java (revision 96f14f440726936ee35b0547416534e59d3db24c) @@ -0,0 +1,86 @@ +/* + * ==================================================================== + * 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 + *
GET
,
+ * PUT
, POST
, or other.
+ */
+ String getMethod();
+
+ /**
+ * Returns the URI this request uses, such as
+ * http://example.org/path/to/file
.
+ * + * Implementations are encouraged to return + * the URI that was initially requested. + *
+ *+ * To find the final URI after any redirects have been processed, + * please see the section entitled + * HTTP execution context + * in the + * HttpClient Tutorial + *
+ */ + URI getURI(); + + /** + * Aborts execution of the request. + * + * @throws UnsupportedOperationException if the abort operation + * is not supported / cannot be implemented. + */ + void abort() throws UnsupportedOperationException; + + /** + * Tests if the request execution has been aborted. + * + * @returntrue
if the request execution has been aborted,
+ * false
otherwise.
+ */
+ boolean isAborted();
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/methods/package.html
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/methods/package.html (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/methods/package.html (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,36 @@
+
+
+
+
+
+Request implementations for the various HTTP methods like GET and POST.
+
+
+
Index: 3rdParty_sources/httpclient/org/apache/http/client/package.html
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/package.html (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/package.html (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,89 @@
+
+
+
+
+
+The API for client-side HTTP communication.
+
+The usual execution flow can be demonstrated by the
+code snippet below:
+
++HttpClient httpclient = new DefaultHttpClient(); + +// Prepare a request object +HttpGet httpget = new HttpGet("http://www.apache.org/"); + +// Execute the request +HttpResponse response = httpclient.execute(httpget); + +// Examine the response status +System.out.println(response.getStatusLine()); + +// Get hold of the response entity +HttpEntity entity = response.getEntity(); + +// If the response does not enclose an entity, there is no need +// to worry about connection release +if (entity != null) { + InputStream instream = entity.getContent(); + try { + + BufferedReader reader = new BufferedReader( + new InputStreamReader(instream)); + // do something useful with the response + System.out.println(reader.readLine()); + + } catch (IOException ex) { + + // In case of an IOException the connection will be released + // back to the connection manager automatically + throw ex; + + } catch (RuntimeException ex) { + + // In case of an unexpected exception you may want to abort + // the HTTP request in order to shut down the underlying + // connection and release it back to the connection manager. + httpget.abort(); + throw ex; + + } finally { + + // Closing the input stream will trigger connection release + instream.close(); + + } +} + ++ + + Index: 3rdParty_sources/httpclient/org/apache/http/client/params/AllClientPNames.java =================================================================== diff -u --- 3rdParty_sources/httpclient/org/apache/http/client/params/AllClientPNames.java (revision 0) +++ 3rdParty_sources/httpclient/org/apache/http/client/params/AllClientPNames.java (revision 96f14f440726936ee35b0547416534e59d3db24c) @@ -0,0 +1,58 @@ +/* + * ==================================================================== + * + * 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 + *
+ * This parameter expects a value of type {@link Boolean}. + *
+ */ + public static final String HANDLE_REDIRECTS = "http.protocol.handle-redirects"; + + /** + * Defines whether relative redirects should be rejected. HTTP specification + * requires the location value be an absolute URI. + *+ * This parameter expects a value of type {@link Boolean}. + *
+ */ + public static final String REJECT_RELATIVE_REDIRECT = "http.protocol.reject-relative-redirect"; + + /** + * Defines the maximum number of redirects to be followed. + * The limit on number of redirects is intended to prevent infinite loops. + *+ * This parameter expects a value of type {@link Integer}. + *
+ */ + public static final String MAX_REDIRECTS = "http.protocol.max-redirects"; + + /** + * Defines whether circular redirects (redirects to the same location) should be allowed. + * The HTTP spec is not sufficiently clear whether circular redirects are permitted, + * therefore optionally they can be enabled + *+ * This parameter expects a value of type {@link Boolean}. + *
+ */ + public static final String ALLOW_CIRCULAR_REDIRECTS = "http.protocol.allow-circular-redirects"; + + /** + * Defines whether authentication should be handled automatically. + *+ * This parameter expects a value of type {@link Boolean}. + *
+ */ + public static final String HANDLE_AUTHENTICATION = "http.protocol.handle-authentication"; + + /** + * Defines the name of the cookie specification to be used for HTTP state management. + *+ * This parameter expects a value of type {@link String}. + *
+ */ + public static final String COOKIE_POLICY = "http.protocol.cookie-policy"; + + /** + * Defines the virtual host to be used in theHost
+ * request header instead of the physical host.
+ * + * This parameter expects a value of type {@link org.apache.http.HttpHost}. + *
+ * If a port is not provided, it will be derived from the request URL. + */ + public static final String VIRTUAL_HOST = "http.virtual-host"; + + /** + * Defines the request headers to be sent per default with each request. + *+ * This parameter expects a value of type {@link java.util.Collection}. The + * collection is expected to contain {@link org.apache.http.Header}s. + *
+ */ + public static final String DEFAULT_HEADERS = "http.default-headers"; + + /** + * Defines the default host. The default value will be used if the target host is + * not explicitly specified in the request URI. + *+ * This parameter expects a value of type {@link org.apache.http.HttpHost}. + *
+ */ + public static final String DEFAULT_HOST = "http.default-host"; + + /** + * Defines the timeout in milliseconds used when retrieving an instance of + * {@link org.apache.http.conn.ManagedClientConnection} from the + * {@link org.apache.http.conn.ClientConnectionManager}. + *+ * This parameter expects a value of type {@link Long}. + *
+ * @since 4.2
+ */
+ public static final String CONN_MANAGER_TIMEOUT = "http.conn-manager.timeout";
+
+}
+
Index: 3rdParty_sources/httpclient/org/apache/http/client/params/ClientParamBean.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/params/ClientParamBean.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/params/ClientParamBean.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,104 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * Instances of this class are stateless, therefore they're thread-safe and immutable.
+ *
+ * @see "http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5"
+ *
+ * @since 4.1
+ */
+@Immutable
+public class RequestAcceptEncoding implements HttpRequestInterceptor {
+
+ /**
+ * Adds the header {@code "Accept-Encoding: gzip,deflate"} to the request.
+ */
+ public void process(
+ final HttpRequest request,
+ final HttpContext context) throws HttpException, IOException {
+
+ /* Signal support for Accept-Encoding transfer encodings. */
+ if (!request.containsHeader("Accept-Encoding")) {
+ request.addHeader("Accept-Encoding", "gzip,deflate");
+ }
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/protocol/RequestAddCookies.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/protocol/RequestAddCookies.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/protocol/RequestAddCookies.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,226 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ *
+ * Instances of this class are stateless and immutable, therefore threadsafe.
+ *
+ * @since 4.1
+ *
+ */
+@Immutable
+public class ResponseContentEncoding implements HttpResponseInterceptor {
+
+ public static final String UNCOMPRESSED = "http.client.response.uncompressed";
+
+ /**
+ * Handles the following {@code Content-Encoding}s by
+ * using the appropriate decompressor to wrap the response Entity:
+ *
+ * Example Code:
+ *
+ *
+ * Example Code:
+ *
+ *
+ * The value is expected to be encoded form data.
+ */
+ public URIBuilder setQuery(final String query) {
+ this.queryParams = parseQuery(query, Consts.UTF_8);
+ this.encodedQuery = null;
+ this.encodedSchemeSpecificPart = null;
+ return this;
+ }
+
+ /**
+ * Adds parameter to URI query. The parameter name and value are expected to be unescaped
+ * and may contain non ASCII characters.
+ */
+ public URIBuilder addParameter(final String param, final String value) {
+ if (this.queryParams == null) {
+ this.queryParams = new ArrayList
+ * This is typically useful while parsing an HTTP PUT.
+ *
+ * @param uri
+ * uri to parse
+ * @param encoding
+ * encoding to use while parsing the query
+ */
+ public static List
+ * This is typically used while parsing an HTTP POST.
+ *
+ * @param entity
+ * The entity to parse
+ * @throws IOException
+ * If there was an exception getting the entity's data.
+ */
+ public static List
+ * This list is the same as the {@code unreserved} list in
+ * RFC 2396
+ */
+ private static final BitSet UNRESERVED = new BitSet(256);
+ /**
+ * Punctuation characters: , ; : $ & + =
+ *
+ * These are the additional characters allowed by userinfo.
+ */
+ private static final BitSet PUNCT = new BitSet(256);
+ /** Characters which are safe to use in userinfo, i.e. {@link #UNRESERVED} plus {@link #PUNCT}uation */
+ private static final BitSet USERINFO = new BitSet(256);
+ /** Characters which are safe to use in a path, i.e. {@link #UNRESERVED} plus {@link #PUNCT}uation plus / @ */
+ private static final BitSet PATHSAFE = new BitSet(256);
+ /** Characters which are safe to use in a fragment, i.e. {@link #RESERVED} plus {@link #UNRESERVED} */
+ private static final BitSet FRAGMENT = new BitSet(256);
+
+ /**
+ * Reserved characters, i.e. {@code ;/?:@&=+$,[]}
+ *
+ * This list is the same as the {@code reserved} list in
+ * RFC 2396
+ * as augmented by
+ * RFC 2732
+ */
+ private static final BitSet RESERVED = new BitSet(256);
+
+
+ /**
+ * Safe characters for x-www-form-urlencoded data, as per java.net.URLEncoder and browser behaviour,
+ * i.e. alphanumeric plus {@code "-", "_", ".", "*"}
+ */
+ private static final BitSet URLENCODER = new BitSet(256);
+
+ static {
+ // unreserved chars
+ // alpha characters
+ for (int i = 'a'; i <= 'z'; i++) {
+ UNRESERVED.set(i);
+ }
+ for (int i = 'A'; i <= 'Z'; i++) {
+ UNRESERVED.set(i);
+ }
+ // numeric characters
+ for (int i = '0'; i <= '9'; i++) {
+ UNRESERVED.set(i);
+ }
+ UNRESERVED.set('_'); // these are the charactes of the "mark" list
+ UNRESERVED.set('-');
+ UNRESERVED.set('.');
+ UNRESERVED.set('*');
+ URLENCODER.or(UNRESERVED); // skip remaining unreserved characters
+ UNRESERVED.set('!');
+ UNRESERVED.set('~');
+ UNRESERVED.set('\'');
+ UNRESERVED.set('(');
+ UNRESERVED.set(')');
+ // punct chars
+ PUNCT.set(',');
+ PUNCT.set(';');
+ PUNCT.set(':');
+ PUNCT.set('$');
+ PUNCT.set('&');
+ PUNCT.set('+');
+ PUNCT.set('=');
+ // Safe for userinfo
+ USERINFO.or(UNRESERVED);
+ USERINFO.or(PUNCT);
+
+ // URL path safe
+ PATHSAFE.or(UNRESERVED);
+ PATHSAFE.set('/'); // segment separator
+ PATHSAFE.set(';'); // param separator
+ PATHSAFE.set(':'); // rest as per list in 2396, i.e. : @ & = + $ ,
+ PATHSAFE.set('@');
+ PATHSAFE.set('&');
+ PATHSAFE.set('=');
+ PATHSAFE.set('+');
+ PATHSAFE.set('$');
+ PATHSAFE.set(',');
+
+ RESERVED.set(';');
+ RESERVED.set('/');
+ RESERVED.set('?');
+ RESERVED.set(':');
+ RESERVED.set('@');
+ RESERVED.set('&');
+ RESERVED.set('=');
+ RESERVED.set('+');
+ RESERVED.set('$');
+ RESERVED.set(',');
+ RESERVED.set('['); // added by RFC 2732
+ RESERVED.set(']'); // added by RFC 2732
+
+ FRAGMENT.or(RESERVED);
+ FRAGMENT.or(UNRESERVED);
+ }
+
+ private static final int RADIX = 16;
+
+ /**
+ * Emcode/escape a portion of a URL, to use with the query part ensure {@code plusAsBlank} is true.
+ *
+ * @param content the portion to decode
+ * @param charset the charset to use
+ * @param blankAsPlus if {@code true}, then convert space to '+' (e.g. for www-url-form-encoded content), otherwise leave as is.
+ * @return
+ */
+ private static String urlencode(
+ final String content,
+ final Charset charset,
+ final BitSet safechars,
+ final boolean blankAsPlus) {
+ if (content == null) {
+ return null;
+ }
+ StringBuilder buf = new StringBuilder();
+ ByteBuffer bb = charset.encode(content);
+ while (bb.hasRemaining()) {
+ int b = bb.get() & 0xff;
+ if (safechars.get(b)) {
+ buf.append((char) b);
+ } else if (blankAsPlus && b == ' ') {
+ buf.append('+');
+ } else {
+ buf.append("%");
+ char hex1 = Character.toUpperCase(Character.forDigit((b >> 4) & 0xF, RADIX));
+ char hex2 = Character.toUpperCase(Character.forDigit(b & 0xF, RADIX));
+ buf.append(hex1);
+ buf.append(hex2);
+ }
+ }
+ return buf.toString();
+ }
+
+ /**
+ * Decode/unescape a portion of a URL, to use with the query part ensure {@code plusAsBlank} is true.
+ *
+ * @param content the portion to decode
+ * @param charset the charset to use
+ * @param plusAsBlank if {@code true}, then convert '+' to space (e.g. for www-url-form-encoded content), otherwise leave as is.
+ * @return
+ */
+ private static String urldecode(
+ final String content,
+ final Charset charset,
+ final boolean plusAsBlank) {
+ if (content == null) {
+ return null;
+ }
+ ByteBuffer bb = ByteBuffer.allocate(content.length());
+ CharBuffer cb = CharBuffer.wrap(content);
+ while (cb.hasRemaining()) {
+ char c = cb.get();
+ if (c == '%' && cb.remaining() >= 2) {
+ char uc = cb.get();
+ char lc = cb.get();
+ int u = Character.digit(uc, 16);
+ int l = Character.digit(lc, 16);
+ if (u != -1 && l != -1) {
+ bb.put((byte) ((u << 4) + l));
+ } else {
+ bb.put((byte) '%');
+ bb.put((byte) uc);
+ bb.put((byte) lc);
+ }
+ } else if (plusAsBlank && c == '+') {
+ bb.put((byte) ' ');
+ } else {
+ bb.put((byte) c);
+ }
+ }
+ bb.flip();
+ return charset.decode(bb).toString();
+ }
+
+ /**
+ * Decode/unescape www-url-form-encoded content.
+ *
+ * @param content the content to decode, will decode '+' as space
+ * @param charset the charset to use
+ * @return
+ */
+ private static String decodeFormFields (final String content, final String charset) {
+ if (content == null) {
+ return null;
+ }
+ return urldecode(content, charset != null ? Charset.forName(charset) : Consts.UTF_8, true);
+ }
+
+ /**
+ * Decode/unescape www-url-form-encoded content.
+ *
+ * @param content the content to decode, will decode '+' as space
+ * @param charset the charset to use
+ * @return
+ */
+ private static String decodeFormFields (final String content, final Charset charset) {
+ if (content == null) {
+ return null;
+ }
+ return urldecode(content, charset != null ? charset : Consts.UTF_8, true);
+ }
+
+ /**
+ * Encode/escape www-url-form-encoded content.
+ *
+ * Uses the {@link #URLENCODER} set of characters, rather than
+ * the {@link #UNRSERVED} set; this is for compatibilty with previous
+ * releases, URLEncoder.encode() and most browsers.
+ *
+ * @param content the content to encode, will convert space to '+'
+ * @param charset the charset to use
+ * @return
+ */
+ private static String encodeFormFields (final String content, final String charset) {
+ if (content == null) {
+ return null;
+ }
+ return urlencode(content, charset != null ? Charset.forName(charset) :
+ Consts.UTF_8, URLENCODER, true);
+ }
+
+ /**
+ * Encode/escape www-url-form-encoded content.
+ *
+ * Uses the {@link #URLENCODER} set of characters, rather than
+ * the {@link #UNRSERVED} set; this is for compatibilty with previous
+ * releases, URLEncoder.encode() and most browsers.
+ *
+ * @param content the content to encode, will convert space to '+'
+ * @param charset the charset to use
+ * @return
+ */
+ private static String encodeFormFields (final String content, final Charset charset) {
+ if (content == null) {
+ return null;
+ }
+ return urlencode(content, charset != null ? charset : Consts.UTF_8, URLENCODER, true);
+ }
+
+ /**
+ * Encode a String using the {@link #USERINFO} set of characters.
+ *
+ * Used by URIBuilder to encode the userinfo segment.
+ *
+ * @param content the string to encode, does not convert space to '+'
+ * @param charset the charset to use
+ * @return the encoded string
+ */
+ static String encUserInfo(final String content, final Charset charset) {
+ return urlencode(content, charset, USERINFO, false);
+ }
+
+ /**
+ * Encode a String using the {@link #FRAGMENT} set of characters.
+ *
+ * Used by URIBuilder to encode the userinfo segment.
+ *
+ * @param content the string to encode, does not convert space to '+'
+ * @param charset the charset to use
+ * @return the encoded string
+ */
+ static String encFragment(final String content, final Charset charset) {
+ return urlencode(content, charset, FRAGMENT, false);
+ }
+
+ /**
+ * Encode a String using the {@link #PATHSAFE} set of characters.
+ *
+ * Used by URIBuilder to encode path segments.
+ *
+ * @param content the string to encode, does not convert space to '+'
+ * @param charset the charset to use
+ * @return the encoded string
+ */
+ static String encPath(final String content, final Charset charset) {
+ return urlencode(content, charset, PATHSAFE, false);
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/utils/package.html
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/utils/package.html (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/utils/package.html (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,36 @@
+
+
+ * Implementations of this interface must be thread-safe. Access to shared
+ * data must be synchronized as methods of this interface may be executed
+ * from multiple threads.
+ *
+ * @since 4.0
+ */
+public interface ClientConnectionManager {
+
+ /**
+ * Obtains the scheme registry used by this manager.
+ *
+ * @return the scheme registry, never
+ * The methods in this interface allow the creation of plain and layered
+ * sockets. Creating a tunnelled connection through a proxy, however,
+ * is not within the scope of the operator.
+ *
+ * Implementations of this interface must be thread-safe. Access to shared
+ * data must be synchronized as methods of this interface may be executed
+ * from multiple threads.
+ *
+ * @since 4.0
+ */
+public interface ClientConnectionOperator {
+
+ /**
+ * Creates a new connection that can be operated.
+ *
+ * @return a new, unopened connection for use with this operator
+ */
+ OperatedClientConnection createConnection();
+
+ /**
+ * Opens a connection to the given target host.
+ *
+ * @param conn the connection to open
+ * @param target the target host to connect to
+ * @param local the local address to route from, or
+ *
+ * Implementations of this interface must be thread-safe. Access to shared
+ * data must be synchronized as methods of this interface may be executed
+ * from multiple threads.
+ *
+ * @since 4.0
+ */
+public interface ConnectionKeepAliveStrategy {
+
+ /**
+ * Returns the duration of time which this connection can be safely kept
+ * idle. If the connection is left idle for longer than this period of time,
+ * it MUST not reused. A value of 0 or less may be returned to indicate that
+ * there is no suitable suggestion.
+ *
+ * When coupled with a {@link ConnectionReuseStrategy}, if
+ * {@link ConnectionReuseStrategy#keepAlive(HttpResponse, HttpContext)}
+ * returns true, this allows you to control how long the reuse will last. If
+ * keepAlive returns false, this should have no meaningful impact
+ *
+ * @param response
+ * The last response received over the connection.
+ * @param context
+ * the context in which the connection is being used.
+ *
+ * @return the duration in ms for which it is safe to keep the connection
+ * idle, or <=0 if no suggested duration.
+ */
+ long getKeepAliveDuration(HttpResponse response, HttpContext context);
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/ConnectionPoolTimeoutException.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/ConnectionPoolTimeoutException.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/ConnectionPoolTimeoutException.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,60 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * The methods in this interface can safely be called multiple times.
+ * The first invocation releases the connection, subsequent calls
+ * are ignored.
+ *
+ * @since 4.0
+ */
+public interface ConnectionReleaseTrigger {
+
+ /**
+ * Releases the connection with the option of keep-alive. This is a
+ * "graceful" release and may cause IO operations for consuming the
+ * remainder of a response entity. Use
+ * {@link #abortConnection abortConnection} for a hard release. The
+ * connection may be reused as specified by the duration.
+ *
+ * @throws IOException
+ * in case of an IO problem. The connection will be released
+ * anyway.
+ */
+ void releaseConnection()
+ throws IOException;
+
+ /**
+ * Releases the connection without the option of keep-alive.
+ * This is a "hard" release that implies a shutdown of the connection.
+ * Use {@link #releaseConnection()} for a graceful release.
+ *
+ * @throws IOException in case of an IO problem.
+ * The connection will be released anyway.
+ */
+ void abortConnection()
+ throws IOException;
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/DnsResolver.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/DnsResolver.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/DnsResolver.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,54 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * This class is based on
+ * By calling this method, the connection can be re-initialized
+ * with a new Socket instance before {@link #openCompleted} is called.
+ * This enabled the connection to close that socket if
+ * {@link org.apache.http.HttpConnection#shutdown shutdown}
+ * is called before it is fully open. Closing an unconnected socket
+ * will interrupt a thread that is blocked on the connect.
+ * Otherwise, that thread will either time out on the connect,
+ * or it returns successfully and then opens this connection
+ * which was just shut down.
+ *
+ * This method can be called multiple times if the connection
+ * is layered over another protocol. Note: This method
+ * will not close the previously used socket. It is
+ * the caller's responsibility to close that socket if it is
+ * no longer required.
+ *
+ * The caller must invoke {@link #openCompleted} in order to complete
+ * the process.
+ *
+ * @param sock the unconnected socket which is about to
+ * be connected.
+ * @param target the target host of this connection
+ */
+ void opening(Socket sock, HttpHost target)
+ throws IOException;
+
+ /**
+ * Signals that the connection has been successfully open.
+ * An attempt to call this method on an open connection will cause
+ * an exception.
+ *
+ * @param secure
+The lowest layer of connection handling is comprised of
+{@link org.apache.http.conn.OperatedClientConnection OperatedClientConnection}
+and
+{@link org.apache.http.conn.ClientConnectionOperator ClientConnectionOperator}.
+The connection interface extends the core
+{@link org.apache.http.HttpClientConnection HttpClientConnection}
+by operations to set and update a socket. An operator encapsulates the logic to
+open and layer sockets, typically using a
+{@link org.apache.http.conn.scheme.SocketFactory}. The socket factory for
+a protocol {@link org.apache.http.conn.scheme.Scheme} such as "http" or "https"
+can be looked up in a {@link org.apache.http.conn.scheme.SchemeRegistry}.
+Applications without a need for sophisticated connection management can use
+this layer directly.
+
+On top of that lies the connection management layer. A
+{@link org.apache.http.conn.ClientConnectionManager} internally manages
+operated connections, but hands out instances of
+{@link org.apache.http.conn.ManagedClientConnection}.
+This interface abstracts from the underlying socket operations and
+provides convenient methods for opening and updating sockets in order
+to establish a {@link org.apache.http.conn.routing.HttpRoute route}.
+The operator is encapsulated by the connection manager and called
+automatically.
+
+Connections obtained from a manager have to be returned after use.
+This can be {@link org.apache.http.conn.ConnectionReleaseTrigger triggered}
+on various levels, either by releasing the
+{@link org.apache.http.conn.ManagedClientConnection connection} directly,
+or by calling a method on
+an {@link org.apache.http.conn.BasicManagedEntity entity} received from
+the connection, or by closing the
+{@link org.apache.http.conn.EofSensorInputStream stream} from which
+that entity is being read.
+
+Connection managers will try to keep returned connections alive in
+order to re-use them for subsequent requests along the same route.
+The managed connection interface and all triggers for connection release
+provide methods to enable or disable this behavior.
+
+ * With HTTP/1.1 persistent connections, the problem arises that
+ * broken scripts could return a wrong Content-Length
+ * (there are more bytes sent than specified).
+ * Unfortunately, in some cases, this cannot be detected after the
+ * bad response, but only before the next one.
+ * So HttpClient must be able to skip those surplus lines this way.
+ *
+ * This parameter expects a value of type {@link Integer}.
+ * 0 disallows all garbage/empty lines before the status line.
+ * Use {@link java.lang.Integer#MAX_VALUE} for unlimited number.
+ *
+ * This parameter expects a value of type {@link Long}.
+ */
+ public static final String TIMEOUT = "http.conn-manager.timeout";
+
+ /**
+ * Defines the maximum number of connections per route.
+ * This limit is interpreted by client connection managers
+ * and applies to individual manager instances.
+ *
+ * This parameter expects a value of type {@link ConnPerRoute}.
+ *
+ */
+ public static final String MAX_CONNECTIONS_PER_ROUTE = "http.conn-manager.max-per-route";
+
+ /**
+ * Defines the maximum number of connections in total.
+ * This limit is interpreted by client connection managers
+ * and applies to individual manager instances.
+ *
+ * This parameter expects a value of type {@link Integer}.
+ */
+ public static final String MAX_TOTAL_CONNECTIONS = "http.conn-manager.max-total";
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/params/ConnManagerParamBean.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/params/ConnManagerParamBean.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/params/ConnManagerParamBean.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,64 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * This parameter expects a value of type {@link org.apache.http.HttpHost}.
+ *
+ * This parameter expects a value of type {@link java.net.InetAddress}.
+ *
+ * This parameter expects a value of type
+ * {@link org.apache.http.conn.routing.HttpRoute HttpRoute}.
+ *
+ * Implementations of this interface must be thread-safe. Access to shared
+ * data must be synchronized as methods of this interface may be executed
+ * from multiple threads.
+ *
+ * @since 4.0
+ */
+public interface HttpRoutePlanner {
+
+ /**
+ * Determines the route for a request.
+ *
+ * @param target the target host for the request.
+ * Implementations may accept
+An {@link org.apache.http.conn.routing.HttpRoute HttpRoute}
+is the path along which a request has to be sent to the server.
+The route starts at a local network address and may pass
+through one or more proxies before reaching the target.
+Routes through proxies can be tunnelled, and a layered protocol (TLS/SSL)
+might be put on top of the tunnel.
+The {@link org.apache.http.conn.routing.RouteTracker RouteTracker}
+helps in tracking the steps for establishing a route, while an
+{@link org.apache.http.conn.routing.HttpRouteDirector HttpRouteDirector}
+determines the next step to take.
+
+The {@link org.apache.http.conn.routing.HttpRoutePlanner HttpRoutePlanner}
+is responsible for determining a route to a given target host.
+Implementations must know about proxies to use, and about exemptions
+for hosts that should be contacted directly without a proxy.
+
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ *
+ * For example, to configure support for "https://" URLs, you could write code like the following:
+ *
+ * As a rule of thumb, plain sockets are not secure and TLS/SSL sockets are secure. However,
+ * there may be application specific deviations. For example, a plain socket to a host in the
+ * same intranet ("trusted zone") could be considered secure. On the other hand, a TLS/SSL
+ * socket could be considered insecure based on the cipher suite chosen for the connection.
+ *
+ * @param sock the connected socket to check
+ *
+ * @return
+ * SSLSocketFactory can be used to validate the identity of the HTTPS server against a list of
+ * trusted certificates and to authenticate to the HTTPS server using a private key.
+ *
+ * SSLSocketFactory will enable server authentication when supplied with
+ * a {@link KeyStore trust-store} file containing one or several trusted certificates. The client
+ * secure socket will reject the connection during the SSL session handshake if the target HTTPS
+ * server attempts to authenticate itself with a non-trusted certificate.
+ *
+ * Use JDK keytool utility to import a trusted certificate and generate a trust-store file:
+ *
+ * In special cases the standard trust verification process can be bypassed by using a custom
+ * {@link TrustStrategy}. This interface is primarily intended for allowing self-signed
+ * certificates to be accepted as trusted without having to add them to the trust-store file.
+ *
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ *
+ * SSLSocketFactory will enable client authentication when supplied with
+ * a {@link KeyStore key-store} file containing a private key/public certificate
+ * pair. The client secure socket will use the private key to authenticate
+ * itself to the target HTTPS server during the SSL session handshake if
+ * requested to do so by the server.
+ * The target HTTPS server will in its turn verify the certificate presented
+ * by the client in order to establish client's authenticity
+ *
+ * Use the following sequence of actions to generate a key-store file
+ *
+ * Use JDK keytool utility to generate a new key
+ *
+ * Issue a certificate signing request (CSR)
+ *
+ * Send the certificate request to the trusted Certificate Authority for signature.
+ * One may choose to act as her own CA and sign the certificate request using a PKI
+ * tool, such as OpenSSL.
+ *
+ * Import the trusted CA root certificate
+ *
+ * Import the PKCS#7 file containg the complete certificate chain
+ *
+ * Verify the content the resultant keystore file
+ *
+ * The following system properties are taken into account by this method:
+ *
+ *
+ * @return the system SSL socket factory
+ */
+ public static SSLSocketFactory getSystemSocketFactory() throws SSLInitializationException {
+ return new SSLSocketFactory(createSystemSSLContext());
+ }
+
+ private final javax.net.ssl.SSLSocketFactory socketfactory;
+ private final HostNameResolver nameResolver;
+ // TODO: make final
+ private volatile X509HostnameVerifier hostnameVerifier;
+
+ private static SSLContext createSSLContext(
+ String algorithm,
+ final KeyStore keystore,
+ final String keystorePassword,
+ final KeyStore truststore,
+ final SecureRandom random,
+ final TrustStrategy trustStrategy)
+ throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException, KeyManagementException {
+ if (algorithm == null) {
+ algorithm = TLS;
+ }
+ KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
+ KeyManagerFactory.getDefaultAlgorithm());
+ kmfactory.init(keystore, keystorePassword != null ? keystorePassword.toCharArray(): null);
+ KeyManager[] keymanagers = kmfactory.getKeyManagers();
+ TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(
+ TrustManagerFactory.getDefaultAlgorithm());
+ tmfactory.init(truststore);
+ TrustManager[] trustmanagers = tmfactory.getTrustManagers();
+ if (trustmanagers != null && trustStrategy != null) {
+ for (int i = 0; i < trustmanagers.length; i++) {
+ TrustManager tm = trustmanagers[i];
+ if (tm instanceof X509TrustManager) {
+ trustmanagers[i] = new TrustManagerDecorator(
+ (X509TrustManager) tm, trustStrategy);
+ }
+ }
+ }
+
+ SSLContext sslcontext = SSLContext.getInstance(algorithm);
+ sslcontext.init(keymanagers, trustmanagers, random);
+ return sslcontext;
+ }
+
+ private static SSLContext createSystemSSLContext(
+ String algorithm,
+ final SecureRandom random) throws IOException, NoSuchAlgorithmException, NoSuchProviderException,
+ KeyStoreException, CertificateException, UnrecoverableKeyException, KeyManagementException {
+ if (algorithm == null) {
+ algorithm = TLS;
+ }
+ TrustManagerFactory tmfactory = null;
+
+ String trustAlgorithm = System.getProperty("ssl.TrustManagerFactory.algorithm");
+ if (trustAlgorithm == null) {
+ trustAlgorithm = TrustManagerFactory.getDefaultAlgorithm();
+ }
+ String trustStoreType = System.getProperty("javax.net.ssl.trustStoreType");
+ if (trustStoreType == null) {
+ trustStoreType = KeyStore.getDefaultType();
+ }
+ if ("none".equalsIgnoreCase(trustStoreType)) {
+ tmfactory = TrustManagerFactory.getInstance(trustAlgorithm);
+ } else {
+ File trustStoreFile = null;
+ String s = System.getProperty("javax.net.ssl.trustStore");
+ if (s != null) {
+ trustStoreFile = new File(s);
+ tmfactory = TrustManagerFactory.getInstance(trustAlgorithm);
+ String trustStoreProvider = System.getProperty("javax.net.ssl.trustStoreProvider");
+ KeyStore trustStore;
+ if (trustStoreProvider != null) {
+ trustStore = KeyStore.getInstance(trustStoreType, trustStoreProvider);
+ } else {
+ trustStore = KeyStore.getInstance(trustStoreType);
+ }
+ String trustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword");
+ FileInputStream instream = new FileInputStream(trustStoreFile);
+ try {
+ trustStore.load(instream, trustStorePassword != null ?
+ trustStorePassword.toCharArray() : EMPTY_PASSWORD);
+ } finally {
+ instream.close();
+ }
+ tmfactory.init(trustStore);
+ } else {
+ File javaHome = new File(System.getProperty("java.home"));
+ File file = new File(javaHome, "lib/security/jssecacerts");
+ if (!file.exists()) {
+ file = new File(javaHome, "lib/security/cacerts");
+ trustStoreFile = file;
+ } else {
+ trustStoreFile = file;
+ }
+ tmfactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
+ KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
+ String trustStorePassword = System.getProperty("javax.net.ssl.trustStorePassword");
+ FileInputStream instream = new FileInputStream(trustStoreFile);
+ try {
+ trustStore.load(instream, trustStorePassword != null ? trustStorePassword.toCharArray() : null);
+ } finally {
+ instream.close();
+ }
+ tmfactory.init(trustStore);
+ }
+ }
+
+ KeyManagerFactory kmfactory = null;
+ String keyAlgorithm = System.getProperty("ssl.KeyManagerFactory.algorithm");
+ if (keyAlgorithm == null) {
+ keyAlgorithm = KeyManagerFactory.getDefaultAlgorithm();
+ }
+ String keyStoreType = System.getProperty("javax.net.ssl.keyStoreType");
+ if (keyStoreType == null) {
+ keyStoreType = KeyStore.getDefaultType();
+ }
+ if ("none".equalsIgnoreCase(keyStoreType)) {
+ kmfactory = KeyManagerFactory.getInstance(keyAlgorithm);
+ } else {
+ File keyStoreFile = null;
+ String s = System.getProperty("javax.net.ssl.keyStore");
+ if (s != null) {
+ keyStoreFile = new File(s);
+ }
+ if (keyStoreFile != null) {
+ kmfactory = KeyManagerFactory.getInstance(keyAlgorithm);
+ String keyStoreProvider = System.getProperty("javax.net.ssl.keyStoreProvider");
+ KeyStore keyStore;
+ if (keyStoreProvider != null) {
+ keyStore = KeyStore.getInstance(keyStoreType, keyStoreProvider);
+ } else {
+ keyStore = KeyStore.getInstance(keyStoreType);
+ }
+ String keyStorePassword = System.getProperty("javax.net.ssl.keyStorePassword");
+ FileInputStream instream = new FileInputStream(keyStoreFile);
+ try {
+ keyStore.load(instream, keyStorePassword != null ?
+ keyStorePassword.toCharArray() : EMPTY_PASSWORD);
+ } finally {
+ instream.close();
+ }
+ kmfactory.init(keyStore, keyStorePassword != null ?
+ keyStorePassword.toCharArray() : EMPTY_PASSWORD);
+ }
+ }
+
+ SSLContext sslcontext = SSLContext.getInstance(algorithm);
+ sslcontext.init(
+ kmfactory != null ? kmfactory.getKeyManagers() : null,
+ tmfactory != null ? tmfactory.getTrustManagers() : null,
+ random);
+ return sslcontext;
+ }
+
+ private static SSLContext createDefaultSSLContext() throws SSLInitializationException {
+ try {
+ return createSSLContext(TLS, null, null, null, null, null);
+ } catch (Exception ex) {
+ throw new SSLInitializationException("Failure initializing default SSL context", ex);
+ }
+ }
+
+ private static SSLContext createSystemSSLContext() throws SSLInitializationException {
+ try {
+ return createSystemSSLContext(TLS, null);
+ } catch (Exception ex) {
+ throw new SSLInitializationException("Failure initializing default system SSL context", ex);
+ }
+ }
+
+ /**
+ * @deprecated Use {@link #SSLSocketFactory(String, KeyStore, String, KeyStore, SecureRandom, X509HostnameVerifier)}
+ */
+ @Deprecated
+ public SSLSocketFactory(
+ final String algorithm,
+ final KeyStore keystore,
+ final String keystorePassword,
+ final KeyStore truststore,
+ final SecureRandom random,
+ final HostNameResolver nameResolver)
+ throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
+ this(createSSLContext(
+ algorithm, keystore, keystorePassword, truststore, random, null),
+ nameResolver);
+ }
+
+ /**
+ * @since 4.1
+ */
+ public SSLSocketFactory(
+ String algorithm,
+ final KeyStore keystore,
+ final String keystorePassword,
+ final KeyStore truststore,
+ final SecureRandom random,
+ final X509HostnameVerifier hostnameVerifier)
+ throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
+ this(createSSLContext(
+ algorithm, keystore, keystorePassword, truststore, random, null),
+ hostnameVerifier);
+ }
+
+ /**
+ * @since 4.1
+ */
+ public SSLSocketFactory(
+ String algorithm,
+ final KeyStore keystore,
+ final String keystorePassword,
+ final KeyStore truststore,
+ final SecureRandom random,
+ final TrustStrategy trustStrategy,
+ final X509HostnameVerifier hostnameVerifier)
+ throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
+ this(createSSLContext(
+ algorithm, keystore, keystorePassword, truststore, random, trustStrategy),
+ hostnameVerifier);
+ }
+
+ public SSLSocketFactory(
+ final KeyStore keystore,
+ final String keystorePassword,
+ final KeyStore truststore)
+ throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
+ this(TLS, keystore, keystorePassword, truststore, null, null, BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+ }
+
+ public SSLSocketFactory(
+ final KeyStore keystore,
+ final String keystorePassword)
+ throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException{
+ this(TLS, keystore, keystorePassword, null, null, null, BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+ }
+
+ public SSLSocketFactory(
+ final KeyStore truststore)
+ throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
+ this(TLS, null, null, truststore, null, null, BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+ }
+
+ /**
+ * @since 4.1
+ */
+ public SSLSocketFactory(
+ final TrustStrategy trustStrategy,
+ final X509HostnameVerifier hostnameVerifier)
+ throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
+ this(TLS, null, null, null, null, trustStrategy, hostnameVerifier);
+ }
+
+ /**
+ * @since 4.1
+ */
+ public SSLSocketFactory(
+ final TrustStrategy trustStrategy)
+ throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException, UnrecoverableKeyException {
+ this(TLS, null, null, null, null, trustStrategy, BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+ }
+
+ public SSLSocketFactory(final SSLContext sslContext) {
+ this(sslContext, BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
+ }
+
+ /**
+ * @deprecated Use {@link #SSLSocketFactory(SSLContext)}
+ */
+ @Deprecated
+ public SSLSocketFactory(
+ final SSLContext sslContext, final HostNameResolver nameResolver) {
+ super();
+ this.socketfactory = sslContext.getSocketFactory();
+ this.hostnameVerifier = BROWSER_COMPATIBLE_HOSTNAME_VERIFIER;
+ this.nameResolver = nameResolver;
+ }
+
+ /**
+ * @since 4.1
+ */
+ public SSLSocketFactory(
+ final SSLContext sslContext, final X509HostnameVerifier hostnameVerifier) {
+ super();
+ if (sslContext == null) {
+ throw new IllegalArgumentException("SSL context may not be null");
+ }
+ this.socketfactory = sslContext.getSocketFactory();
+ this.hostnameVerifier = hostnameVerifier;
+ this.nameResolver = null;
+ }
+
+ /**
+ * @since 4.2
+ */
+ public SSLSocketFactory(
+ final javax.net.ssl.SSLSocketFactory socketfactory,
+ final X509HostnameVerifier hostnameVerifier) {
+ if (socketfactory == null) {
+ throw new IllegalArgumentException("SSL socket factory may not be null");
+ }
+ this.socketfactory = socketfactory;
+ this.hostnameVerifier = hostnameVerifier;
+ this.nameResolver = null;
+ }
+
+ /**
+ * @param params Optional parameters. Parameters passed to this method will have no effect.
+ * This method will create a unconnected instance of {@link Socket} class.
+ * @since 4.1
+ */
+ public Socket createSocket(final HttpParams params) throws IOException {
+ SSLSocket sock = (SSLSocket) this.socketfactory.createSocket();
+ prepareSocket(sock);
+ return sock;
+ }
+
+ @Deprecated
+ public Socket createSocket() throws IOException {
+ SSLSocket sock = (SSLSocket) this.socketfactory.createSocket();
+ prepareSocket(sock);
+ return sock;
+ }
+
+ /**
+ * @since 4.1
+ */
+ public Socket connectSocket(
+ final Socket socket,
+ final InetSocketAddress remoteAddress,
+ final InetSocketAddress localAddress,
+ final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
+ if (remoteAddress == null) {
+ throw new IllegalArgumentException("Remote address may not be null");
+ }
+ if (params == null) {
+ throw new IllegalArgumentException("HTTP parameters may not be null");
+ }
+ Socket sock = socket != null ? socket : this.socketfactory.createSocket();
+ if (localAddress != null) {
+ sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params));
+ sock.bind(localAddress);
+ }
+
+ int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
+ int soTimeout = HttpConnectionParams.getSoTimeout(params);
+
+ try {
+ sock.setSoTimeout(soTimeout);
+ sock.connect(remoteAddress, connTimeout);
+ } catch (SocketTimeoutException ex) {
+ throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out");
+ }
+
+ String hostname;
+ if (remoteAddress instanceof HttpInetSocketAddress) {
+ hostname = ((HttpInetSocketAddress) remoteAddress).getHttpHost().getHostName();
+ } else {
+ hostname = remoteAddress.getHostName();
+ }
+
+ SSLSocket sslsock;
+ // Setup SSL layering if necessary
+ if (sock instanceof SSLSocket) {
+ sslsock = (SSLSocket) sock;
+ } else {
+ int port = remoteAddress.getPort();
+ sslsock = (SSLSocket) this.socketfactory.createSocket(sock, hostname, port, true);
+ prepareSocket(sslsock);
+ }
+ if (this.hostnameVerifier != null) {
+ try {
+ this.hostnameVerifier.verify(hostname, sslsock);
+ // verifyHostName() didn't blowup - good!
+ } catch (IOException iox) {
+ // close the socket before re-throwing the exception
+ try { sslsock.close(); } catch (Exception x) { /*ignore*/ }
+ throw iox;
+ }
+ }
+ return sslsock;
+ }
+
+
+ /**
+ * Checks whether a socket connection is secure.
+ * This factory creates TLS/SSL socket connections
+ * which, by default, are considered secure.
+ *
+ * Please note that, if this method returns Note: the object returned by this method is
+ * considered immutable. Changing it (e.g. using setTime()) could result
+ * in undefined behaviour. Do so at your peril.
+ * Cookies are considered identical if their names are equal and
+ * their domain attributes match ignoring case.
+ *
+ * @since 4.0
+ */
+@Immutable
+public class CookieIdentityComparator implements Serializable, Comparator
+ * This comparator assumes that Path attributes of two cookies
+ * path-match a commmon request-URI. Otherwise, the result of the
+ * comparison is undefined.
+ * Cookie management specification must define
+ * This method will not perform the validation of the resultant
+ * {@link Cookie}s Note: the object returned by this method is considered
+ * immutable. Changing it (e.g. using setTime()) could result in undefined
+ * behaviour. Do so at your peril.
+ * When true the cookie should only be sent
+ * using a secure protocol (https). This should only be set when
+ * the cookie's originating server used a secure protocol to set the
+ * cookie's value.
+ *
+ * @param secure The value of the secure attribute
+ *
+ * @see #isSecure()
+ */
+ void setSecure (boolean secure);
+
+ /**
+ * Sets the version of the cookie specification to which this
+ * cookie conforms.
+ *
+ * @param version the version of the cookie.
+ *
+ * @see Cookie#getVersion
+ */
+ void setVersion(int version);
+
+}
+
Index: 3rdParty_sources/httpclient/org/apache/http/cookie/SetCookie2.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/cookie/SetCookie2.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/cookie/SetCookie2.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,60 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * This parameter expects a value of type {@link java.util.Collection}.
+ * The collection elements must be of type {@link String} compatible
+ * with the syntax of {@link java.text.SimpleDateFormat}.
+ *
+ * This parameter expects a value of type {@link Boolean}.
+ *
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ *
+ * Credential charset is configured via the
+ * {@link org.apache.http.auth.params.AuthPNames#CREDENTIAL_CHARSET}
+ * parameter of the HTTP request.
+ *
+ * Since the digest username is included as clear text in the generated
+ * Authentication header, the charset of the username must be compatible
+ * with the
+ * {@link org.apache.http.params.CoreProtocolPNames#HTTP_ELEMENT_CHARSET
+ * http element charset}.
+ *
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ * There are no valid parameters for Negotiate authentication so this
+ * method always returns null.
+ * Implementations of this interface are expected to be thread-safe.
+ *
+ * @since 4.1
+ *
+ * @deprecated (4.2) subclass {@link KerberosScheme} and override
+ * {@link KerberosScheme#generateGSSToken(byte[], org.ietf.jgss.Oid, String)}
+ */
+@Deprecated
+public interface SpnegoTokenGenerator {
+
+ byte [] generateSpnegoDERObject(byte [] kerberosTicket) throws IOException;
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/auth/UnsupportedDigestAlgorithmException.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,69 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * The Generally speaking, shorter cooldowns will lead to more steady-state
+ * variability but faster reaction times, while longer cooldowns
+ * will lead to more stable equilibrium behavior but slower reaction
+ * times. Similarly, higher backoff factors promote greater
+ * utilization of available capacity at the expense of fairness
+ * among clients. Lower backoff factors allow equal distribution of
+ * capacity among clients (fairness) to happen faster, at the
+ * expense of having more server capacity unused in the short term.
+ * This class also maintains a list of protocol interceptors intended
+ * for processing outgoing requests and incoming responses and provides
+ * methods for managing those interceptors. New protocol interceptors can be
+ * introduced to the protocol processor chain or removed from it if needed.
+ * Internally protocol interceptors are stored in a simple
+ * {@link java.util.ArrayList}. They are executed in the same natural order
+ * as they are added to the list.
+ *
+ * AbstractHttpClient is thread safe. It is recommended that the same
+ * instance of this class is reused for multiple request executions.
+ * When an instance of DefaultHttpClient is no longer needed and is about
+ * to go out of scope the connection manager associated with it must be
+ * shut down by calling {@link ClientConnectionManager#shutdown()}!
+ *
+ * @since 4.0
+ */
+@SuppressWarnings("deprecation")
+@ThreadSafe
+public abstract class AbstractHttpClient implements HttpClient {
+
+ private final Log log = LogFactory.getLog(getClass());
+
+ /** The parameters. */
+ @GuardedBy("this")
+ private HttpParams defaultParams;
+
+ /** The request executor. */
+ @GuardedBy("this")
+ private HttpRequestExecutor requestExec;
+
+ /** The connection manager. */
+ @GuardedBy("this")
+ private ClientConnectionManager connManager;
+
+ /** The connection re-use strategy. */
+ @GuardedBy("this")
+ private ConnectionReuseStrategy reuseStrategy;
+
+ /** The connection keep-alive strategy. */
+ @GuardedBy("this")
+ private ConnectionKeepAliveStrategy keepAliveStrategy;
+
+ /** The cookie spec registry. */
+ @GuardedBy("this")
+ private CookieSpecRegistry supportedCookieSpecs;
+
+ /** The authentication scheme registry. */
+ @GuardedBy("this")
+ private AuthSchemeRegistry supportedAuthSchemes;
+
+ /** The HTTP protocol processor and its immutable copy. */
+ @GuardedBy("this")
+ private BasicHttpProcessor mutableProcessor;
+
+ @GuardedBy("this")
+ private ImmutableHttpProcessor protocolProcessor;
+
+ /** The request retry handler. */
+ @GuardedBy("this")
+ private HttpRequestRetryHandler retryHandler;
+
+ /** The redirect handler. */
+ @GuardedBy("this")
+ private RedirectStrategy redirectStrategy;
+
+ /** The target authentication handler. */
+ @GuardedBy("this")
+ private AuthenticationStrategy targetAuthStrategy;
+
+ /** The proxy authentication handler. */
+ @GuardedBy("this")
+ private AuthenticationStrategy proxyAuthStrategy;
+
+ /** The cookie store. */
+ @GuardedBy("this")
+ private CookieStore cookieStore;
+
+ /** The credentials provider. */
+ @GuardedBy("this")
+ private CredentialsProvider credsProvider;
+
+ /** The route planner. */
+ @GuardedBy("this")
+ private HttpRoutePlanner routePlanner;
+
+ /** The user token handler. */
+ @GuardedBy("this")
+ private UserTokenHandler userTokenHandler;
+
+ /** The connection backoff strategy. */
+ @GuardedBy("this")
+ private ConnectionBackoffStrategy connectionBackoffStrategy;
+
+ /** The backoff manager. */
+ @GuardedBy("this")
+ private BackoffManager backoffManager;
+
+ /**
+ * Creates a new HTTP client.
+ *
+ * @param conman the connection manager
+ * @param params the parameters
+ */
+ protected AbstractHttpClient(
+ final ClientConnectionManager conman,
+ final HttpParams params) {
+ defaultParams = params;
+ connManager = conman;
+ } // constructor
+
+
+ protected abstract HttpParams createHttpParams();
+
+
+ protected abstract BasicHttpProcessor createHttpProcessor();
+
+
+ protected HttpContext createHttpContext() {
+ HttpContext context = new BasicHttpContext();
+ context.setAttribute(
+ ClientContext.SCHEME_REGISTRY,
+ getConnectionManager().getSchemeRegistry());
+ context.setAttribute(
+ ClientContext.AUTHSCHEME_REGISTRY,
+ getAuthSchemes());
+ context.setAttribute(
+ ClientContext.COOKIESPEC_REGISTRY,
+ getCookieSpecs());
+ context.setAttribute(
+ ClientContext.COOKIE_STORE,
+ getCookieStore());
+ context.setAttribute(
+ ClientContext.CREDS_PROVIDER,
+ getCredentialsProvider());
+ return context;
+ }
+
+
+ protected ClientConnectionManager createClientConnectionManager() {
+ SchemeRegistry registry = SchemeRegistryFactory.createDefault();
+
+ ClientConnectionManager connManager = null;
+ HttpParams params = getParams();
+
+ ClientConnectionManagerFactory factory = null;
+
+ String className = (String) params.getParameter(
+ ClientPNames.CONNECTION_MANAGER_FACTORY_CLASS_NAME);
+ if (className != null) {
+ try {
+ Class> clazz = Class.forName(className);
+ factory = (ClientConnectionManagerFactory) clazz.newInstance();
+ } catch (ClassNotFoundException ex) {
+ throw new IllegalStateException("Invalid class name: " + className);
+ } catch (IllegalAccessException ex) {
+ throw new IllegalAccessError(ex.getMessage());
+ } catch (InstantiationException ex) {
+ throw new InstantiationError(ex.getMessage());
+ }
+ }
+ if (factory != null) {
+ connManager = factory.newInstance(params, registry);
+ } else {
+ connManager = new BasicClientConnectionManager(registry);
+ }
+
+ return connManager;
+ }
+
+
+ protected AuthSchemeRegistry createAuthSchemeRegistry() {
+ AuthSchemeRegistry registry = new AuthSchemeRegistry();
+ registry.register(
+ AuthPolicy.BASIC,
+ new BasicSchemeFactory());
+ registry.register(
+ AuthPolicy.DIGEST,
+ new DigestSchemeFactory());
+ registry.register(
+ AuthPolicy.NTLM,
+ new NTLMSchemeFactory());
+ registry.register(
+ AuthPolicy.SPNEGO,
+ new SPNegoSchemeFactory());
+ registry.register(
+ AuthPolicy.KERBEROS,
+ new KerberosSchemeFactory());
+ return registry;
+ }
+
+
+ protected CookieSpecRegistry createCookieSpecRegistry() {
+ CookieSpecRegistry registry = new CookieSpecRegistry();
+ registry.register(
+ CookiePolicy.BEST_MATCH,
+ new BestMatchSpecFactory());
+ registry.register(
+ CookiePolicy.BROWSER_COMPATIBILITY,
+ new BrowserCompatSpecFactory());
+ registry.register(
+ CookiePolicy.NETSCAPE,
+ new NetscapeDraftSpecFactory());
+ registry.register(
+ CookiePolicy.RFC_2109,
+ new RFC2109SpecFactory());
+ registry.register(
+ CookiePolicy.RFC_2965,
+ new RFC2965SpecFactory());
+ registry.register(
+ CookiePolicy.IGNORE_COOKIES,
+ new IgnoreSpecFactory());
+ return registry;
+ }
+
+ protected HttpRequestExecutor createRequestExecutor() {
+ return new HttpRequestExecutor();
+ }
+
+ protected ConnectionReuseStrategy createConnectionReuseStrategy() {
+ return new DefaultConnectionReuseStrategy();
+ }
+
+ protected ConnectionKeepAliveStrategy createConnectionKeepAliveStrategy() {
+ return new DefaultConnectionKeepAliveStrategy();
+ }
+
+ protected HttpRequestRetryHandler createHttpRequestRetryHandler() {
+ return new DefaultHttpRequestRetryHandler();
+ }
+
+ /**
+ * @deprecated (4.1) do not use
+ */
+ @Deprecated
+ protected RedirectHandler createRedirectHandler() {
+ return new DefaultRedirectHandler();
+ }
+
+ protected AuthenticationStrategy createTargetAuthenticationStrategy() {
+ return new TargetAuthenticationStrategy();
+ }
+
+ /**
+ * @deprecated (4.2) do not use
+ */
+ @Deprecated
+ protected AuthenticationHandler createTargetAuthenticationHandler() {
+ return new DefaultTargetAuthenticationHandler();
+ }
+
+ protected AuthenticationStrategy createProxyAuthenticationStrategy() {
+ return new ProxyAuthenticationStrategy();
+ }
+
+ /**
+ * @deprecated (4.2) do not use
+ */
+ @Deprecated
+ protected AuthenticationHandler createProxyAuthenticationHandler() {
+ return new DefaultProxyAuthenticationHandler();
+ }
+
+ protected CookieStore createCookieStore() {
+ return new BasicCookieStore();
+ }
+
+ protected CredentialsProvider createCredentialsProvider() {
+ return new BasicCredentialsProvider();
+ }
+
+ protected HttpRoutePlanner createHttpRoutePlanner() {
+ return new DefaultHttpRoutePlanner(getConnectionManager().getSchemeRegistry());
+ }
+
+ protected UserTokenHandler createUserTokenHandler() {
+ return new DefaultUserTokenHandler();
+ }
+
+ // non-javadoc, see interface HttpClient
+ public synchronized final HttpParams getParams() {
+ if (defaultParams == null) {
+ defaultParams = createHttpParams();
+ }
+ return defaultParams;
+ }
+
+ /**
+ * Replaces the parameters.
+ * The implementation here does not update parameters of dependent objects.
+ *
+ * @param params the new default parameters
+ */
+ public synchronized void setParams(HttpParams params) {
+ defaultParams = params;
+ }
+
+
+ public synchronized final ClientConnectionManager getConnectionManager() {
+ if (connManager == null) {
+ connManager = createClientConnectionManager();
+ }
+ return connManager;
+ }
+
+
+ public synchronized final HttpRequestExecutor getRequestExecutor() {
+ if (requestExec == null) {
+ requestExec = createRequestExecutor();
+ }
+ return requestExec;
+ }
+
+
+ public synchronized final AuthSchemeRegistry getAuthSchemes() {
+ if (supportedAuthSchemes == null) {
+ supportedAuthSchemes = createAuthSchemeRegistry();
+ }
+ return supportedAuthSchemes;
+ }
+
+ public synchronized void setAuthSchemes(final AuthSchemeRegistry registry) {
+ supportedAuthSchemes = registry;
+ }
+
+ public synchronized final ConnectionBackoffStrategy getConnectionBackoffStrategy() {
+ return connectionBackoffStrategy;
+ }
+
+ public synchronized void setConnectionBackoffStrategy(final ConnectionBackoffStrategy strategy) {
+ connectionBackoffStrategy = strategy;
+ }
+
+ public synchronized final CookieSpecRegistry getCookieSpecs() {
+ if (supportedCookieSpecs == null) {
+ supportedCookieSpecs = createCookieSpecRegistry();
+ }
+ return supportedCookieSpecs;
+ }
+
+ public synchronized final BackoffManager getBackoffManager() {
+ return backoffManager;
+ }
+
+ public synchronized void setBackoffManager(final BackoffManager manager) {
+ backoffManager = manager;
+ }
+
+ public synchronized void setCookieSpecs(final CookieSpecRegistry registry) {
+ supportedCookieSpecs = registry;
+ }
+
+ public synchronized final ConnectionReuseStrategy getConnectionReuseStrategy() {
+ if (reuseStrategy == null) {
+ reuseStrategy = createConnectionReuseStrategy();
+ }
+ return reuseStrategy;
+ }
+
+
+ public synchronized void setReuseStrategy(final ConnectionReuseStrategy strategy) {
+ this.reuseStrategy = strategy;
+ }
+
+
+ public synchronized final ConnectionKeepAliveStrategy getConnectionKeepAliveStrategy() {
+ if (keepAliveStrategy == null) {
+ keepAliveStrategy = createConnectionKeepAliveStrategy();
+ }
+ return keepAliveStrategy;
+ }
+
+
+ public synchronized void setKeepAliveStrategy(final ConnectionKeepAliveStrategy strategy) {
+ this.keepAliveStrategy = strategy;
+ }
+
+
+ public synchronized final HttpRequestRetryHandler getHttpRequestRetryHandler() {
+ if (retryHandler == null) {
+ retryHandler = createHttpRequestRetryHandler();
+ }
+ return retryHandler;
+ }
+
+ public synchronized void setHttpRequestRetryHandler(final HttpRequestRetryHandler handler) {
+ this.retryHandler = handler;
+ }
+
+ /**
+ * @deprecated (4.1) do not use
+ */
+ @Deprecated
+ public synchronized final RedirectHandler getRedirectHandler() {
+ return createRedirectHandler();
+ }
+
+ /**
+ * @deprecated (4.1) do not use
+ */
+ @Deprecated
+ public synchronized void setRedirectHandler(final RedirectHandler handler) {
+ this.redirectStrategy = new DefaultRedirectStrategyAdaptor(handler);
+ }
+
+ /**
+ * @since 4.1
+ */
+ public synchronized final RedirectStrategy getRedirectStrategy() {
+ if (redirectStrategy == null) {
+ redirectStrategy = new DefaultRedirectStrategy();
+ }
+ return redirectStrategy;
+ }
+
+ /**
+ * @since 4.1
+ */
+ public synchronized void setRedirectStrategy(final RedirectStrategy strategy) {
+ this.redirectStrategy = strategy;
+ }
+
+ /**
+ * @deprecated (4.2) do not use
+ */
+ @Deprecated
+ public synchronized final AuthenticationHandler getTargetAuthenticationHandler() {
+ return createTargetAuthenticationHandler();
+ }
+
+ /**
+ * @deprecated (4.2) do not use
+ */
+ @Deprecated
+ public synchronized void setTargetAuthenticationHandler(final AuthenticationHandler handler) {
+ this.targetAuthStrategy = new AuthenticationStrategyAdaptor(handler);
+ }
+
+ /**
+ * @since 4.2
+ */
+ public synchronized final AuthenticationStrategy getTargetAuthenticationStrategy() {
+ if (targetAuthStrategy == null) {
+ targetAuthStrategy = createTargetAuthenticationStrategy();
+ }
+ return targetAuthStrategy;
+ }
+
+ /**
+ * @since 4.2
+ */
+ public synchronized void setTargetAuthenticationStrategy(final AuthenticationStrategy strategy) {
+ this.targetAuthStrategy = strategy;
+ }
+
+ /**
+ * @deprecated (4.2) do not use
+ */
+ @Deprecated
+ public synchronized final AuthenticationHandler getProxyAuthenticationHandler() {
+ return createProxyAuthenticationHandler();
+ }
+
+ /**
+ * @deprecated (4.2) do not use
+ */
+ @Deprecated
+ public synchronized void setProxyAuthenticationHandler(final AuthenticationHandler handler) {
+ this.proxyAuthStrategy = new AuthenticationStrategyAdaptor(handler);
+ }
+
+ /**
+ * @since 4.2
+ */
+ public synchronized final AuthenticationStrategy getProxyAuthenticationStrategy() {
+ if (proxyAuthStrategy == null) {
+ proxyAuthStrategy = createProxyAuthenticationStrategy();
+ }
+ return proxyAuthStrategy;
+ }
+
+ /**
+ * @since 4.2
+ */
+ public synchronized void setProxyAuthenticationStrategy(final AuthenticationStrategy strategy) {
+ this.proxyAuthStrategy = strategy;
+ }
+
+ public synchronized final CookieStore getCookieStore() {
+ if (cookieStore == null) {
+ cookieStore = createCookieStore();
+ }
+ return cookieStore;
+ }
+
+ public synchronized void setCookieStore(final CookieStore cookieStore) {
+ this.cookieStore = cookieStore;
+ }
+
+ public synchronized final CredentialsProvider getCredentialsProvider() {
+ if (credsProvider == null) {
+ credsProvider = createCredentialsProvider();
+ }
+ return credsProvider;
+ }
+
+ public synchronized void setCredentialsProvider(final CredentialsProvider credsProvider) {
+ this.credsProvider = credsProvider;
+ }
+
+ public synchronized final HttpRoutePlanner getRoutePlanner() {
+ if (this.routePlanner == null) {
+ this.routePlanner = createHttpRoutePlanner();
+ }
+ return this.routePlanner;
+ }
+
+ public synchronized void setRoutePlanner(final HttpRoutePlanner routePlanner) {
+ this.routePlanner = routePlanner;
+ }
+
+ public synchronized final UserTokenHandler getUserTokenHandler() {
+ if (this.userTokenHandler == null) {
+ this.userTokenHandler = createUserTokenHandler();
+ }
+ return this.userTokenHandler;
+ }
+
+ public synchronized void setUserTokenHandler(final UserTokenHandler handler) {
+ this.userTokenHandler = handler;
+ }
+
+ protected synchronized final BasicHttpProcessor getHttpProcessor() {
+ if (mutableProcessor == null) {
+ mutableProcessor = createHttpProcessor();
+ }
+ return mutableProcessor;
+ }
+
+ private synchronized final HttpProcessor getProtocolProcessor() {
+ if (protocolProcessor == null) {
+ // Get mutable HTTP processor
+ BasicHttpProcessor proc = getHttpProcessor();
+ // and create an immutable copy of it
+ int reqc = proc.getRequestInterceptorCount();
+ HttpRequestInterceptor[] reqinterceptors = new HttpRequestInterceptor[reqc];
+ for (int i = 0; i < reqc; i++) {
+ reqinterceptors[i] = proc.getRequestInterceptor(i);
+ }
+ int resc = proc.getResponseInterceptorCount();
+ HttpResponseInterceptor[] resinterceptors = new HttpResponseInterceptor[resc];
+ for (int i = 0; i < resc; i++) {
+ resinterceptors[i] = proc.getResponseInterceptor(i);
+ }
+ protocolProcessor = new ImmutableHttpProcessor(reqinterceptors, resinterceptors);
+ }
+ return protocolProcessor;
+ }
+
+ public synchronized int getResponseInterceptorCount() {
+ return getHttpProcessor().getResponseInterceptorCount();
+ }
+
+ public synchronized HttpResponseInterceptor getResponseInterceptor(int index) {
+ return getHttpProcessor().getResponseInterceptor(index);
+ }
+
+ public synchronized HttpRequestInterceptor getRequestInterceptor(int index) {
+ return getHttpProcessor().getRequestInterceptor(index);
+ }
+
+ public synchronized int getRequestInterceptorCount() {
+ return getHttpProcessor().getRequestInterceptorCount();
+ }
+
+ public synchronized void addResponseInterceptor(final HttpResponseInterceptor itcp) {
+ getHttpProcessor().addInterceptor(itcp);
+ protocolProcessor = null;
+ }
+
+ public synchronized void addResponseInterceptor(final HttpResponseInterceptor itcp, int index) {
+ getHttpProcessor().addInterceptor(itcp, index);
+ protocolProcessor = null;
+ }
+
+ public synchronized void clearResponseInterceptors() {
+ getHttpProcessor().clearResponseInterceptors();
+ protocolProcessor = null;
+ }
+
+ public synchronized void removeResponseInterceptorByClass(Class extends HttpResponseInterceptor> clazz) {
+ getHttpProcessor().removeResponseInterceptorByClass(clazz);
+ protocolProcessor = null;
+ }
+
+ public synchronized void addRequestInterceptor(final HttpRequestInterceptor itcp) {
+ getHttpProcessor().addInterceptor(itcp);
+ protocolProcessor = null;
+ }
+
+ public synchronized void addRequestInterceptor(final HttpRequestInterceptor itcp, int index) {
+ getHttpProcessor().addInterceptor(itcp, index);
+ protocolProcessor = null;
+ }
+
+ public synchronized void clearRequestInterceptors() {
+ getHttpProcessor().clearRequestInterceptors();
+ protocolProcessor = null;
+ }
+
+ public synchronized void removeRequestInterceptorByClass(Class extends HttpRequestInterceptor> clazz) {
+ getHttpProcessor().removeRequestInterceptorByClass(clazz);
+ protocolProcessor = null;
+ }
+
+ public final HttpResponse execute(HttpUriRequest request)
+ throws IOException, ClientProtocolException {
+
+ return execute(request, (HttpContext) null);
+ }
+
+ /**
+ * Maps to {@link HttpClient#execute(HttpHost,HttpRequest,HttpContext)
+ * execute(target, request, context)}.
+ * The target is determined from the URI of the request.
+ *
+ * @param request the request to execute
+ * @param context the request-specific execution context,
+ * or Decorator adding support for compressed responses. This class sets
+ * the N.B. Any upstream clients of this class need to be aware that
+ * this effectively obscures visibility into the length of a server
+ * response body, since the That said, this decorator is compatible with the
+ *
+ * Please see the Javadoc for {@link #createHttpProcessor()} for the details of the interceptors
+ * that are set up by default.
+ *
+ * Additional interceptors can be added as follows, but
+ * take care not to add the same interceptor more than once.
+ *
+ * This class sets up the following parameters if not explicitly set:
+ *
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ *
+ * @return the processor with the added interceptors.
+ */
+ @Override
+ protected BasicHttpProcessor createHttpProcessor() {
+ BasicHttpProcessor httpproc = new BasicHttpProcessor();
+ httpproc.addInterceptor(new RequestDefaultHeaders());
+ // Required protocol interceptors
+ httpproc.addInterceptor(new RequestContent());
+ httpproc.addInterceptor(new RequestTargetHost());
+ // Recommended protocol interceptors
+ httpproc.addInterceptor(new RequestClientConnControl());
+ httpproc.addInterceptor(new RequestUserAgent());
+ httpproc.addInterceptor(new RequestExpectContinue());
+ // HTTP state management interceptors
+ httpproc.addInterceptor(new RequestAddCookies());
+ httpproc.addInterceptor(new ResponseProcessCookies());
+ // HTTP authentication interceptors
+ httpproc.addInterceptor(new RequestAuthCache());
+ httpproc.addInterceptor(new RequestTargetAuthentication());
+ httpproc.addInterceptor(new RequestProxyAuthentication());
+ return httpproc;
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/client/DefaultHttpRequestRetryHandler.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,169 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ *
+ * DefaultUserTokenHandler will use the user principle of connection
+ * based authentication schemes such as NTLM or that of the SSL session
+ * with the client authentication turned on. If both are unavailable,
+ *
+ * The following system properties are taken into account by this class:
+ *
+ *
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ *
+ * This adapter tracks the checkpoints for reusable communication states,
+ * as indicated by {@link #markReusable markReusable} and queried by
+ * {@link #isMarkedReusable isMarkedReusable}.
+ * All send and receive operations will automatically clear the mark.
+ *
+ * Connection release calls are delegated to the connection manager,
+ * if there is one. {@link #abortConnection abortConnection} will
+ * clear the reusability mark first. The connection manager is
+ * expected to tolerate multiple calls to the release method.
+ *
+ * @since 4.0
+ *
+ * @deprecated (4.2) do not use
+ */
+@Deprecated
+@NotThreadSafe
+public abstract class AbstractClientConnAdapter implements ManagedClientConnection, HttpContext {
+
+ /**
+ * The connection manager.
+ */
+ private final ClientConnectionManager connManager;
+
+ /** The wrapped connection. */
+ private volatile OperatedClientConnection wrappedConnection;
+
+ /** The reusability marker. */
+ private volatile boolean markedReusable;
+
+ /** True if the connection has been shut down or released. */
+ private volatile boolean released;
+
+ /** The duration this is valid for while idle (in ms). */
+ private volatile long duration;
+
+ /**
+ * Creates a new connection adapter.
+ * The adapter is initially not
+ * {@link #isMarkedReusable marked} as reusable.
+ *
+ * @param mgr the connection manager, or
+ * If the managed connections is released or revoked, the adapter
+ * gets disconnected, but the pool entry still contains the
+ * underlying connection and the established route.
+ *
+ * @since 4.0
+ *
+ * @deprecated (4.2) do not use
+ */
+@Deprecated
+public abstract class AbstractPoolEntry {
+
+ /** The connection operator. */
+ protected final ClientConnectionOperator connOperator;
+
+ /** The underlying connection being pooled or used. */
+ protected final OperatedClientConnection connection;
+
+ /** The route for which this entry gets allocated. */
+ //@@@ currently accessed from connection manager(s) as attribute
+ //@@@ avoid that, derived classes should decide whether update is allowed
+ //@@@ SCCM: yes, TSCCM: no
+ protected volatile HttpRoute route;
+
+ /** Connection state object */
+ protected volatile Object state;
+
+ /** The tracked route, or
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ *
+ * This connection operator is multihome network aware and will attempt to retry failed connects
+ * against all known IP addresses sequentially until the connect is successful or all known
+ * addresses fail to respond. Please note the same
+ * {@link org.apache.http.params.CoreConnectionPNames#CONNECTION_TIMEOUT} value will be used
+ * for each connection attempt, so in the worst case the total elapsed time before timeout
+ * can be
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ *
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ *
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ *
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ * This class is not synchronized.
+ * PoolingConnectionManager maintains a maximum limit of connection on
+ * a per route basis and in total. Per default this implementation will
+ * create no more than than 2 concurrent connections per given route
+ * and no more 20 connections in total. For many real-world applications
+ * these limits may prove too constraining, especially if they use HTTP
+ * as a transport protocol for their services. Connection limits, however,
+ * can be adjusted using HTTP parameters.
+ *
+ * @since 4.2
+ */
+@ThreadSafe
+public class PoolingClientConnectionManager implements ClientConnectionManager, ConnPoolControl
+ * The following parameters can be used to customize the behavior of this
+ * class:
+ *
+ * The following system properties are taken into account by this method:
+ *
+ *
+ * @since 4.2
+ */
+ public static SchemeRegistry createSystemDefault() {
+ SchemeRegistry registry = new SchemeRegistry();
+ registry.register(
+ new Scheme("http", 80, PlainSocketFactory.getSocketFactory()));
+ registry.register(
+ new Scheme("https", 443, SSLSocketFactory.getSystemSocketFactory()));
+ return registry;
+ }
+}
+
Index: 3rdParty_sources/httpclient/org/apache/http/impl/conn/SingleClientConnManager.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/conn/SingleClientConnManager.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/conn/SingleClientConnManager.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,431 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * SingleClientConnManager will make an effort to reuse the connection
+ * for subsequent requests with the same {@link HttpRoute route}.
+ * It will, however, close the existing connection and open it
+ * for the given route, if the route of the persistent connection does
+ * not match that of the connection request. If the connection has been
+ * already been allocated {@link IllegalStateException} is thrown.
+ *
+ * @since 4.0
+ *
+ * @deprecated (4.2) use {@link BasicClientConnectionManager}
+ */
+@ThreadSafe
+@Deprecated
+public class SingleClientConnManager implements ClientConnectionManager {
+
+ private final Log log = LogFactory.getLog(getClass());
+
+ /** The message to be logged on multiple allocation. */
+ public final static String MISUSE_MESSAGE =
+ "Invalid use of SingleClientConnManager: connection still allocated.\n" +
+ "Make sure to release the connection before allocating another one.";
+
+ /** The schemes supported by this connection manager. */
+ protected final SchemeRegistry schemeRegistry;
+
+ /** The operator for opening and updating connections. */
+ protected final ClientConnectionOperator connOperator;
+
+ /** Whether the connection should be shut down on release. */
+ protected final boolean alwaysShutDown;
+
+ /** The one and only entry in this pool. */
+ @GuardedBy("this")
+ protected volatile PoolEntry uniquePoolEntry;
+
+ /** The currently issued managed connection, if any. */
+ @GuardedBy("this")
+ protected volatile ConnAdapter managedConn;
+
+ /** The time of the last connection release, or -1. */
+ @GuardedBy("this")
+ protected volatile long lastReleaseTime;
+
+ /** The time the last released connection expires and shouldn't be reused. */
+ @GuardedBy("this")
+ protected volatile long connectionExpiresTime;
+
+ /** Indicates whether this connection manager is shut down. */
+ protected volatile boolean isShutDown;
+
+ /**
+ * Creates a new simple connection manager.
+ *
+ * @param params the parameters for this manager
+ * @param schreg the scheme registry
+ *
+ * @deprecated (4.1) use {@link SingleClientConnManager#SingleClientConnManager(SchemeRegistry)}
+ */
+ public SingleClientConnManager(HttpParams params,
+ SchemeRegistry schreg) {
+ this(schreg);
+ }
+ /**
+ * Creates a new simple connection manager.
+ *
+ * @param schreg the scheme registry
+ */
+ public SingleClientConnManager(final SchemeRegistry schreg) {
+ if (schreg == null) {
+ throw new IllegalArgumentException
+ ("Scheme registry must not be null.");
+ }
+ this.schemeRegistry = schreg;
+ this.connOperator = createConnectionOperator(schreg);
+ this.uniquePoolEntry = new PoolEntry();
+ this.managedConn = null;
+ this.lastReleaseTime = -1L;
+ this.alwaysShutDown = false; //@@@ from params? as argument?
+ this.isShutDown = false;
+ }
+
+ /**
+ * @since 4.1
+ */
+ public SingleClientConnManager() {
+ this(SchemeRegistryFactory.createDefault());
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ try {
+ shutdown();
+ } finally { // Make sure we call overridden method even if shutdown barfs
+ super.finalize();
+ }
+ }
+
+ public SchemeRegistry getSchemeRegistry() {
+ return this.schemeRegistry;
+ }
+
+ /**
+ * Hook for creating the connection operator.
+ * It is called by the constructor.
+ * Derived classes can override this method to change the
+ * instantiation of the operator.
+ * The default implementation here instantiates
+ * {@link DefaultClientConnectionOperator DefaultClientConnectionOperator}.
+ *
+ * @param schreg the scheme registry to use, or Cookie
request headers.
+ *
+ *
+ *
+ * @since 4.0
+ */
+@Immutable
+public class RequestAddCookies implements HttpRequestInterceptor {
+
+ private final Log log = LogFactory.getLog(getClass());
+
+ public RequestAddCookies() {
+ super();
+ }
+
+ public void process(final HttpRequest request, final HttpContext context)
+ throws HttpException, IOException {
+ if (request == null) {
+ throw new IllegalArgumentException("HTTP request may not be null");
+ }
+ if (context == null) {
+ throw new IllegalArgumentException("HTTP context may not be null");
+ }
+
+ String method = request.getRequestLine().getMethod();
+ if (method.equalsIgnoreCase("CONNECT")) {
+ return;
+ }
+
+ // Obtain cookie store
+ CookieStore cookieStore = (CookieStore) context.getAttribute(
+ ClientContext.COOKIE_STORE);
+ if (cookieStore == null) {
+ this.log.debug("Cookie store not specified in HTTP context");
+ return;
+ }
+
+ // Obtain the registry of cookie specs
+ CookieSpecRegistry registry = (CookieSpecRegistry) context.getAttribute(
+ ClientContext.COOKIESPEC_REGISTRY);
+ if (registry == null) {
+ this.log.debug("CookieSpec registry not specified in HTTP context");
+ return;
+ }
+
+ // Obtain the target host (required)
+ HttpHost targetHost = (HttpHost) context.getAttribute(
+ ExecutionContext.HTTP_TARGET_HOST);
+ if (targetHost == null) {
+ this.log.debug("Target host not set in the context");
+ return;
+ }
+
+ // Obtain the client connection (required)
+ HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute(
+ ExecutionContext.HTTP_CONNECTION);
+ if (conn == null) {
+ this.log.debug("HTTP connection not set in the context");
+ return;
+ }
+
+ String policy = HttpClientParams.getCookiePolicy(request.getParams());
+ if (this.log.isDebugEnabled()) {
+ this.log.debug("CookieSpec selected: " + policy);
+ }
+
+ URI requestURI;
+ if (request instanceof HttpUriRequest) {
+ requestURI = ((HttpUriRequest) request).getURI();
+ } else {
+ try {
+ requestURI = new URI(request.getRequestLine().getUri());
+ } catch (URISyntaxException ex) {
+ throw new ProtocolException("Invalid request URI: " +
+ request.getRequestLine().getUri(), ex);
+ }
+ }
+
+ String hostName = targetHost.getHostName();
+ int port = targetHost.getPort();
+ if (port < 0) {
+ HttpRoute route = conn.getRoute();
+ if (route.getHopCount() == 1) {
+ port = conn.getRemotePort();
+ } else {
+ // Target port will be selected by the proxy.
+ // Use conventional ports for known schemes
+ String scheme = targetHost.getSchemeName();
+ if (scheme.equalsIgnoreCase("http")) {
+ port = 80;
+ } else if (scheme.equalsIgnoreCase("https")) {
+ port = 443;
+ } else {
+ port = 0;
+ }
+ }
+ }
+
+ CookieOrigin cookieOrigin = new CookieOrigin(
+ hostName,
+ port,
+ requestURI.getPath(),
+ conn.isSecure());
+
+ // Get an instance of the selected cookie policy
+ CookieSpec cookieSpec = registry.getCookieSpec(policy, request.getParams());
+ // Get all cookies available in the HTTP state
+ ListConnection
+ * or Proxy-Connection
headers to the outgoing requests, which
+ * is essential for managing persistence of HTTP/1.0
connections.
+ *
+ * @since 4.0
+ */
+@Immutable
+public class RequestClientConnControl implements HttpRequestInterceptor {
+
+ private final Log log = LogFactory.getLog(getClass());
+
+ private static final String PROXY_CONN_DIRECTIVE = "Proxy-Connection";
+
+ public RequestClientConnControl() {
+ super();
+ }
+
+ public void process(final HttpRequest request, final HttpContext context)
+ throws HttpException, IOException {
+ if (request == null) {
+ throw new IllegalArgumentException("HTTP request may not be null");
+ }
+
+ String method = request.getRequestLine().getMethod();
+ if (method.equalsIgnoreCase("CONNECT")) {
+ request.setHeader(PROXY_CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
+ return;
+ }
+
+ // Obtain the client connection (required)
+ HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute(
+ ExecutionContext.HTTP_CONNECTION);
+ if (conn == null) {
+ this.log.debug("HTTP connection not set in the context");
+ return;
+ }
+
+ HttpRoute route = conn.getRoute();
+
+ if (route.getHopCount() == 1 || route.isTunnelled()) {
+ if (!request.containsHeader(HTTP.CONN_DIRECTIVE)) {
+ request.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
+ }
+ }
+ if (route.getHopCount() == 2 && !route.isTunnelled()) {
+ if (!request.containsHeader(PROXY_CONN_DIRECTIVE)) {
+ request.addHeader(PROXY_CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
+ }
+ }
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/protocol/RequestDefaultHeaders.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/protocol/RequestDefaultHeaders.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/protocol/RequestDefaultHeaders.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -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
+ *
+ *
+ *
+ * @param response the response which contains the entity
+ * @param context not currently used
+ *
+ * @throws HttpException if the {@code Content-Encoding} is none of the above
+ */
+ public void process(
+ final HttpResponse response,
+ final HttpContext context) throws HttpException, IOException {
+ HttpEntity entity = response.getEntity();
+
+ // It wasn't a 304 Not Modified response, 204 No Content or similar
+ if (entity != null) {
+ Header ceheader = entity.getContentEncoding();
+ if (ceheader != null) {
+ HeaderElement[] codecs = ceheader.getElements();
+ for (HeaderElement codec : codecs) {
+ String codecname = codec.getName().toLowerCase(Locale.US);
+ if ("gzip".equals(codecname) || "x-gzip".equals(codecname)) {
+ response.setEntity(new GzipDecompressingEntity(response.getEntity()));
+ if (context != null) context.setAttribute(UNCOMPRESSED, true);
+ return;
+ } else if ("deflate".equals(codecname)) {
+ response.setEntity(new DeflateDecompressingEntity(response.getEntity()));
+ if (context != null) context.setAttribute(UNCOMPRESSED, true);
+ return;
+ } else if ("identity".equals(codecname)) {
+
+ /* Don't need to transform the content - no-op */
+ return;
+ } else {
+ throw new HttpException("Unsupported Content-Coding: " + codec.getName());
+ }
+ }
+ }
+ }
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/protocol/ResponseProcessCookies.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/protocol/ResponseProcessCookies.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/protocol/ResponseProcessCookies.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,141 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * HttpResponse httpResponse = null;
+ * try {
+ * httpResponse = httpClient.execute(httpGet);
+ * } catch (Exception e) {
+ * // error handling
+ * } finally {
+ * HttpClientUtils.closeQuietly(httpResponse);
+ * }
+ *
+ *
+ * @param response
+ * the HttpResponse to release resources, may be null or already
+ * closed.
+ *
+ * @since 4.2
+ */
+ public static void closeQuietly(final HttpResponse response) {
+ if (response != null) {
+ HttpEntity entity = response.getEntity();
+ if (entity != null) {
+ try {
+ EntityUtils.consume(entity);
+ } catch (final IOException ex) {
+ }
+ }
+ }
+ }
+
+ /**
+ * Unconditionally close a httpClient. Shuts down the underlying connection
+ * manager and releases the resources.
+ *
+ * HttpClient httpClient = null;
+ * try {
+ * httpClient = new DefaultHttpClient(...);
+ * } catch (Exception e) {
+ * // error handling
+ * } finally {
+ * HttpClientUtils.closeQuietly(httpClient);
+ * }
+ *
+ *
+ * @param httpClient
+ * the HttpClient to close, may be null or already closed.
+ * @since 4.2
+ */
+ public static void closeQuietly(final HttpClient httpClient) {
+ if (httpClient != null) {
+ httpClient.getConnectionManager().shutdown();
+ }
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/utils/Idn.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/utils/Idn.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/utils/Idn.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,46 @@
+/*
+ * $HeadURL$
+ * $Revision$
+ * $Date$
+ *
+ * ====================================================================
+ *
+ * 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
+ * null if the URI is
+ * relative or does not contain a valid host name.
+ *
+ * @since 4.1
+ */
+ public static HttpHost extractHost(final URI uri) {
+ if (uri == null) {
+ return null;
+ }
+ HttpHost target = null;
+ if (uri.isAbsolute()) {
+ int port = uri.getPort(); // may be overridden later
+ String host = uri.getHost();
+ if (host == null) { // normal parse failed; let's do it ourselves
+ // authority does not seem to care about the valid character-set for host names
+ host = uri.getAuthority();
+ if (host != null) {
+ // Strip off any leading user credentials
+ int at = host.indexOf('@');
+ if (at >= 0) {
+ if (host.length() > at+1 ) {
+ host = host.substring(at+1);
+ } else {
+ host = null; // @ on its own
+ }
+ }
+ // Extract the port suffix, if present
+ if (host != null) {
+ int colon = host.indexOf(':');
+ if (colon >= 0) {
+ int pos = colon + 1;
+ int len = 0;
+ for (int i = pos; i < host.length(); i++) {
+ if (Character.isDigit(host.charAt(i))) {
+ len++;
+ } else {
+ break;
+ }
+ }
+ if (len > 0) {
+ try {
+ port = Integer.parseInt(host.substring(pos, pos + len));
+ } catch (NumberFormatException ex) {
+ }
+ }
+ host = host.substring(0, colon);
+ }
+ }
+ }
+ }
+ String scheme = uri.getScheme();
+ if (host != null) {
+ target = new HttpHost(host, port, scheme);
+ }
+ }
+ return target;
+ }
+
+ /**
+ * This class should not be instantiated.
+ */
+ private URIUtils() {
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/client/utils/URLEncodedUtils.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/client/utils/URLEncodedUtils.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/client/utils/URLEncodedUtils.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,544 @@
+/*
+ * ====================================================================
+ * 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
+ *
application/x-www-form-urlencoded
.
+ */
+ public static boolean isEncoded (final HttpEntity entity) {
+ Header h = entity.getContentType();
+ if (h != null) {
+ HeaderElement[] elems = h.getElements();
+ if (elems.length > 0) {
+ String contentType = elems[0].getName();
+ return contentType.equalsIgnoreCase(CONTENT_TYPE);
+ } else {
+ return false;
+ }
+ } else {
+ return false;
+ }
+ }
+
+ /**
+ * Adds all parameters within the Scanner to the list of
+ * parameters
, as encoded by encoding
. For
+ * example, a scanner containing the string a=1&b=2&c=3
would
+ * add the {@link NameValuePair NameValuePairs} a=1, b=2, and c=3 to the
+ * list of parameters.
+ *
+ * @param parameters
+ * List to add parameters to.
+ * @param scanner
+ * Input that contains the parameters to parse.
+ * @param charset
+ * Encoding to use when decoding the parameters.
+ */
+ public static void parse (
+ final List application/x-www-form-urlencoded
+ * list of parameters in an HTTP PUT or HTTP POST.
+ *
+ * @param parameters The parameters to include.
+ * @param encoding The encoding to use.
+ */
+ public static String format (
+ final List extends NameValuePair> parameters,
+ final String encoding) {
+ final StringBuilder result = new StringBuilder();
+ for (final NameValuePair parameter : parameters) {
+ final String encodedName = encodeFormFields(parameter.getName(), encoding);
+ final String encodedValue = encodeFormFields(parameter.getValue(), encoding);
+ if (result.length() > 0) {
+ result.append(PARAMETER_SEPARATOR);
+ }
+ result.append(encodedName);
+ if (encodedValue != null) {
+ result.append(NAME_VALUE_SEPARATOR);
+ result.append(encodedValue);
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ * Returns a String that is suitable for use as an application/x-www-form-urlencoded
+ * list of parameters in an HTTP PUT or HTTP POST.
+ *
+ * @param parameters The parameters to include.
+ * @param charset The encoding to use.
+ *
+ * @since 4.2
+ */
+ public static String format (
+ final Iterable extends NameValuePair> parameters,
+ final Charset charset) {
+ final StringBuilder result = new StringBuilder();
+ for (final NameValuePair parameter : parameters) {
+ final String encodedName = encodeFormFields(parameter.getName(), charset);
+ final String encodedValue = encodeFormFields(parameter.getValue(), charset);
+ if (result.length() > 0) {
+ result.append(PARAMETER_SEPARATOR);
+ }
+ result.append(encodedName);
+ if (encodedValue != null) {
+ result.append(NAME_VALUE_SEPARATOR);
+ result.append(encodedValue);
+ }
+ }
+ return result.toString();
+ }
+
+ /**
+ * Unreserved characters, i.e. alphanumeric, plus: {@code _ - ! . ~ ' ( ) *}
+ * null
+ */
+ SchemeRegistry getSchemeRegistry();
+
+ /**
+ * Returns a new {@link ClientConnectionRequest}, from which a
+ * {@link ManagedClientConnection} can be obtained or the request can be
+ * aborted.
+ */
+ ClientConnectionRequest requestConnection(HttpRoute route, Object state);
+
+ /**
+ * Releases a connection for use by others.
+ * You may optionally specify how long the connection is valid
+ * to be reused. Values <= 0 are considered to be valid forever.
+ * If the connection is not marked as reusable, the connection will
+ * not be reused regardless of the valid duration.
+ *
+ * If the connection has been released before,
+ * the call will be ignored.
+ *
+ * @param conn the connection to release
+ * @param validDuration the duration of time this connection is valid for reuse
+ * @param timeUnit the unit of time validDuration is measured in
+ *
+ * @see #closeExpiredConnections()
+ */
+ void releaseConnection(ManagedClientConnection conn, long validDuration, TimeUnit timeUnit);
+
+ /**
+ * Closes idle connections in the pool.
+ * Open connections in the pool that have not been used for the
+ * timespan given by the argument will be closed.
+ * Currently allocated connections are not subject to this method.
+ * Times will be checked with milliseconds precision
+ *
+ * All expired connections will also be closed.
+ *
+ * @param idletime the idle time of connections to be closed
+ * @param tunit the unit for the idletime
+ *
+ * @see #closeExpiredConnections()
+ */
+ void closeIdleConnections(long idletime, TimeUnit tunit);
+
+ /**
+ * Closes all expired connections in the pool.
+ * Open connections in the pool that have not been used for
+ * the timespan defined when the connection was released will be closed.
+ * Currently allocated connections are not subject to this method.
+ * Times will be checked with milliseconds precision.
+ */
+ void closeExpiredConnections();
+
+ /**
+ * Shuts down this connection manager and releases allocated resources.
+ * This includes closing all connections, whether they are currently
+ * used or not.
+ */
+ void shutdown();
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/ClientConnectionManagerFactory.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/ClientConnectionManagerFactory.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/ClientConnectionManagerFactory.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,45 @@
+/*
+ * ====================================================================
+ * 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
+ * null
for the default
+ * @param context the context for the connection
+ * @param params the parameters for the connection
+ *
+ * @throws IOException in case of a problem
+ */
+ void openConnection(OperatedClientConnection conn,
+ HttpHost target,
+ InetAddress local,
+ HttpContext context,
+ HttpParams params)
+ throws IOException;
+
+ /**
+ * Updates a connection with a layered secure connection.
+ * The typical use of this method is to update a tunnelled plain
+ * connection (HTTP) to a secure TLS/SSL connection (HTTPS).
+ *
+ * @param conn the open connection to update
+ * @param target the target host for the updated connection.
+ * The connection must already be open or tunnelled
+ * to the host and port, but the scheme of the target
+ * will be used to create a layered connection.
+ * @param context the context for the connection
+ * @param params the parameters for the updated connection
+ *
+ * @throws IOException in case of a problem
+ */
+ void updateSecureConnection(OperatedClientConnection conn,
+ HttpHost target,
+ HttpContext context,
+ HttpParams params)
+ throws IOException;
+
+}
+
Index: 3rdParty_sources/httpclient/org/apache/http/conn/ClientConnectionRequest.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/ClientConnectionRequest.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/ClientConnectionRequest.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,71 @@
+/*
+ * ====================================================================
+ * 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
+ * timeout
,
+ * may be null
only if there is no timeout
+ *
+ * @return a connection that can be used to communicate
+ * along the given route
+ *
+ * @throws ConnectionPoolTimeoutException
+ * in case of a timeout
+ * @throws InterruptedException
+ * if the calling thread is interrupted while waiting
+ */
+ ManagedClientConnection getConnection(long timeout, TimeUnit tunit)
+ throws InterruptedException, ConnectionPoolTimeoutException;
+
+ /**
+ * Aborts the call to {@link #getConnection(long, TimeUnit)},
+ * causing it to throw an {@link InterruptedException}.
+ */
+ void abortRequest();
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/ConnectTimeoutException.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/ConnectTimeoutException.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/ConnectTimeoutException.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,62 @@
+/*
+ * ====================================================================
+ * 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
+ * AutoCloseInputStream
in HttpClient 3.1,
+ * but has notable differences. It does not allow mark/reset, distinguishes
+ * different kinds of event, and does not always close the underlying stream
+ * on EOF. That decision is left to the {@link EofSensorWatcher watcher}.
+ *
+ * @see EofSensorWatcher
+ *
+ * @since 4.0
+ */
+// don't use FilterInputStream as the base class, we'd have to
+// override markSupported(), mark(), and reset() to disable them
+@NotThreadSafe
+public class EofSensorInputStream extends InputStream implements ConnectionReleaseTrigger {
+
+ /**
+ * The wrapped input stream, while accessible.
+ * The value changes to null
when the wrapped stream
+ * becomes inaccessible.
+ */
+ protected InputStream wrappedStream;
+
+ /**
+ * Indicates whether this stream itself is closed.
+ * If it isn't, but {@link #wrappedStream wrappedStream}
+ * is null
, we're running in EOF mode.
+ * All read operations will indicate EOF without accessing
+ * the underlying stream. After closing this stream, read
+ * operations will trigger an {@link IOException IOException}.
+ *
+ * @see #isReadAllowed isReadAllowed
+ */
+ private boolean selfClosed;
+
+ /** The watcher to be notified, if any. */
+ private final EofSensorWatcher eofWatcher;
+
+ /**
+ * Creates a new EOF sensor.
+ * If no watcher is passed, the underlying stream will simply be
+ * closed when EOF is detected or {@link #close close} is called.
+ * Otherwise, the watcher decides whether the underlying stream
+ * should be closed before detaching from it.
+ *
+ * @param in the wrapped stream
+ * @param watcher the watcher for events, or null
for
+ * auto-close behavior without notification
+ */
+ public EofSensorInputStream(final InputStream in,
+ final EofSensorWatcher watcher) {
+ if (in == null) {
+ throw new IllegalArgumentException
+ ("Wrapped stream may not be null.");
+ }
+
+ wrappedStream = in;
+ selfClosed = false;
+ eofWatcher = watcher;
+ }
+
+ /**
+ * Checks whether the underlying stream can be read from.
+ *
+ * @return true
if the underlying stream is accessible,
+ * false
if this stream is in EOF mode and
+ * detached from the underlying stream
+ *
+ * @throws IOException if this stream is already closed
+ */
+ protected boolean isReadAllowed() throws IOException {
+ if (selfClosed) {
+ throw new IOException("Attempted read on closed stream.");
+ }
+ return (wrappedStream != null);
+ }
+
+ @Override
+ public int read() throws IOException {
+ int l = -1;
+
+ if (isReadAllowed()) {
+ try {
+ l = wrappedStream.read();
+ checkEOF(l);
+ } catch (IOException ex) {
+ checkAbort();
+ throw ex;
+ }
+ }
+
+ return l;
+ }
+
+ @Override
+ public int read(byte[] b, int off, int len) throws IOException {
+ int l = -1;
+
+ if (isReadAllowed()) {
+ try {
+ l = wrappedStream.read(b, off, len);
+ checkEOF(l);
+ } catch (IOException ex) {
+ checkAbort();
+ throw ex;
+ }
+ }
+
+ return l;
+ }
+
+ @Override
+ public int read(byte[] b) throws IOException {
+ int l = -1;
+
+ if (isReadAllowed()) {
+ try {
+ l = wrappedStream.read(b);
+ checkEOF(l);
+ } catch (IOException ex) {
+ checkAbort();
+ throw ex;
+ }
+ }
+ return l;
+ }
+
+ @Override
+ public int available() throws IOException {
+ int a = 0; // not -1
+
+ if (isReadAllowed()) {
+ try {
+ a = wrappedStream.available();
+ // no checkEOF() here, available() can't trigger EOF
+ } catch (IOException ex) {
+ checkAbort();
+ throw ex;
+ }
+ }
+
+ return a;
+ }
+
+ @Override
+ public void close() throws IOException {
+ // tolerate multiple calls to close()
+ selfClosed = true;
+ checkClose();
+ }
+
+ /**
+ * Detects EOF and notifies the watcher.
+ * This method should only be called while the underlying stream is
+ * still accessible. Use {@link #isReadAllowed isReadAllowed} to
+ * check that condition.
+ *
+ * If EOF is detected, the watcher will be notified and this stream
+ * is detached from the underlying stream. This prevents multiple
+ * notifications from this stream.
+ *
+ * @param eof the result of the calling read operation.
+ * A negative value indicates that EOF is reached.
+ *
+ * @throws IOException
+ * in case of an IO problem on closing the underlying stream
+ */
+ protected void checkEOF(int eof) throws IOException {
+
+ if ((wrappedStream != null) && (eof < 0)) {
+ try {
+ boolean scws = true; // should close wrapped stream?
+ if (eofWatcher != null)
+ scws = eofWatcher.eofDetected(wrappedStream);
+ if (scws)
+ wrappedStream.close();
+ } finally {
+ wrappedStream = null;
+ }
+ }
+ }
+
+ /**
+ * Detects stream close and notifies the watcher.
+ * There's not much to detect since this is called by {@link #close close}.
+ * The watcher will only be notified if this stream is closed
+ * for the first time and before EOF has been detected.
+ * This stream will be detached from the underlying stream to prevent
+ * multiple notifications to the watcher.
+ *
+ * @throws IOException
+ * in case of an IO problem on closing the underlying stream
+ */
+ protected void checkClose() throws IOException {
+
+ if (wrappedStream != null) {
+ try {
+ boolean scws = true; // should close wrapped stream?
+ if (eofWatcher != null)
+ scws = eofWatcher.streamClosed(wrappedStream);
+ if (scws)
+ wrappedStream.close();
+ } finally {
+ wrappedStream = null;
+ }
+ }
+ }
+
+ /**
+ * Detects stream abort and notifies the watcher.
+ * There's not much to detect since this is called by
+ * {@link #abortConnection abortConnection}.
+ * The watcher will only be notified if this stream is aborted
+ * for the first time and before EOF has been detected or the
+ * stream has been {@link #close closed} gracefully.
+ * This stream will be detached from the underlying stream to prevent
+ * multiple notifications to the watcher.
+ *
+ * @throws IOException
+ * in case of an IO problem on closing the underlying stream
+ */
+ protected void checkAbort() throws IOException {
+
+ if (wrappedStream != null) {
+ try {
+ boolean scws = true; // should close wrapped stream?
+ if (eofWatcher != null)
+ scws = eofWatcher.streamAbort(wrappedStream);
+ if (scws)
+ wrappedStream.close();
+ } finally {
+ wrappedStream = null;
+ }
+ }
+ }
+
+ /**
+ * Same as {@link #close close()}.
+ */
+ public void releaseConnection() throws IOException {
+ close();
+ }
+
+ /**
+ * Aborts this stream.
+ * This is a special version of {@link #close close()} which prevents
+ * re-use of the underlying connection, if any. Calling this method
+ * indicates that there should be no attempt to read until the end of
+ * the stream.
+ */
+ public void abortConnection() throws IOException {
+ // tolerate multiple calls
+ selfClosed = true;
+ checkAbort();
+ }
+
+}
+
Index: 3rdParty_sources/httpclient/org/apache/http/conn/EofSensorWatcher.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/EofSensorWatcher.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/EofSensorWatcher.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,95 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * true
if wrapped
should be closed,
+ * false
if it should be left alone
+ *
+ * @throws IOException
+ * in case of an IO problem, for example if the watcher itself
+ * closes the underlying stream. The caller will leave the
+ * wrapped stream alone, as if false
was returned.
+ */
+ boolean eofDetected(InputStream wrapped)
+ throws IOException;
+
+ /**
+ * Indicates that the {@link EofSensorInputStream stream} is closed.
+ * This method will be called only if EOF was not detected
+ * before closing. Otherwise, {@link #eofDetected eofDetected} is called.
+ *
+ * @param wrapped the underlying stream which has not reached EOF
+ *
+ * @return true
if wrapped
should be closed,
+ * false
if it should be left alone
+ *
+ * @throws IOException
+ * in case of an IO problem, for example if the watcher itself
+ * closes the underlying stream. The caller will leave the
+ * wrapped stream alone, as if false
was returned.
+ */
+ boolean streamClosed(InputStream wrapped)
+ throws IOException;
+
+ /**
+ * Indicates that the {@link EofSensorInputStream stream} is aborted.
+ * This method will be called only if EOF was not detected
+ * before aborting. Otherwise, {@link #eofDetected eofDetected} is called.
+ * true
if wrapped
should be closed,
+ * false
if it should be left alone
+ *
+ * @throws IOException
+ * in case of an IO problem, for example if the watcher itself
+ * closes the underlying stream. The caller will leave the
+ * wrapped stream alone, as if false
was returned.
+ */
+ boolean streamAbort(InputStream wrapped)
+ throws IOException;
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/HttpHostConnectException.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/HttpHostConnectException.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/HttpHostConnectException.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,58 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * true
if this connection is secure,
+ * false
otherwise
+ */
+ boolean isSecure();
+
+ /**
+ * Obtains the current route of this connection.
+ *
+ * @return the route established so far, or
+ * null
if not connected
+ */
+ HttpRoute getRoute();
+
+ /**
+ * Obtains the SSL session of the underlying connection, if any.
+ * If this connection is open, and the underlying socket is an
+ * {@link javax.net.ssl.SSLSocket SSLSocket}, the SSL session of
+ * that socket is obtained. This is a potentially blocking operation.
+ *
+ * Note: Whether the underlying socket is an SSL socket
+ * can not necessarily be determined via {@link #isSecure}.
+ * Plain sockets may be considered secure, for example if they are
+ * connected to a known host in the same network segment.
+ * On the other hand, SSL sockets may be considered insecure,
+ * for example depending on the chosen cipher suite.
+ *
+ * @return the underlying SSL session if available,
+ * null
otherwise
+ */
+ SSLSession getSSLSession();
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/ManagedClientConnection.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/ManagedClientConnection.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/ManagedClientConnection.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,226 @@
+/*
+ * ====================================================================
+ * 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
+ * true
if this connection is secure,
+ * false
otherwise
+ */
+ boolean isSecure();
+
+ /**
+ * Obtains the current route of this connection.
+ *
+ * @return the route established so far, or
+ * null
if not connected
+ */
+ HttpRoute getRoute();
+
+ /**
+ * Obtains the SSL session of the underlying connection, if any.
+ * If this connection is open, and the underlying socket is an
+ * {@link javax.net.ssl.SSLSocket SSLSocket}, the SSL session of
+ * that socket is obtained. This is a potentially blocking operation.
+ *
+ * Note: Whether the underlying socket is an SSL socket
+ * can not necessarily be determined via {@link #isSecure}.
+ * Plain sockets may be considered secure, for example if they are
+ * connected to a known host in the same network segment.
+ * On the other hand, SSL sockets may be considered insecure,
+ * for example depending on the chosen cipher suite.
+ *
+ * @return the underlying SSL session if available,
+ * null
otherwise
+ */
+ SSLSession getSSLSession();
+
+ /**
+ * Opens this connection according to the given route.
+ *
+ * @param route the route along which to open. It will be opened to
+ * the first proxy if present, or directly to the target.
+ * @param context the context for opening this connection
+ * @param params the parameters for opening this connection
+ *
+ * @throws IOException in case of a problem
+ */
+ void open(HttpRoute route, HttpContext context, HttpParams params)
+ throws IOException;
+
+ /**
+ * Indicates that a tunnel to the target has been established.
+ * The route is the one previously passed to {@link #open open}.
+ * Subsequently, {@link #layerProtocol layerProtocol} can be called
+ * to layer the TLS/SSL protocol on top of the tunnelled connection.
+ *
+ * Note: In HttpClient 3, a call to the corresponding method
+ * would automatically trigger the layering of the TLS/SSL protocol.
+ * This is not the case anymore, you can establish a tunnel without
+ * layering a new protocol over the connection.
+ *
+ * @param secure true
if the tunnel should be considered
+ * secure, false
otherwise
+ * @param params the parameters for tunnelling this connection
+ *
+ * @throws IOException in case of a problem
+ */
+ void tunnelTarget(boolean secure, HttpParams params)
+ throws IOException;
+
+ /**
+ * Indicates that a tunnel to an intermediate proxy has been established.
+ * This is used exclusively for so-called proxy chains, where
+ * a request has to pass through multiple proxies before reaching the
+ * target. In that case, all proxies but the last need to be tunnelled
+ * when establishing the connection. Tunnelling of the last proxy to the
+ * target is optional and would be indicated via {@link #tunnelTarget}.
+ *
+ * @param next the proxy to which the tunnel was established.
+ * This is not the proxy through which
+ * the tunnel was established, but the new end point
+ * of the tunnel. The tunnel does not yet
+ * reach to the target, use {@link #tunnelTarget}
+ * to indicate an end-to-end tunnel.
+ * @param secure true
if the connection should be
+ * considered secure, false
otherwise
+ * @param params the parameters for tunnelling this connection
+ *
+ * @throws IOException in case of a problem
+ */
+ void tunnelProxy(HttpHost next, boolean secure, HttpParams params)
+ throws IOException;
+
+ /**
+ * Layers a new protocol on top of a {@link #tunnelTarget tunnelled}
+ * connection. This is typically used to create a TLS/SSL connection
+ * through a proxy.
+ * The route is the one previously passed to {@link #open open}.
+ * It is not guaranteed that the layered connection is
+ * {@link #isSecure secure}.
+ *
+ * @param context the context for layering on top of this connection
+ * @param params the parameters for layering on top of this connection
+ *
+ * @throws IOException in case of a problem
+ */
+ void layerProtocol(HttpContext context, HttpParams params)
+ throws IOException;
+
+ /**
+ * Marks this connection as being in a reusable communication state.
+ * The checkpoints for reuseable communication states (in the absence
+ * of pipelining) are before sending a request and after receiving
+ * the response in its entirety.
+ * The connection will automatically clear the checkpoint when
+ * used for communication. A call to this method indicates that
+ * the next checkpoint has been reached.
+ *
+ * A reusable communication state is necessary but not sufficient
+ * for the connection to be reused.
+ * A {@link #getRoute route} mismatch, the connection being closed,
+ * or other circumstances might prevent reuse.
+ */
+ void markReusable();
+
+ /**
+ * Marks this connection as not being in a reusable state.
+ * This can be used immediately before releasing this connection
+ * to prevent its reuse. Reasons for preventing reuse include
+ * error conditions and the evaluation of a
+ * {@link org.apache.http.ConnectionReuseStrategy reuse strategy}.
+ *
+ * Note:
+ * It is not necessary to call here before writing to
+ * or reading from this connection. Communication attempts will
+ * automatically unmark the state as non-reusable. It can then
+ * be switched back using {@link #markReusable markReusable}.
+ */
+ void unmarkReusable();
+
+ /**
+ * Indicates whether this connection is in a reusable communication state.
+ * See {@link #markReusable markReusable} and
+ * {@link #unmarkReusable unmarkReusable} for details.
+ *
+ * @return true
if this connection is marked as being in
+ * a reusable communication state,
+ * false
otherwise
+ */
+ boolean isMarkedReusable();
+
+ /**
+ * Assigns a state object to this connection. Connection managers may make
+ * use of the connection state when allocating persistent connections.
+ *
+ * @param state The state object
+ */
+ void setState(Object state);
+
+ /**
+ * Returns the state object associated with this connection.
+ *
+ * @return The state object
+ */
+ Object getState();
+
+ /**
+ * Sets the duration that this connection can remain idle before it is
+ * reused. The connection should not be used again if this time elapses. The
+ * idle duration must be reset after each request sent over this connection.
+ * The elapsed time starts counting when the connection is released, which
+ * is typically after the headers (and any response body, if present) is
+ * fully consumed.
+ */
+ void setIdleDuration(long duration, TimeUnit unit);
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/MultihomePlainSocketFactory.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/MultihomePlainSocketFactory.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/MultihomePlainSocketFactory.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,193 @@
+/*
+ * ====================================================================
+ * 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
+ * false
+ *
+ * @throws IllegalArgumentException if the argument is invalid
+ */
+ public final boolean isSecure(Socket sock)
+ throws IllegalArgumentException {
+
+ if (sock == null) {
+ throw new IllegalArgumentException("Socket may not be null.");
+ }
+ // This class check assumes that createSocket() calls the constructor
+ // directly. If it was using javax.net.SocketFactory, we couldn't make
+ // an assumption about the socket class here.
+ if (sock.getClass() != Socket.class) {
+ throw new IllegalArgumentException
+ ("Socket not created by this factory.");
+ }
+ // This check is performed last since it calls a method implemented
+ // by the argument object. getClass() is final in java.lang.Object.
+ if (sock.isClosed()) {
+ throw new IllegalArgumentException("Socket is closed.");
+ }
+
+ return false;
+
+ } // isSecure
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/OperatedClientConnection.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/OperatedClientConnection.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/OperatedClientConnection.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,152 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * The return value is well-defined only while the connection is open.
+ * It may change even while the connection is open,
+ * because of an {@link #update update}.
+ *
+ * @return the host to which this connection is opened
+ */
+ HttpHost getTargetHost();
+
+ /**
+ * Indicates whether this connection is secure.
+ * The return value is well-defined only while the connection is open.
+ * It may change even while the connection is open,
+ * because of an {@link #update update}.
+ *
+ * @return true
if this connection is secure,
+ * false
otherwise
+ */
+ boolean isSecure();
+
+ /**
+ * Obtains the socket for this connection.
+ * The return value is well-defined only while the connection is open.
+ * It may change even while the connection is open,
+ * because of an {@link #update update}.
+ *
+ * @return the socket for communicating with the
+ * {@link #getTargetHost target host}
+ */
+ Socket getSocket();
+
+ /**
+ * Signals that this connection is in the process of being open.
+ * true
if this connection is secure, for
+ * example if an SSLSocket
is used, or
+ * false
if it is not secure
+ * @param params parameters for this connection. The parameters will
+ * be used when creating dependent objects, for example
+ * to determine buffer sizes.
+ */
+ void openCompleted(boolean secure, HttpParams params)
+ throws IOException;
+
+ /**
+ * Updates this connection.
+ * A connection can be updated only while it is open.
+ * Updates are used for example when a tunnel has been established,
+ * or when a TLS/SSL connection has been layered on top of a plain
+ * socket connection.
+ *
+ * Note: Updating the connection will not close the
+ * previously used socket. It is the caller's responsibility to close
+ * that socket if it is no longer required.
+ *
+ * @param sock the new socket for communicating with the target host,
+ * or null
to continue using the old socket.
+ * If null
is passed, helper objects that
+ * depend on the socket should be re-used. In that case,
+ * some changes in the parameters will not take effect.
+ * @param target the new target host of this connection
+ * @param secure true
if this connection is now secure,
+ * false
if it is not secure
+ * @param params new parameters for this connection
+ */
+ void update(Socket sock, HttpHost target,
+ boolean secure, HttpParams params)
+ throws IOException;
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/package.html
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/package.html (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/package.html (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,80 @@
+
+null
,
+ * to allow unsetting in a hierarchy.
+ *
+ * @param params the parameters in which to look up
+ *
+ * @return the default proxy set in the argument parameters, or
+ * null
if not set
+ */
+ public static HttpHost getDefaultProxy(HttpParams params) {
+ if (params == null) {
+ throw new IllegalArgumentException("Parameters must not be null.");
+ }
+ HttpHost proxy = (HttpHost)
+ params.getParameter(DEFAULT_PROXY);
+ if ((proxy != null) && NO_HOST.equals(proxy)) {
+ // value is explicitly unset
+ proxy = null;
+ }
+ return proxy;
+ }
+
+ /**
+ * Sets the {@link ConnRoutePNames#DEFAULT_PROXY DEFAULT_PROXY}
+ * parameter value.
+ *
+ * @param params the parameters in which to set the value
+ * @param proxy the value to set, may be null
.
+ * Note that {@link #NO_HOST} will be mapped to
+ * null
by {@link #getDefaultProxy},
+ * to allow for explicit unsetting in hierarchies.
+ */
+ public static void setDefaultProxy(HttpParams params,
+ HttpHost proxy) {
+ if (params == null) {
+ throw new IllegalArgumentException("Parameters must not be null.");
+ }
+ params.setParameter(DEFAULT_PROXY, proxy);
+ }
+
+ /**
+ * Obtains the {@link ConnRoutePNames#FORCED_ROUTE FORCED_ROUTE}
+ * parameter value.
+ * {@link #NO_ROUTE} will be mapped to null
,
+ * to allow unsetting in a hierarchy.
+ *
+ * @param params the parameters in which to look up
+ *
+ * @return the forced route set in the argument parameters, or
+ * null
if not set
+ */
+ public static HttpRoute getForcedRoute(HttpParams params) {
+ if (params == null) {
+ throw new IllegalArgumentException("Parameters must not be null.");
+ }
+ HttpRoute route = (HttpRoute)
+ params.getParameter(FORCED_ROUTE);
+ if ((route != null) && NO_ROUTE.equals(route)) {
+ // value is explicitly unset
+ route = null;
+ }
+ return route;
+ }
+
+ /**
+ * Sets the {@link ConnRoutePNames#FORCED_ROUTE FORCED_ROUTE}
+ * parameter value.
+ *
+ * @param params the parameters in which to set the value
+ * @param route the value to set, may be null
.
+ * Note that {@link #NO_ROUTE} will be mapped to
+ * null
by {@link #getForcedRoute},
+ * to allow for explicit unsetting in hierarchies.
+ */
+ public static void setForcedRoute(HttpParams params,
+ HttpRoute route) {
+ if (params == null) {
+ throw new IllegalArgumentException("Parameters must not be null.");
+ }
+ params.setParameter(FORCED_ROUTE, route);
+ }
+
+ /**
+ * Obtains the {@link ConnRoutePNames#LOCAL_ADDRESS LOCAL_ADDRESS}
+ * parameter value.
+ * There is no special value that would automatically be mapped to
+ * null
. You can use the wildcard address (0.0.0.0 for IPv4,
+ * :: for IPv6) to override a specific local address in a hierarchy.
+ *
+ * @param params the parameters in which to look up
+ *
+ * @return the local address set in the argument parameters, or
+ * null
if not set
+ */
+ public static InetAddress getLocalAddress(HttpParams params) {
+ if (params == null) {
+ throw new IllegalArgumentException("Parameters must not be null.");
+ }
+ InetAddress local = (InetAddress)
+ params.getParameter(LOCAL_ADDRESS);
+ // no explicit unsetting
+ return local;
+ }
+
+ /**
+ * Sets the {@link ConnRoutePNames#LOCAL_ADDRESS LOCAL_ADDRESS}
+ * parameter value.
+ *
+ * @param params the parameters in which to set the value
+ * @param local the value to set, may be null
+ */
+ public static void setLocalAddress(HttpParams params,
+ InetAddress local) {
+ if (params == null) {
+ throw new IllegalArgumentException("Parameters must not be null.");
+ }
+ params.setParameter(LOCAL_ADDRESS, local);
+ }
+
+}
+
Index: 3rdParty_sources/httpclient/org/apache/http/conn/params/package.html
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/params/package.html (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/params/package.html (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,36 @@
+
+
+
+
+
+Parameters for configuring HTTP connection and connection management
+related classes.
+
+
Index: 3rdParty_sources/httpclient/org/apache/http/conn/routing/BasicRouteDirector.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/routing/BasicRouteDirector.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/routing/BasicRouteDirector.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,168 @@
+/*
+ * ====================================================================
+ * 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
+ * null
if nothing is established
+ *
+ * @return one of the constants defined in this class, indicating
+ * either the next step to perform, or success, or failure.
+ * 0 is for success, a negative value for failure.
+ */
+ public int nextStep(RouteInfo plan, RouteInfo fact) {
+ if (plan == null) {
+ throw new IllegalArgumentException
+ ("Planned route may not be null.");
+ }
+
+ int step = UNREACHABLE;
+
+ if ((fact == null) || (fact.getHopCount() < 1))
+ step = firstStep(plan);
+ else if (plan.getHopCount() > 1)
+ step = proxiedStep(plan, fact);
+ else
+ step = directStep(plan, fact);
+
+ return step;
+
+ } // nextStep
+
+
+ /**
+ * Determines the first step to establish a route.
+ *
+ * @param plan the planned route
+ *
+ * @return the first step
+ */
+ protected int firstStep(RouteInfo plan) {
+
+ return (plan.getHopCount() > 1) ?
+ CONNECT_PROXY : CONNECT_TARGET;
+ }
+
+
+ /**
+ * Determines the next step to establish a direct connection.
+ *
+ * @param plan the planned route
+ * @param fact the currently established route
+ *
+ * @return one of the constants defined in this class, indicating
+ * either the next step to perform, or success, or failure
+ */
+ protected int directStep(RouteInfo plan, RouteInfo fact) {
+
+ if (fact.getHopCount() > 1)
+ return UNREACHABLE;
+ if (!plan.getTargetHost().equals(fact.getTargetHost()))
+ return UNREACHABLE;
+ // If the security is too low, we could now suggest to layer
+ // a secure protocol on the direct connection. Layering on direct
+ // connections has not been supported in HttpClient 3.x, we don't
+ // consider it here until there is a real-life use case for it.
+
+ // Should we tolerate if security is better than planned?
+ // (plan.isSecure() && !fact.isSecure())
+ if (plan.isSecure() != fact.isSecure())
+ return UNREACHABLE;
+
+ // Local address has to match only if the plan specifies one.
+ if ((plan.getLocalAddress() != null) &&
+ !plan.getLocalAddress().equals(fact.getLocalAddress())
+ )
+ return UNREACHABLE;
+
+ return COMPLETE;
+ }
+
+
+ /**
+ * Determines the next step to establish a connection via proxy.
+ *
+ * @param plan the planned route
+ * @param fact the currently established route
+ *
+ * @return one of the constants defined in this class, indicating
+ * either the next step to perform, or success, or failure
+ */
+ protected int proxiedStep(RouteInfo plan, RouteInfo fact) {
+
+ if (fact.getHopCount() <= 1)
+ return UNREACHABLE;
+ if (!plan.getTargetHost().equals(fact.getTargetHost()))
+ return UNREACHABLE;
+ final int phc = plan.getHopCount();
+ final int fhc = fact.getHopCount();
+ if (phc < fhc)
+ return UNREACHABLE;
+
+ for (int i=0; inull
indicates that the default should be used.
+ */
+ private final InetAddress localAddress;
+
+ /** The proxy servers, if any. Never null. */
+ private final HttpHost[] proxyChain;
+
+ /** Whether the the route is tunnelled through the proxy. */
+ private final TunnelType tunnelled;
+
+ /** Whether the route is layered. */
+ private final LayerType layered;
+
+ /** Whether the route is (supposed to be) secure. */
+ private final boolean secure;
+
+
+ /**
+ * Internal, fully-specified constructor.
+ * This constructor does not clone the proxy chain array,
+ * nor test it for null
elements. This conversion and
+ * check is the responsibility of the public constructors.
+ * The order of arguments here is different from the similar public
+ * constructor, as required by Java.
+ *
+ * @param local the local address to route from, or
+ * null
for the default
+ * @param target the host to which to route
+ * @param proxies the proxy chain to use, or
+ * null
for a direct route
+ * @param secure true
if the route is (to be) secure,
+ * false
otherwise
+ * @param tunnelled the tunnel type of this route, or
+ * null
for PLAIN
+ * @param layered the layering type of this route, or
+ * null
for PLAIN
+ */
+ private HttpRoute(InetAddress local,
+ HttpHost target, HttpHost[] proxies,
+ boolean secure,
+ TunnelType tunnelled, LayerType layered) {
+ if (target == null) {
+ throw new IllegalArgumentException
+ ("Target host may not be null.");
+ }
+ if (proxies == null) {
+ throw new IllegalArgumentException
+ ("Proxies may not be null.");
+ }
+ if ((tunnelled == TunnelType.TUNNELLED) && (proxies.length == 0)) {
+ throw new IllegalArgumentException
+ ("Proxy required if tunnelled.");
+ }
+
+ // tunnelled is already checked above, that is in line with the default
+ if (tunnelled == null)
+ tunnelled = TunnelType.PLAIN;
+ if (layered == null)
+ layered = LayerType.PLAIN;
+
+ this.targetHost = target;
+ this.localAddress = local;
+ this.proxyChain = proxies;
+ this.secure = secure;
+ this.tunnelled = tunnelled;
+ this.layered = layered;
+ }
+
+
+ /**
+ * Creates a new route with all attributes specified explicitly.
+ *
+ * @param target the host to which to route
+ * @param local the local address to route from, or
+ * null
for the default
+ * @param proxies the proxy chain to use, or
+ * null
for a direct route
+ * @param secure true
if the route is (to be) secure,
+ * false
otherwise
+ * @param tunnelled the tunnel type of this route
+ * @param layered the layering type of this route
+ */
+ public HttpRoute(HttpHost target, InetAddress local, HttpHost[] proxies,
+ boolean secure, TunnelType tunnelled, LayerType layered) {
+ this(local, target, toChain(proxies), secure, tunnelled, layered);
+ }
+
+
+ /**
+ * Creates a new route with at most one proxy.
+ *
+ * @param target the host to which to route
+ * @param local the local address to route from, or
+ * null
for the default
+ * @param proxy the proxy to use, or
+ * null
for a direct route
+ * @param secure true
if the route is (to be) secure,
+ * false
otherwise
+ * @param tunnelled true
if the route is (to be) tunnelled
+ * via the proxy,
+ * false
otherwise
+ * @param layered true
if the route includes a
+ * layered protocol,
+ * false
otherwise
+ */
+ public HttpRoute(HttpHost target, InetAddress local, HttpHost proxy,
+ boolean secure, TunnelType tunnelled, LayerType layered) {
+ this(local, target, toChain(proxy), secure, tunnelled, layered);
+ }
+
+
+ /**
+ * Creates a new direct route.
+ * That is a route without a proxy.
+ *
+ * @param target the host to which to route
+ * @param local the local address to route from, or
+ * null
for the default
+ * @param secure true
if the route is (to be) secure,
+ * false
otherwise
+ */
+ public HttpRoute(HttpHost target, InetAddress local, boolean secure) {
+ this(local, target, EMPTY_HTTP_HOST_ARRAY, secure, TunnelType.PLAIN, LayerType.PLAIN);
+ }
+
+
+ /**
+ * Creates a new direct insecure route.
+ *
+ * @param target the host to which to route
+ */
+ public HttpRoute(HttpHost target) {
+ this(null, target, EMPTY_HTTP_HOST_ARRAY, false, TunnelType.PLAIN, LayerType.PLAIN);
+ }
+
+
+ /**
+ * Creates a new route through a proxy.
+ * When using this constructor, the proxy
MUST be given.
+ * For convenience, it is assumed that a secure connection will be
+ * layered over a tunnel through the proxy.
+ *
+ * @param target the host to which to route
+ * @param local the local address to route from, or
+ * null
for the default
+ * @param proxy the proxy to use
+ * @param secure true
if the route is (to be) secure,
+ * false
otherwise
+ */
+ public HttpRoute(HttpHost target, InetAddress local, HttpHost proxy,
+ boolean secure) {
+ this(local, target, toChain(proxy), secure,
+ secure ? TunnelType.TUNNELLED : TunnelType.PLAIN,
+ secure ? LayerType.LAYERED : LayerType.PLAIN);
+ if (proxy == null) {
+ throw new IllegalArgumentException
+ ("Proxy host may not be null.");
+ }
+ }
+
+
+ /**
+ * Helper to convert a proxy to a proxy chain.
+ *
+ * @param proxy the only proxy in the chain, or null
+ *
+ * @return a proxy chain array, may be empty (never null)
+ */
+ private static HttpHost[] toChain(HttpHost proxy) {
+ if (proxy == null)
+ return EMPTY_HTTP_HOST_ARRAY;
+
+ return new HttpHost[]{ proxy };
+ }
+
+
+ /**
+ * Helper to duplicate and check a proxy chain.
+ * null
is converted to an empty proxy chain.
+ *
+ * @param proxies the proxy chain to duplicate, or null
+ *
+ * @return a new proxy chain array, may be empty (never null)
+ */
+ private static HttpHost[] toChain(HttpHost[] proxies) {
+ if ((proxies == null) || (proxies.length < 1))
+ return EMPTY_HTTP_HOST_ARRAY;
+
+ for (HttpHost proxy : proxies) {
+ if (proxy == null)
+ throw new IllegalArgumentException
+ ("Proxy chain may not contain null elements.");
+ }
+
+ // copy the proxy chain, the traditional way
+ HttpHost[] result = new HttpHost[proxies.length];
+ System.arraycopy(proxies, 0, result, 0, proxies.length);
+
+ return result;
+ }
+
+
+
+ // non-JavaDoc, see interface RouteInfo
+ public final HttpHost getTargetHost() {
+ return this.targetHost;
+ }
+
+
+ // non-JavaDoc, see interface RouteInfo
+ public final InetAddress getLocalAddress() {
+ return this.localAddress;
+ }
+
+
+ public final int getHopCount() {
+ return proxyChain.length+1;
+ }
+
+
+ public final HttpHost getHopTarget(int hop) {
+ if (hop < 0)
+ throw new IllegalArgumentException
+ ("Hop index must not be negative: " + hop);
+ final int hopcount = getHopCount();
+ if (hop >= hopcount)
+ throw new IllegalArgumentException
+ ("Hop index " + hop +
+ " exceeds route length " + hopcount);
+
+ HttpHost result = null;
+ if (hop < hopcount-1)
+ result = this.proxyChain[hop];
+ else
+ result = this.targetHost;
+
+ return result;
+ }
+
+
+ public final HttpHost getProxyHost() {
+ return (this.proxyChain.length == 0) ? null : this.proxyChain[0];
+ }
+
+
+ public final TunnelType getTunnelType() {
+ return this.tunnelled;
+ }
+
+
+ public final boolean isTunnelled() {
+ return (this.tunnelled == TunnelType.TUNNELLED);
+ }
+
+
+ public final LayerType getLayerType() {
+ return this.layered;
+ }
+
+
+ public final boolean isLayered() {
+ return (this.layered == LayerType.LAYERED);
+ }
+
+
+ public final boolean isSecure() {
+ return this.secure;
+ }
+
+
+ /**
+ * Compares this route to another.
+ *
+ * @param obj the object to compare with
+ *
+ * @return true
if the argument is the same route,
+ * false
+ */
+ @Override
+ public final boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj instanceof HttpRoute) {
+ HttpRoute that = (HttpRoute) obj;
+ return
+ // Do the cheapest tests first
+ (this.secure == that.secure) &&
+ (this.tunnelled == that.tunnelled) &&
+ (this.layered == that.layered) &&
+ LangUtils.equals(this.targetHost, that.targetHost) &&
+ LangUtils.equals(this.localAddress, that.localAddress) &&
+ LangUtils.equals(this.proxyChain, that.proxyChain);
+ } else {
+ return false;
+ }
+ }
+
+
+ /**
+ * Generates a hash code for this route.
+ *
+ * @return the hash code
+ */
+ @Override
+ public final int hashCode() {
+ int hash = LangUtils.HASH_SEED;
+ hash = LangUtils.hashCode(hash, this.targetHost);
+ hash = LangUtils.hashCode(hash, this.localAddress);
+ for (int i = 0; i < this.proxyChain.length; i++) {
+ hash = LangUtils.hashCode(hash, this.proxyChain[i]);
+ }
+ hash = LangUtils.hashCode(hash, this.secure);
+ hash = LangUtils.hashCode(hash, this.tunnelled);
+ hash = LangUtils.hashCode(hash, this.layered);
+ return hash;
+ }
+
+
+ /**
+ * Obtains a description of this route.
+ *
+ * @return a human-readable representation of this route
+ */
+ @Override
+ public final String toString() {
+ StringBuilder cab = new StringBuilder(50 + getHopCount()*30);
+ if (this.localAddress != null) {
+ cab.append(this.localAddress);
+ cab.append("->");
+ }
+ cab.append('{');
+ if (this.tunnelled == TunnelType.TUNNELLED)
+ cab.append('t');
+ if (this.layered == LayerType.LAYERED)
+ cab.append('l');
+ if (this.secure)
+ cab.append('s');
+ cab.append("}->");
+ for (HttpHost aProxyChain : this.proxyChain) {
+ cab.append(aProxyChain);
+ cab.append("->");
+ }
+ cab.append(this.targetHost);
+ return cab.toString();
+ }
+
+
+ // default implementation of clone() is sufficient
+ @Override
+ public Object clone() throws CloneNotSupportedException {
+ return super.clone();
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/routing/HttpRouteDirector.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/routing/HttpRouteDirector.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/routing/HttpRouteDirector.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,74 @@
+/*
+ * ====================================================================
+ * 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
+ * null
if nothing is established
+ *
+ * @return one of the constants defined in this interface, indicating
+ * either the next step to perform, or success, or failure.
+ * 0 is for success, a negative value for failure.
+ */
+ public int nextStep(RouteInfo plan, RouteInfo fact);
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/routing/HttpRoutePlanner.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/routing/HttpRoutePlanner.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/routing/HttpRoutePlanner.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,67 @@
+/*
+ * ====================================================================
+ * 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
+ * null
+ * if they can still determine a route, for example
+ * to a default target or by inspecting the request.
+ * @param request the request to execute
+ * @param context the context to use for the subsequent execution.
+ * Implementations may accept null
.
+ *
+ * @return the route that the request should take
+ *
+ * @throws HttpException in case of a problem
+ */
+ public HttpRoute determineRoute(HttpHost target,
+ HttpRequest request,
+ HttpContext context) throws HttpException;
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/routing/RouteInfo.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/routing/RouteInfo.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/routing/RouteInfo.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,161 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * Layering a protocol
+ * over a direct connection makes little sense, since the connection
+ * could be established with the new protocol in the first place.
+ * But we don't want to exclude that use case.
+ */
+ public enum LayerType { PLAIN, LAYERED }
+
+ /**
+ * Obtains the target host.
+ *
+ * @return the target host
+ */
+ HttpHost getTargetHost();
+
+ /**
+ * Obtains the local address to connect from.
+ *
+ * @return the local address,
+ * or null
+ */
+ InetAddress getLocalAddress();
+
+ /**
+ * Obtains the number of hops in this route.
+ * A direct route has one hop. A route through a proxy has two hops.
+ * A route through a chain of n proxies has n+1 hops.
+ *
+ * @return the number of hops in this route
+ */
+ int getHopCount();
+
+ /**
+ * Obtains the target of a hop in this route.
+ * The target of the last hop is the {@link #getTargetHost target host},
+ * the target of previous hops is the respective proxy in the chain.
+ * For a route through exactly one proxy, target of hop 0 is the proxy
+ * and target of hop 1 is the target host.
+ *
+ * @param hop index of the hop for which to get the target,
+ * 0 for first
+ *
+ * @return the target of the given hop
+ *
+ * @throws IllegalArgumentException
+ * if the argument is negative or not less than
+ * {@link #getHopCount getHopCount()}
+ */
+ HttpHost getHopTarget(int hop);
+
+ /**
+ * Obtains the first proxy host.
+ *
+ * @return the first proxy in the proxy chain, or
+ * null
if this route is direct
+ */
+ HttpHost getProxyHost();
+
+ /**
+ * Obtains the tunnel type of this route.
+ * If there is a proxy chain, only end-to-end tunnels are considered.
+ *
+ * @return the tunnelling type
+ */
+ TunnelType getTunnelType();
+
+ /**
+ * Checks whether this route is tunnelled through a proxy.
+ * If there is a proxy chain, only end-to-end tunnels are considered.
+ *
+ * @return true
if tunnelled end-to-end through at least
+ * one proxy,
+ * false
otherwise
+ */
+ boolean isTunnelled();
+
+ /**
+ * Obtains the layering type of this route.
+ * In the presence of proxies, only layering over an end-to-end tunnel
+ * is considered.
+ *
+ * @return the layering type
+ */
+ LayerType getLayerType();
+
+ /**
+ * Checks whether this route includes a layered protocol.
+ * In the presence of proxies, only layering over an end-to-end tunnel
+ * is considered.
+ *
+ * @return true
if layered,
+ * false
otherwise
+ */
+ boolean isLayered();
+
+ /**
+ * Checks whether this route is secure.
+ *
+ * @return true
if secure,
+ * false
otherwise
+ */
+ boolean isSecure();
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/routing/RouteTracker.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/routing/RouteTracker.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/routing/RouteTracker.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,386 @@
+/*
+ * ====================================================================
+ * 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
+ * null
indicates that the default should be used.
+ */
+ private final InetAddress localAddress;
+
+ // the attributes above are fixed at construction time
+ // now follow attributes that indicate the established route
+
+ /** Whether the first hop of the route is established. */
+ private boolean connected;
+
+ /** The proxy chain, if any. */
+ private HttpHost[] proxyChain;
+
+ /** Whether the the route is tunnelled end-to-end through proxies. */
+ private TunnelType tunnelled;
+
+ /** Whether the route is layered over a tunnel. */
+ private LayerType layered;
+
+ /** Whether the route is secure. */
+ private boolean secure;
+
+ /**
+ * Creates a new route tracker.
+ * The target and origin need to be specified at creation time.
+ *
+ * @param target the host to which to route
+ * @param local the local address to route from, or
+ * null
for the default
+ */
+ public RouteTracker(HttpHost target, InetAddress local) {
+ if (target == null) {
+ throw new IllegalArgumentException("Target host may not be null.");
+ }
+ this.targetHost = target;
+ this.localAddress = local;
+ this.tunnelled = TunnelType.PLAIN;
+ this.layered = LayerType.PLAIN;
+ }
+
+ /**
+ * @since 4.2
+ */
+ public void reset() {
+ this.connected = false;
+ this.proxyChain = null;
+ this.tunnelled = TunnelType.PLAIN;
+ this.layered = LayerType.PLAIN;
+ this.secure = false;
+ }
+
+ /**
+ * Creates a new tracker for the given route.
+ * Only target and origin are taken from the route,
+ * everything else remains to be tracked.
+ *
+ * @param route the route to track
+ */
+ public RouteTracker(HttpRoute route) {
+ this(route.getTargetHost(), route.getLocalAddress());
+ }
+
+ /**
+ * Tracks connecting to the target.
+ *
+ * @param secure true
if the route is secure,
+ * false
otherwise
+ */
+ public final void connectTarget(boolean secure) {
+ if (this.connected) {
+ throw new IllegalStateException("Already connected.");
+ }
+ this.connected = true;
+ this.secure = secure;
+ }
+
+ /**
+ * Tracks connecting to the first proxy.
+ *
+ * @param proxy the proxy connected to
+ * @param secure true
if the route is secure,
+ * false
otherwise
+ */
+ public final void connectProxy(HttpHost proxy, boolean secure) {
+ if (proxy == null) {
+ throw new IllegalArgumentException("Proxy host may not be null.");
+ }
+ if (this.connected) {
+ throw new IllegalStateException("Already connected.");
+ }
+ this.connected = true;
+ this.proxyChain = new HttpHost[]{ proxy };
+ this.secure = secure;
+ }
+
+ /**
+ * Tracks tunnelling to the target.
+ *
+ * @param secure true
if the route is secure,
+ * false
otherwise
+ */
+ public final void tunnelTarget(boolean secure) {
+ if (!this.connected) {
+ throw new IllegalStateException("No tunnel unless connected.");
+ }
+ if (this.proxyChain == null) {
+ throw new IllegalStateException("No tunnel without proxy.");
+ }
+ this.tunnelled = TunnelType.TUNNELLED;
+ this.secure = secure;
+ }
+
+ /**
+ * Tracks tunnelling to a proxy in a proxy chain.
+ * This will extend the tracked proxy chain, but it does not mark
+ * the route as tunnelled. Only end-to-end tunnels are considered there.
+ *
+ * @param proxy the proxy tunnelled to
+ * @param secure true
if the route is secure,
+ * false
otherwise
+ */
+ public final void tunnelProxy(HttpHost proxy, boolean secure) {
+ if (proxy == null) {
+ throw new IllegalArgumentException("Proxy host may not be null.");
+ }
+ if (!this.connected) {
+ throw new IllegalStateException("No tunnel unless connected.");
+ }
+ if (this.proxyChain == null) {
+ throw new IllegalStateException("No proxy tunnel without proxy.");
+ }
+
+ // prepare an extended proxy chain
+ HttpHost[] proxies = new HttpHost[this.proxyChain.length+1];
+ System.arraycopy(this.proxyChain, 0,
+ proxies, 0, this.proxyChain.length);
+ proxies[proxies.length-1] = proxy;
+
+ this.proxyChain = proxies;
+ this.secure = secure;
+ }
+
+ /**
+ * Tracks layering a protocol.
+ *
+ * @param secure true
if the route is secure,
+ * false
otherwise
+ */
+ public final void layerProtocol(boolean secure) {
+ // it is possible to layer a protocol over a direct connection,
+ // although this case is probably not considered elsewhere
+ if (!this.connected) {
+ throw new IllegalStateException
+ ("No layered protocol unless connected.");
+ }
+ this.layered = LayerType.LAYERED;
+ this.secure = secure;
+ }
+
+ public final HttpHost getTargetHost() {
+ return this.targetHost;
+ }
+
+ public final InetAddress getLocalAddress() {
+ return this.localAddress;
+ }
+
+ public final int getHopCount() {
+ int hops = 0;
+ if (this.connected) {
+ if (proxyChain == null)
+ hops = 1;
+ else
+ hops = proxyChain.length + 1;
+ }
+ return hops;
+ }
+
+ public final HttpHost getHopTarget(int hop) {
+ if (hop < 0)
+ throw new IllegalArgumentException
+ ("Hop index must not be negative: " + hop);
+ final int hopcount = getHopCount();
+ if (hop >= hopcount) {
+ throw new IllegalArgumentException
+ ("Hop index " + hop +
+ " exceeds tracked route length " + hopcount +".");
+ }
+
+ HttpHost result = null;
+ if (hop < hopcount-1)
+ result = this.proxyChain[hop];
+ else
+ result = this.targetHost;
+
+ return result;
+ }
+
+ public final HttpHost getProxyHost() {
+ return (this.proxyChain == null) ? null : this.proxyChain[0];
+ }
+
+ public final boolean isConnected() {
+ return this.connected;
+ }
+
+ public final TunnelType getTunnelType() {
+ return this.tunnelled;
+ }
+
+ public final boolean isTunnelled() {
+ return (this.tunnelled == TunnelType.TUNNELLED);
+ }
+
+ public final LayerType getLayerType() {
+ return this.layered;
+ }
+
+ public final boolean isLayered() {
+ return (this.layered == LayerType.LAYERED);
+ }
+
+ public final boolean isSecure() {
+ return this.secure;
+ }
+
+ /**
+ * Obtains the tracked route.
+ * If a route has been tracked, it is {@link #isConnected connected}.
+ * If not connected, nothing has been tracked so far.
+ *
+ * @return the tracked route, or
+ * null
if nothing has been tracked so far
+ */
+ public final HttpRoute toRoute() {
+ return !this.connected ?
+ null : new HttpRoute(this.targetHost, this.localAddress,
+ this.proxyChain, this.secure,
+ this.tunnelled, this.layered);
+ }
+
+ /**
+ * Compares this tracked route to another.
+ *
+ * @param o the object to compare with
+ *
+ * @return true
if the argument is the same tracked route,
+ * false
+ */
+ @Override
+ public final boolean equals(Object o) {
+ if (o == this)
+ return true;
+ if (!(o instanceof RouteTracker))
+ return false;
+
+ RouteTracker that = (RouteTracker) o;
+ return
+ // Do the cheapest checks first
+ (this.connected == that.connected) &&
+ (this.secure == that.secure) &&
+ (this.tunnelled == that.tunnelled) &&
+ (this.layered == that.layered) &&
+ LangUtils.equals(this.targetHost, that.targetHost) &&
+ LangUtils.equals(this.localAddress, that.localAddress) &&
+ LangUtils.equals(this.proxyChain, that.proxyChain);
+ }
+
+ /**
+ * Generates a hash code for this tracked route.
+ * Route trackers are modifiable and should therefore not be used
+ * as lookup keys. Use {@link #toRoute toRoute} to obtain an
+ * unmodifiable representation of the tracked route.
+ *
+ * @return the hash code
+ */
+ @Override
+ public final int hashCode() {
+ int hash = LangUtils.HASH_SEED;
+ hash = LangUtils.hashCode(hash, this.targetHost);
+ hash = LangUtils.hashCode(hash, this.localAddress);
+ if (this.proxyChain != null) {
+ for (int i = 0; i < this.proxyChain.length; i++) {
+ hash = LangUtils.hashCode(hash, this.proxyChain[i]);
+ }
+ }
+ hash = LangUtils.hashCode(hash, this.connected);
+ hash = LangUtils.hashCode(hash, this.secure);
+ hash = LangUtils.hashCode(hash, this.tunnelled);
+ hash = LangUtils.hashCode(hash, this.layered);
+ return hash;
+ }
+
+ /**
+ * Obtains a description of the tracked route.
+ *
+ * @return a human-readable representation of the tracked route
+ */
+ @Override
+ public final String toString() {
+ StringBuilder cab = new StringBuilder(50 + getHopCount()*30);
+
+ cab.append("RouteTracker[");
+ if (this.localAddress != null) {
+ cab.append(this.localAddress);
+ cab.append("->");
+ }
+ cab.append('{');
+ if (this.connected)
+ cab.append('c');
+ if (this.tunnelled == TunnelType.TUNNELLED)
+ cab.append('t');
+ if (this.layered == LayerType.LAYERED)
+ cab.append('l');
+ if (this.secure)
+ cab.append('s');
+ cab.append("}->");
+ if (this.proxyChain != null) {
+ for (int i=0; i
+ *
+ *
+ * @since 4.0
+ */
+@SuppressWarnings("deprecation")
+@Immutable
+public class PlainSocketFactory implements SocketFactory, SchemeSocketFactory {
+
+ private final HostNameResolver nameResolver;
+
+ /**
+ * Gets the default factory.
+ *
+ * @return the default factory
+ */
+ public static PlainSocketFactory getSocketFactory() {
+ return new PlainSocketFactory();
+ }
+
+ /**
+ * @deprecated (4.1) use {@link DnsResolver}
+ */
+ @Deprecated
+ public PlainSocketFactory(final HostNameResolver nameResolver) {
+ super();
+ this.nameResolver = nameResolver;
+ }
+
+ public PlainSocketFactory() {
+ super();
+ this.nameResolver = null;
+ }
+
+ /**
+ * @param params Optional parameters. Parameters passed to this method will have no effect.
+ * This method will create a unconnected instance of {@link Socket} class
+ * using default constructor.
+ *
+ * @since 4.1
+ */
+ public Socket createSocket(final HttpParams params) {
+ return new Socket();
+ }
+
+ public Socket createSocket() {
+ return new Socket();
+ }
+
+ /**
+ * @since 4.1
+ */
+ public Socket connectSocket(
+ final Socket socket,
+ final InetSocketAddress remoteAddress,
+ final InetSocketAddress localAddress,
+ final HttpParams params) throws IOException, ConnectTimeoutException {
+ if (remoteAddress == null) {
+ throw new IllegalArgumentException("Remote address may not be null");
+ }
+ if (params == null) {
+ throw new IllegalArgumentException("HTTP parameters may not be null");
+ }
+ Socket sock = socket;
+ if (sock == null) {
+ sock = createSocket();
+ }
+ if (localAddress != null) {
+ sock.setReuseAddress(HttpConnectionParams.getSoReuseaddr(params));
+ sock.bind(localAddress);
+ }
+ int connTimeout = HttpConnectionParams.getConnectionTimeout(params);
+ int soTimeout = HttpConnectionParams.getSoTimeout(params);
+
+ try {
+ sock.setSoTimeout(soTimeout);
+ sock.connect(remoteAddress, connTimeout);
+ } catch (SocketTimeoutException ex) {
+ throw new ConnectTimeoutException("Connect to " + remoteAddress + " timed out");
+ }
+ return sock;
+ }
+
+ /**
+ * Checks whether a socket connection is secure.
+ * This factory creates plain socket connections
+ * which are not considered secure.
+ *
+ * @param sock the connected socket
+ *
+ * @return false
+ *
+ * @throws IllegalArgumentException if the argument is invalid
+ */
+ public final boolean isSecure(Socket sock)
+ throws IllegalArgumentException {
+
+ if (sock == null) {
+ throw new IllegalArgumentException("Socket may not be null.");
+ }
+ // This check is performed last since it calls a method implemented
+ // by the argument object. getClass() is final in java.lang.Object.
+ if (sock.isClosed()) {
+ throw new IllegalArgumentException("Socket is closed.");
+ }
+ return false;
+ }
+
+ /**
+ * @deprecated (4.1) Use {@link #connectSocket(Socket, InetSocketAddress, InetSocketAddress, HttpParams)}
+ */
+ @Deprecated
+ public Socket connectSocket(
+ final Socket socket,
+ final String host, int port,
+ final InetAddress localAddress, int localPort,
+ final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
+ InetSocketAddress local = null;
+ if (localAddress != null || localPort > 0) {
+ // we need to bind explicitly
+ if (localPort < 0) {
+ localPort = 0; // indicates "any"
+ }
+ local = new InetSocketAddress(localAddress, localPort);
+ }
+ InetAddress remoteAddress;
+ if (this.nameResolver != null) {
+ remoteAddress = this.nameResolver.resolve(host);
+ } else {
+ remoteAddress = InetAddress.getByName(host);
+ }
+ InetSocketAddress remote = new InetSocketAddress(remoteAddress, port);
+ return connectSocket(socket, remote, local, params);
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/scheme/Scheme.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/scheme/Scheme.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/scheme/Scheme.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,269 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * Scheme https = new Scheme("https", 443, new MySecureSocketFactory());
+ * SchemeRegistry.DEFAULT.register(https);
+ *
+ *
+ * @since 4.0
+ */
+@Immutable
+public final class Scheme {
+
+ /** The name of this scheme, in lowercase. (e.g. http, https) */
+ private final String name;
+
+ /** The socket factory for this scheme */
+ private final SchemeSocketFactory socketFactory;
+
+ /** The default port for this scheme */
+ private final int defaultPort;
+
+ /** Indicates whether this scheme allows for layered connections */
+ private final boolean layered;
+
+ /** A string representation, for {@link #toString toString}. */
+ private String stringRep;
+ /*
+ * This is used to cache the result of the toString() method
+ * Since the method always generates the same value, there's no
+ * need to synchronize, and it does not affect immutability.
+ */
+
+ /**
+ * Creates a new scheme.
+ * Whether the created scheme allows for layered connections
+ * depends on the class of factory
.
+ *
+ * @param name the scheme name, for example "http".
+ * The name will be converted to lowercase.
+ * @param port the default port for this scheme
+ * @param factory the factory for creating sockets for communication
+ * with this scheme
+ *
+ * @since 4.1
+ */
+ @SuppressWarnings("deprecation")
+ public Scheme(final String name, final int port, final SchemeSocketFactory factory) {
+ if (name == null) {
+ throw new IllegalArgumentException("Scheme name may not be null");
+ }
+ if ((port <= 0) || (port > 0xffff)) {
+ throw new IllegalArgumentException("Port is invalid: " + port);
+ }
+ if (factory == null) {
+ throw new IllegalArgumentException("Socket factory may not be null");
+ }
+ this.name = name.toLowerCase(Locale.ENGLISH);
+ this.defaultPort = port;
+ if (factory instanceof SchemeLayeredSocketFactory) {
+ this.layered = true;
+ this.socketFactory = factory;
+ } else if (factory instanceof LayeredSchemeSocketFactory) {
+ this.layered = true;
+ this.socketFactory = new SchemeLayeredSocketFactoryAdaptor2((LayeredSchemeSocketFactory) factory);
+ } else {
+ this.layered = false;
+ this.socketFactory = factory;
+ }
+ }
+
+ /**
+ * Creates a new scheme.
+ * Whether the created scheme allows for layered connections
+ * depends on the class of factory
.
+ *
+ * @param name the scheme name, for example "http".
+ * The name will be converted to lowercase.
+ * @param factory the factory for creating sockets for communication
+ * with this scheme
+ * @param port the default port for this scheme
+ *
+ * @deprecated (4.1) Use {@link #Scheme(String, int, SchemeSocketFactory)}
+ */
+ @Deprecated
+ public Scheme(final String name,
+ final SocketFactory factory,
+ final int port) {
+
+ if (name == null) {
+ throw new IllegalArgumentException
+ ("Scheme name may not be null");
+ }
+ if (factory == null) {
+ throw new IllegalArgumentException
+ ("Socket factory may not be null");
+ }
+ if ((port <= 0) || (port > 0xffff)) {
+ throw new IllegalArgumentException
+ ("Port is invalid: " + port);
+ }
+
+ this.name = name.toLowerCase(Locale.ENGLISH);
+ if (factory instanceof LayeredSocketFactory) {
+ this.socketFactory = new SchemeLayeredSocketFactoryAdaptor(
+ (LayeredSocketFactory) factory);
+ this.layered = true;
+ } else {
+ this.socketFactory = new SchemeSocketFactoryAdaptor(factory);
+ this.layered = false;
+ }
+ this.defaultPort = port;
+ }
+
+ /**
+ * Obtains the default port.
+ *
+ * @return the default port for this scheme
+ */
+ public final int getDefaultPort() {
+ return defaultPort;
+ }
+
+
+ /**
+ * Obtains the socket factory.
+ * If this scheme is {@link #isLayered layered}, the factory implements
+ * {@link LayeredSocketFactory LayeredSocketFactory}.
+ *
+ * @return the socket factory for this scheme
+ *
+ * @deprecated (4.1) Use {@link #getSchemeSocketFactory()}
+ */
+ @Deprecated
+ public final SocketFactory getSocketFactory() {
+ if (this.socketFactory instanceof SchemeSocketFactoryAdaptor) {
+ return ((SchemeSocketFactoryAdaptor) this.socketFactory).getFactory();
+ } else {
+ if (this.layered) {
+ return new LayeredSocketFactoryAdaptor(
+ (LayeredSchemeSocketFactory) this.socketFactory);
+ } else {
+ return new SocketFactoryAdaptor(this.socketFactory);
+ }
+ }
+ }
+
+ /**
+ * Obtains the socket factory.
+ * If this scheme is {@link #isLayered layered}, the factory implements
+ * {@link LayeredSocketFactory LayeredSchemeSocketFactory}.
+ *
+ * @return the socket factory for this scheme
+ *
+ * @since 4.1
+ */
+ public final SchemeSocketFactory getSchemeSocketFactory() {
+ return this.socketFactory;
+ }
+
+ /**
+ * Obtains the scheme name.
+ *
+ * @return the name of this scheme, in lowercase
+ */
+ public final String getName() {
+ return name;
+ }
+
+ /**
+ * Indicates whether this scheme allows for layered connections.
+ *
+ * @return true
if layered connections are possible,
+ * false
otherwise
+ */
+ public final boolean isLayered() {
+ return layered;
+ }
+
+ /**
+ * Resolves the correct port for this scheme.
+ * Returns the given port if it is valid, the default port otherwise.
+ *
+ * @param port the port to be resolved,
+ * a negative number to obtain the default port
+ *
+ * @return the given port or the defaultPort
+ */
+ public final int resolvePort(int port) {
+ return port <= 0 ? defaultPort : port;
+ }
+
+ /**
+ * Return a string representation of this object.
+ *
+ * @return a human-readable string description of this scheme
+ */
+ @Override
+ public final String toString() {
+ if (stringRep == null) {
+ StringBuilder buffer = new StringBuilder();
+ buffer.append(this.name);
+ buffer.append(':');
+ buffer.append(Integer.toString(this.defaultPort));
+ stringRep = buffer.toString();
+ }
+ return stringRep;
+ }
+
+ @Override
+ public final boolean equals(Object obj) {
+ if (this == obj) return true;
+ if (obj instanceof Scheme) {
+ Scheme that = (Scheme) obj;
+ return this.name.equals(that.name)
+ && this.defaultPort == that.defaultPort
+ && this.layered == that.layered;
+ } else {
+ return false;
+ }
+ }
+
+ @Override
+ public int hashCode() {
+ int hash = LangUtils.HASH_SEED;
+ hash = LangUtils.hashCode(hash, this.defaultPort);
+ hash = LangUtils.hashCode(hash, this.name);
+ hash = LangUtils.hashCode(hash, this.layered);
+ return hash;
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/scheme/SchemeLayeredSocketFactory.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/scheme/SchemeLayeredSocketFactory.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/scheme/SchemeLayeredSocketFactory.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,65 @@
+/*
+ * ====================================================================
+ * 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
+ * null
+ *
+ * @throws IllegalStateException
+ * if the scheme with the given name is not registered
+ */
+ public final Scheme getScheme(String name) {
+ Scheme found = get(name);
+ if (found == null) {
+ throw new IllegalStateException
+ ("Scheme '"+name+"' not registered.");
+ }
+ return found;
+ }
+
+ /**
+ * Obtains the scheme for a host.
+ * Convenience method for getScheme(host.getSchemeName())
+ *
+ * @param host the host for which to obtain the scheme
+ *
+ * @return the scheme for the given host, never
null
+ *
+ * @throws IllegalStateException
+ * if a scheme with the respective name is not registered
+ */
+ public final Scheme getScheme(HttpHost host) {
+ if (host == null) {
+ throw new IllegalArgumentException("Host must not be null.");
+ }
+ return getScheme(host.getSchemeName());
+ }
+
+ /**
+ * Obtains a scheme by name, if registered.
+ *
+ * @param name the name of the scheme to look up (in lowercase)
+ *
+ * @return the scheme, or
+ * null
if there is none by this name
+ */
+ public final Scheme get(String name) {
+ if (name == null)
+ throw new IllegalArgumentException("Name must not be null.");
+
+ // leave it to the caller to use the correct name - all lowercase
+ //name = name.toLowerCase();
+ Scheme found = registeredSchemes.get(name);
+ return found;
+ }
+
+ /**
+ * Registers a scheme.
+ * The scheme can later be retrieved by its name
+ * using {@link #getScheme(String) getScheme} or {@link #get get}.
+ *
+ * @param sch the scheme to register
+ *
+ * @return the scheme previously registered with that name, or
+ * null
if none was registered
+ */
+ public final Scheme register(Scheme sch) {
+ if (sch == null)
+ throw new IllegalArgumentException("Scheme must not be null.");
+
+ Scheme old = registeredSchemes.put(sch.getName(), sch);
+ return old;
+ }
+
+ /**
+ * Unregisters a scheme.
+ *
+ * @param name the name of the scheme to unregister (in lowercase)
+ *
+ * @return the unregistered scheme, or
+ * null
if there was none
+ */
+ public final Scheme unregister(String name) {
+ if (name == null)
+ throw new IllegalArgumentException("Name must not be null.");
+
+ // leave it to the caller to use the correct name - all lowercase
+ //name = name.toLowerCase();
+ Scheme gone = registeredSchemes.remove(name);
+ return gone;
+ }
+
+ /**
+ * Obtains the names of the registered schemes.
+ *
+ * @return List containing registered scheme names.
+ */
+ public final Listnull
indicates that a new socket
+ * should be created and connected.
+ * @param remoteAddress the remote address to connect to.
+ * @param localAddress the local address to bind the socket to, or
+ * null
for any
+ * @param params additional {@link HttpParams parameters} for connecting
+ *
+ * @return the connected socket. The returned object may be different
+ * from the sock
argument if this factory supports
+ * a layered protocol.
+ *
+ * @throws IOException if an I/O error occurs
+ * @throws UnknownHostException if the IP address of the target host
+ * can not be determined
+ * @throws ConnectTimeoutException if the socket cannot be connected
+ * within the time limit defined in the params
+ *
+ * @see HttpInetSocketAddress
+ */
+ Socket connectSocket(
+ Socket sock,
+ InetSocketAddress remoteAddress,
+ InetSocketAddress localAddress,
+ HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException;
+
+ /**
+ * Checks whether a socket provides a secure connection. The socket must be
+ * {@link #connectSocket(Socket, InetSocketAddress, InetSocketAddress, HttpParams) connected}
+ * by this factory. The factory will not perform I/O operations in this method.
+ * true
if the connection of the socket
+ * should be considered secure, or
+ * false
if it should not
+ *
+ * @throws IllegalArgumentException
+ * if the argument is invalid, for example because it is
+ * not a connected socket or was created by a different
+ * socket factory.
+ * Note that socket factories are not required to
+ * check these conditions, they may simply return a default
+ * value when called with an invalid socket argument.
+ */
+ boolean isSecure(Socket sock) throws IllegalArgumentException;
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/scheme/SchemeSocketFactoryAdaptor.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,96 @@
+/*
+ * ====================================================================
+ * 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
+ * null
indicates that a new socket
+ * should be created and connected.
+ * @param host the host to connect to
+ * @param port the port to connect to on the host
+ * @param localAddress the local address to bind the socket to, or
+ * null
for any
+ * @param localPort the port on the local machine,
+ * 0 or a negative number for any
+ * @param params additional {@link HttpParams parameters} for connecting
+ *
+ * @return the connected socket. The returned object may be different
+ * from the sock
argument if this factory supports
+ * a layered protocol.
+ *
+ * @throws IOException if an I/O error occurs
+ * @throws UnknownHostException if the IP address of the target host
+ * can not be determined
+ * @throws ConnectTimeoutException if the socket cannot be connected
+ * within the time limit defined in the params
+ */
+ Socket connectSocket(
+ Socket sock,
+ String host,
+ int port,
+ InetAddress localAddress,
+ int localPort,
+ HttpParams params
+ ) throws IOException, UnknownHostException, ConnectTimeoutException;
+
+ /**
+ * Checks whether a socket provides a secure connection.
+ * The socket must be {@link #connectSocket connected}
+ * by this factory.
+ * The factory will not perform I/O operations
+ * in this method.
+ *
+ * As a rule of thumb, plain sockets are not secure and
+ * TLS/SSL sockets are secure. However, there may be
+ * application specific deviations. For example, a plain
+ * socket to a host in the same intranet ("trusted zone")
+ * could be considered secure. On the other hand, a
+ * TLS/SSL socket could be considered insecure based on
+ * the cipher suite chosen for the connection.
+ *
+ * @param sock the connected socket to check
+ *
+ * @return true
if the connection of the socket
+ * should be considered secure, or
+ * false
if it should not
+ *
+ * @throws IllegalArgumentException
+ * if the argument is invalid, for example because it is
+ * not a connected socket or was created by a different
+ * socket factory.
+ * Note that socket factories are not required to
+ * check these conditions, they may simply return a default
+ * value when called with an invalid socket argument.
+ */
+ boolean isSecure(Socket sock)
+ throws IllegalArgumentException;
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/scheme/SocketFactoryAdaptor.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/scheme/SocketFactoryAdaptor.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/scheme/SocketFactoryAdaptor.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,100 @@
+/*
+ * ====================================================================
+ * 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
+ * RFC 2253
.
+
+ I've noticed that toString() seems to do a better job than
+ getName() on these X500Principal objects, so I'm hoping that
+ addresses Sebastian's concern.
+
+ For example, getName() gives me this:
+ 1.2.840.113549.1.9.1=#16166a756c6975736461766965734063756362632e636f6d
+
+ whereas toString() gives me this:
+ EMAILADDRESS=juliusdavies@cucbc.com
+
+ Looks like toString() even works with non-ascii domain names!
+ I tested it with "花子.co.jp" and it worked fine.
+ */
+ String subjectPrincipal = cert.getSubjectX500Principal().toString();
+ StringTokenizer st = new StringTokenizer(subjectPrincipal, ",");
+ while(st.hasMoreTokens()) {
+ String tok = st.nextToken();
+ int x = tok.indexOf("CN=");
+ if(x >= 0) {
+ cnList.add(tok.substring(x + 3));
+ }
+ }
+ if(!cnList.isEmpty()) {
+ String[] cns = new String[cnList.size()];
+ cnList.toArray(cns);
+ return cns;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Extracts the array of SubjectAlt DNS or IP names from an X509Certificate.
+ * Returns null if there aren't any.
+ *
+ * @param cert X509Certificate
+ * @param hostname
+ * @return Array of SubjectALT DNS or IP names stored in the certificate.
+ */
+ private static String[] getSubjectAlts(
+ final X509Certificate cert, final String hostname) {
+ int subjectType;
+ if (isIPAddress(hostname)) {
+ subjectType = 7;
+ } else {
+ subjectType = 2;
+ }
+
+ LinkedList> c = null;
+ try {
+ c = cert.getSubjectAlternativeNames();
+ }
+ catch(CertificateParsingException cpe) {
+ Logger.getLogger(AbstractVerifier.class.getName())
+ .log(Level.FINE, "Error parsing certificate.", cpe);
+ }
+ if(c != null) {
+ for (List> aC : c) {
+ List> list = aC;
+ int type = ((Integer) list.get(0)).intValue();
+ if (type == subjectType) {
+ String s = (String) list.get(1);
+ subjectAltList.add(s);
+ }
+ }
+ }
+ if(!subjectAltList.isEmpty()) {
+ String[] subjectAlts = new String[subjectAltList.size()];
+ subjectAltList.toArray(subjectAlts);
+ return subjectAlts;
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * Extracts the array of SubjectAlt DNS names from an X509Certificate.
+ * Returns null if there aren't any.
+ *
+ * Note: Java doesn't appear able to extract international characters
+ * from the SubjectAlts. It can only extract international characters
+ * from the CN field.
+ *
+ * (Or maybe the version of OpenSSL I'm using to test isn't storing the
+ * international characters correctly in the SubjectAlts?).
+ *
+ * @param cert X509Certificate
+ * @return Array of SubjectALT DNS names stored in the certificate.
+ */
+ public static String[] getDNSSubjectAlts(X509Certificate cert) {
+ return getSubjectAlts(cert, null);
+ }
+
+ /**
+ * Counts the number of dots "." in a string.
+ * @param s string to count dots from
+ * @return number of dots
+ */
+ public static int countDots(final String s) {
+ int count = 0;
+ for(int i = 0; i < s.length(); i++) {
+ if(s.charAt(i) == '.') {
+ count++;
+ }
+ }
+ return count;
+ }
+
+ private static boolean isIPAddress(final String hostname) {
+ return hostname != null &&
+ (InetAddressUtils.isIPv4Address(hostname) ||
+ InetAddressUtils.isIPv6Address(hostname));
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/ssl/AllowAllHostnameVerifier.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,54 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ * keytool -import -alias "my server cert" -file server.crt -keystore my.truststore
+ *
+ *
+ *
+ *
+ *
keytool -genkey -v -alias "my client key" -validity 365 -keystore my.keystore
+ * For simplicity use the same password for the key as that of the key-store
+ * keytool -certreq -alias "my client key" -file mycertreq.csr -keystore my.keystore
+ * keytool -import -alias "my trusted ca" -file caroot.crt -keystore my.keystore
+ * keytool -import -alias "my client key" -file mycert.p7 -keystore my.keystore
+ * keytool -list -v -keystore my.keystore
+ *
+ *
+ *
+ * Derived classes may override this method to perform
+ * runtime checks, for example based on the cypher suite.
+ *
+ * @param sock the connected socket
+ *
+ * @return true
+ *
+ * @throws IllegalArgumentException if the argument is invalid
+ */
+ public boolean isSecure(final Socket sock) throws IllegalArgumentException {
+ if (sock == null) {
+ throw new IllegalArgumentException("Socket may not be null");
+ }
+ // This instanceof check is in line with createSocket() above.
+ if (!(sock instanceof SSLSocket)) {
+ throw new IllegalArgumentException("Socket not created by this factory");
+ }
+ // This check is performed last since it calls the argument object.
+ if (sock.isClosed()) {
+ throw new IllegalArgumentException("Socket is closed");
+ }
+ return true;
+ }
+
+ /**
+ * @since 4.2
+ */
+ public Socket createLayeredSocket(
+ final Socket socket,
+ final String host,
+ final int port,
+ final HttpParams params) throws IOException, UnknownHostException {
+ SSLSocket sslSocket = (SSLSocket) this.socketfactory.createSocket(
+ socket,
+ host,
+ port,
+ true);
+ prepareSocket(sslSocket);
+ if (this.hostnameVerifier != null) {
+ this.hostnameVerifier.verify(host, sslSocket);
+ }
+ // verifyHostName() didn't blowup - good!
+ return sslSocket;
+ }
+
+ /**
+ * @deprecated use {@link #createLayeredSocket(Socket, String, int, HttpParams)}
+ */
+ public Socket createLayeredSocket(
+ final Socket socket,
+ final String host,
+ final int port,
+ final boolean autoClose) throws IOException, UnknownHostException {
+ SSLSocket sslSocket = (SSLSocket) this.socketfactory.createSocket(
+ socket,
+ host,
+ port,
+ autoClose
+ );
+ prepareSocket(sslSocket);
+ if (this.hostnameVerifier != null) {
+ this.hostnameVerifier.verify(host, sslSocket);
+ }
+ // verifyHostName() didn't blowup - good!
+ return sslSocket;
+ }
+
+ @Deprecated
+ public void setHostnameVerifier(X509HostnameVerifier hostnameVerifier) {
+ if ( hostnameVerifier == null ) {
+ throw new IllegalArgumentException("Hostname verifier may not be null");
+ }
+ this.hostnameVerifier = hostnameVerifier;
+ }
+
+ public X509HostnameVerifier getHostnameVerifier() {
+ return this.hostnameVerifier;
+ }
+
+ /**
+ * @deprecated Use {@link #connectSocket(Socket, InetSocketAddress, InetSocketAddress, HttpParams)}
+ */
+ @Deprecated
+ public Socket connectSocket(
+ final Socket socket,
+ final String host, int port,
+ final InetAddress localAddress, int localPort,
+ final HttpParams params) throws IOException, UnknownHostException, ConnectTimeoutException {
+ InetSocketAddress local = null;
+ if (localAddress != null || localPort > 0) {
+ // we need to bind explicitly
+ if (localPort < 0) {
+ localPort = 0; // indicates "any"
+ }
+ local = new InetSocketAddress(localAddress, localPort);
+ }
+ InetAddress remoteAddress;
+ if (this.nameResolver != null) {
+ remoteAddress = this.nameResolver.resolve(host);
+ } else {
+ remoteAddress = InetAddress.getByName(host);
+ }
+ InetSocketAddress remote = new HttpInetSocketAddress(new HttpHost(host, port), remoteAddress, port);
+ return connectSocket(socket, remote, local, params);
+ }
+
+ /**
+ * @deprecated Use {@link #createLayeredSocket(Socket, String, int, boolean)}
+ */
+ @Deprecated
+ public Socket createSocket(
+ final Socket socket,
+ final String host, int port,
+ boolean autoClose) throws IOException, UnknownHostException {
+ return createLayeredSocket(socket, host, port, autoClose);
+ }
+
+ /**
+ * Performs any custom initialization for a newly created SSLSocket
+ * (before the SSL handshake happens).
+ *
+ * The default implementation is a no-op, but could be overriden to, e.g.,
+ * call {@link SSLSocket#setEnabledCipherSuites(java.lang.String[])}.
+ *
+ * @since 4.2
+ */
+ protected void prepareSocket(final SSLSocket socket) throws IOException {
+ }
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/ssl/StrictHostnameVerifier.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/ssl/StrictHostnameVerifier.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/ssl/StrictHostnameVerifier.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,69 @@
+/*
+ * ====================================================================
+ * 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
+ * false
, the trust manager configured
+ * in the actual SSL context can still clear the certificate as trusted.
+ *
+ * @param chain the peer certificate chain
+ * @param authType the authentication type based on the client certificate
+ * @return true
if the certificate can be trusted without verification by
+ * the trust manager, false
otherwise.
+ * @throws CertificateException thrown if the certificate is not trusted or invalid.
+ */
+ boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException;
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/conn/ssl/X509HostnameVerifier.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/conn/ssl/X509HostnameVerifier.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/conn/ssl/X509HostnameVerifier.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,84 @@
+/*
+ * ====================================================================
+ * 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
+ * true
if this cookie should only be sent
+ * over secure connections, false
otherwise.
+ */
+ boolean isSecure();
+
+ /**
+ * Returns the version of the cookie specification to which this
+ * cookie conforms.
+ *
+ * @return the version of the cookie.
+ */
+ int getVersion();
+
+ /**
+ * Returns true if this cookie has expired.
+ * @param date Current time
+ *
+ * @return true if the cookie has expired.
+ */
+ boolean isExpired(final Date date);
+
+}
+
Index: 3rdParty_sources/httpclient/org/apache/http/cookie/CookieAttributeHandler.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/cookie/CookieAttributeHandler.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/cookie/CookieAttributeHandler.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,73 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ *
+ * for a given host, port and path of origin
+ *
+ *
+ * @since 4.0
+ */
+public interface CookieSpec {
+
+ /**
+ * Returns version of the state management this cookie specification
+ * conforms to.
+ *
+ * @return version of the state management specification
+ */
+ int getVersion();
+
+ /**
+ * Parse the "Set-Cookie" Header into an array of Cookies.
+ *
+ * null
if the cookie
+ * specification does not support Cookie2 header.
+ */
+ Header getVersionHeader();
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/cookie/CookieSpecFactory.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/cookie/CookieSpecFactory.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/cookie/CookieSpecFactory.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,48 @@
+/*
+ * ====================================================================
+ * 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
+ * Set-Cookie
response header sent by the
+ * origin server to the HTTP agent in order to maintain a conversational state.
+ *
+ * @since 4.0
+ */
+public interface SetCookie extends Cookie {
+
+ void setValue(String value);
+
+ /**
+ * If a user agent (web browser) presents this cookie to a user, the
+ * cookie's purpose will be described using this comment.
+ *
+ * @param comment
+ *
+ * @see #getComment()
+ */
+ void setComment(String comment);
+
+ /**
+ * Sets expiration date.
+ * Set-Cookie2
response header sent by the
+ * origin server to the HTTP agent in order to maintain a conversational state.
+ *
+ * @since 4.0
+ */
+public interface SetCookie2 extends SetCookie {
+
+ /**
+ * If a user agent (web browser) presents this cookie to a user, the
+ * cookie's purpose will be described by the information at this URL.
+ */
+ void setCommentURL(String commentURL);
+
+ /**
+ * Sets the Port attribute. It restricts the ports to which a cookie
+ * may be returned in a Cookie request header.
+ */
+ void setPorts(int[] ports);
+
+ /**
+ * Set the Discard attribute.
+ *
+ * Note: Discard attribute overrides Max-age.
+ *
+ * @see #isPersistent()
+ */
+ void setDiscard(boolean discard);
+
+}
+
Index: 3rdParty_sources/httpclient/org/apache/http/cookie/package.html
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/cookie/package.html (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/cookie/package.html (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,35 @@
+
+expires
attribute. Only required for compatibility
+ * with non-compliant servers that still use expires
+ * defined in the Netscape draft instead of the standard
+ * max-age
attribute.
+ * Cookie
request header. Otherwise, each cookie is formatted
+ * as a separate Cookie
header.
+ * true
if authenticating against a proxy, false
+ * otherwise.
+ */
+ public boolean isProxy() {
+ return this.challengeState != null && this.challengeState == ChallengeState.PROXY;
+ }
+
+ /**
+ * Returns {@link ChallengeState} value or null
if unchallenged.
+ *
+ * @since 4.2
+ */
+ public ChallengeState getChallengeState() {
+ return this.challengeState;
+ }
+
+ @Override
+ public String toString() {
+ String name = getSchemeName();
+ if (name != null) {
+ return name.toUpperCase(Locale.US);
+ } else {
+ return super.toString();
+ }
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/auth/BasicScheme.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/auth/BasicScheme.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/auth/BasicScheme.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,201 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ *
+ *
+ *
+ * @since 4.0
+ */
+@NotThreadSafe
+public class BasicScheme extends RFC2617Scheme {
+
+ /** Whether the basic authentication process is complete */
+ private boolean complete;
+
+ /**
+ * Creates an instance of BasicScheme with the given challenge
+ * state.
+ *
+ * @since 4.2
+ */
+ public BasicScheme(final ChallengeState challengeState) {
+ super(challengeState);
+ this.complete = false;
+ }
+
+ public BasicScheme() {
+ this(null);
+ }
+
+ /**
+ * Returns textual designation of the basic authentication scheme.
+ *
+ * @return basic
+ */
+ public String getSchemeName() {
+ return "basic";
+ }
+
+ /**
+ * Processes the Basic challenge.
+ *
+ * @param header the challenge header
+ *
+ * @throws MalformedChallengeException is thrown if the authentication challenge
+ * is malformed
+ */
+ @Override
+ public void processChallenge(
+ final Header header) throws MalformedChallengeException {
+ super.processChallenge(header);
+ this.complete = true;
+ }
+
+ /**
+ * Tests if the Basic authentication process has been completed.
+ *
+ * @return true if Basic authorization has been processed,
+ * false otherwise.
+ */
+ public boolean isComplete() {
+ return this.complete;
+ }
+
+ /**
+ * Returns false. Basic authentication scheme is request based.
+ *
+ * @return false.
+ */
+ public boolean isConnectionBased() {
+ return false;
+ }
+
+ /**
+ * @deprecated (4.2) Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, org.apache.http.protocol.HttpContext)}
+ */
+ @Deprecated
+ public Header authenticate(
+ final Credentials credentials, final HttpRequest request) throws AuthenticationException {
+ return authenticate(credentials, request, new BasicHttpContext());
+ }
+
+ /**
+ * Produces basic authorization header for the given set of {@link Credentials}.
+ *
+ * @param credentials The set of credentials to be used for authentication
+ * @param request The request being authenticated
+ * @throws InvalidCredentialsException if authentication credentials are not
+ * valid or not applicable for this authentication scheme
+ * @throws AuthenticationException if authorization string cannot
+ * be generated due to an authentication failure
+ *
+ * @return a basic authorization string
+ */
+ @Override
+ public Header authenticate(
+ final Credentials credentials,
+ final HttpRequest request,
+ final HttpContext context) throws AuthenticationException {
+
+ if (credentials == null) {
+ throw new IllegalArgumentException("Credentials may not be null");
+ }
+ if (request == null) {
+ throw new IllegalArgumentException("HTTP request may not be null");
+ }
+
+ String charset = AuthParams.getCredentialCharset(request.getParams());
+ return authenticate(credentials, charset, isProxy());
+ }
+
+ /**
+ * Returns a basic Authorization header value for the given
+ * {@link Credentials} and charset.
+ *
+ * @param credentials The credentials to encode.
+ * @param charset The charset to use for encoding the credentials
+ *
+ * @return a basic authorization header
+ */
+ public static Header authenticate(
+ final Credentials credentials,
+ final String charset,
+ boolean proxy) {
+ if (credentials == null) {
+ throw new IllegalArgumentException("Credentials may not be null");
+ }
+ if (charset == null) {
+ throw new IllegalArgumentException("charset may not be null");
+ }
+
+ StringBuilder tmp = new StringBuilder();
+ tmp.append(credentials.getUserPrincipal().getName());
+ tmp.append(":");
+ tmp.append((credentials.getPassword() == null) ? "null" : credentials.getPassword());
+
+ byte[] base64password = Base64.encodeBase64(
+ EncodingUtils.getBytes(tmp.toString(), charset));
+
+ CharArrayBuffer buffer = new CharArrayBuffer(32);
+ if (proxy) {
+ buffer.append(AUTH.PROXY_AUTH_RESP);
+ } else {
+ buffer.append(AUTH.WWW_AUTH_RESP);
+ }
+ buffer.append(": Basic ");
+ buffer.append(base64password, 0, base64password.length);
+
+ return new BufferedHeader(buffer);
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/auth/BasicSchemeFactory.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/auth/BasicSchemeFactory.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/auth/BasicSchemeFactory.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,49 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ *
+ *
+ * @since 4.0
+ */
+@NotThreadSafe
+public class DigestScheme extends RFC2617Scheme {
+
+ /**
+ * Hexa values used when creating 32 character long digest in HTTP DigestScheme
+ * in case of authentication.
+ *
+ * @see #encode(byte[])
+ */
+ private static final char[] HEXADECIMAL = {
+ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
+ 'e', 'f'
+ };
+
+ /** Whether the digest authentication process is complete */
+ private boolean complete;
+
+ private static final int QOP_UNKNOWN = -1;
+ private static final int QOP_MISSING = 0;
+ private static final int QOP_AUTH_INT = 1;
+ private static final int QOP_AUTH = 2;
+
+ private String lastNonce;
+ private long nounceCount;
+ private String cnonce;
+ private String a1;
+ private String a2;
+
+ /**
+ * Creates an instance of DigestScheme with the given challenge
+ * state.
+ *
+ * @since 4.2
+ */
+ public DigestScheme(final ChallengeState challengeState) {
+ super(challengeState);
+ this.complete = false;
+ }
+
+ public DigestScheme() {
+ this(null);
+ }
+
+ /**
+ * Processes the Digest challenge.
+ *
+ * @param header the challenge header
+ *
+ * @throws MalformedChallengeException is thrown if the authentication challenge
+ * is malformed
+ */
+ @Override
+ public void processChallenge(
+ final Header header) throws MalformedChallengeException {
+ super.processChallenge(header);
+ this.complete = true;
+ }
+
+ /**
+ * Tests if the Digest authentication process has been completed.
+ *
+ * @return true if Digest authorization has been processed,
+ * false otherwise.
+ */
+ public boolean isComplete() {
+ String s = getParameter("stale");
+ if ("true".equalsIgnoreCase(s)) {
+ return false;
+ } else {
+ return this.complete;
+ }
+ }
+
+ /**
+ * Returns textual designation of the digest authentication scheme.
+ *
+ * @return digest
+ */
+ public String getSchemeName() {
+ return "digest";
+ }
+
+ /**
+ * Returns false. Digest authentication scheme is request based.
+ *
+ * @return false.
+ */
+ public boolean isConnectionBased() {
+ return false;
+ }
+
+ public void overrideParamter(final String name, final String value) {
+ getParameters().put(name, value);
+ }
+
+ /**
+ * @deprecated (4.2) Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, org.apache.http.protocol.HttpContext)}
+ */
+ @Deprecated
+ public Header authenticate(
+ final Credentials credentials, final HttpRequest request) throws AuthenticationException {
+ return authenticate(credentials, request, new BasicHttpContext());
+ }
+
+ /**
+ * Produces a digest authorization string for the given set of
+ * {@link Credentials}, method name and URI.
+ *
+ * @param credentials A set of credentials to be used for athentication
+ * @param request The request being authenticated
+ *
+ * @throws org.apache.http.auth.InvalidCredentialsException if authentication credentials
+ * are not valid or not applicable for this authentication scheme
+ * @throws AuthenticationException if authorization string cannot
+ * be generated due to an authentication failure
+ *
+ * @return a digest authorization string
+ */
+ @Override
+ public Header authenticate(
+ final Credentials credentials,
+ final HttpRequest request,
+ final HttpContext context) throws AuthenticationException {
+
+ if (credentials == null) {
+ throw new IllegalArgumentException("Credentials may not be null");
+ }
+ if (request == null) {
+ throw new IllegalArgumentException("HTTP request may not be null");
+ }
+ if (getParameter("realm") == null) {
+ throw new AuthenticationException("missing realm in challenge");
+ }
+ if (getParameter("nonce") == null) {
+ throw new AuthenticationException("missing nonce in challenge");
+ }
+ // Add method name and request-URI to the parameter map
+ getParameters().put("methodname", request.getRequestLine().getMethod());
+ getParameters().put("uri", request.getRequestLine().getUri());
+ String charset = getParameter("charset");
+ if (charset == null) {
+ charset = AuthParams.getCredentialCharset(request.getParams());
+ getParameters().put("charset", charset);
+ }
+ return createDigestHeader(credentials, request);
+ }
+
+ private static MessageDigest createMessageDigest(
+ final String digAlg) throws UnsupportedDigestAlgorithmException {
+ try {
+ return MessageDigest.getInstance(digAlg);
+ } catch (Exception e) {
+ throw new UnsupportedDigestAlgorithmException(
+ "Unsupported algorithm in HTTP Digest authentication: "
+ + digAlg);
+ }
+ }
+
+ /**
+ * Creates digest-response header as defined in RFC2617.
+ *
+ * @param credentials User credentials
+ *
+ * @return The digest-response as String.
+ */
+ private Header createDigestHeader(
+ final Credentials credentials,
+ final HttpRequest request) throws AuthenticationException {
+ String uri = getParameter("uri");
+ String realm = getParameter("realm");
+ String nonce = getParameter("nonce");
+ String opaque = getParameter("opaque");
+ String method = getParameter("methodname");
+ String algorithm = getParameter("algorithm");
+
+ SetString
according to RFC 2617.
+ *
+ * @param binaryData array containing the digest
+ * @return encoded MD5, or null
if encoding failed
+ */
+ static String encode(byte[] binaryData) {
+ int n = binaryData.length;
+ char[] buffer = new char[n * 2];
+ for (int i = 0; i < n; i++) {
+ int low = (binaryData[i] & 0x0f);
+ int high = ((binaryData[i] & 0xf0) >> 4);
+ buffer[i * 2] = HEXADECIMAL[high];
+ buffer[(i * 2) + 1] = HEXADECIMAL[low];
+ }
+
+ return new String(buffer);
+ }
+
+
+ /**
+ * Creates a random cnonce value based on the current time.
+ *
+ * @return The cnonce value as String.
+ */
+ public static String createCnonce() {
+ SecureRandom rnd = new SecureRandom();
+ byte[] tmp = new byte[8];
+ rnd.nextBytes(tmp);
+ return encode(tmp);
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/auth/DigestSchemeFactory.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/auth/DigestSchemeFactory.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/auth/DigestSchemeFactory.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,49 @@
+/*
+ * ====================================================================
+ * 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
+ * null
.
+ *
+ * @return null
+ */
+ public String getParameter(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Parameter name may not be null");
+ }
+ return null;
+ }
+
+ /**
+ * The concept of an authentication realm is not supported by the Negotiate
+ * authentication scheme. Always returns null
.
+ *
+ * @return null
+ */
+ public String getRealm() {
+ return null;
+ }
+
+ /**
+ * Returns true. KERBEROS authentication scheme is connection based.
+ *
+ * @return true.
+ */
+ public boolean isConnectionBased() {
+ return true;
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/auth/KerberosSchemeFactory.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/auth/KerberosSchemeFactory.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/auth/KerberosSchemeFactory.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,61 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * null
.
+ * @param workstation Optional Windows workstation name. Can be
+ * null
.
+ * @return Type1 message
+ * @throws NTLMEngineException
+ */
+ String generateType1Msg(
+ String domain,
+ String workstation) throws NTLMEngineException;
+
+ /**
+ * Generates a Type3 message given the user credentials and the
+ * authentication challenge.
+ *
+ * @param username Windows user name
+ * @param password Password
+ * @param domain Windows domain name
+ * @param workstation Windows workstation name
+ * @param challenge Type2 challenge.
+ * @return Type3 response.
+ * @throws NTLMEngineException
+ */
+ String generateType3Msg(
+ String username,
+ String password,
+ String domain,
+ String workstation,
+ String challenge) throws NTLMEngineException;
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/auth/NTLMEngineException.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/auth/NTLMEngineException.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/auth/NTLMEngineException.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,68 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * Negotiate
+ */
+ public String getSchemeName() {
+ return "Negotiate";
+ }
+
+ public Header authenticate(
+ final Credentials credentials,
+ final HttpRequest request) throws AuthenticationException {
+ return authenticate(credentials, request, null);
+ }
+
+ /**
+ * Produces Negotiate authorization Header based on token created by
+ * processChallenge.
+ *
+ * @param credentials Never used be the Negotiate scheme but must be provided to
+ * satisfy common-httpclient API. Credentials from JAAS will be used instead.
+ * @param request The request being authenticated
+ *
+ * @throws AuthenticationException if authorisation string cannot
+ * be generated due to an authentication failure
+ *
+ * @return an Negotiate authorisation Header
+ */
+ @Override
+ public Header authenticate(
+ final Credentials credentials,
+ final HttpRequest request,
+ final HttpContext context) throws AuthenticationException {
+ return super.authenticate(credentials, request, context);
+ }
+
+ @Override
+ protected byte[] generateToken(final byte[] input, final String authServer) throws GSSException {
+ /* Using the SPNEGO OID is the correct method.
+ * Kerberos v5 works for IIS but not JBoss. Unwrapping
+ * the initial token when using SPNEGO OID looks like what is
+ * described here...
+ *
+ * http://msdn.microsoft.com/en-us/library/ms995330.aspx
+ *
+ * Another helpful URL...
+ *
+ * http://publib.boulder.ibm.com/infocenter/wasinfo/v7r0/index.jsp?topic=/com.ibm.websphere.express.doc/info/exp/ae/tsec_SPNEGO_token.html
+ *
+ * Unfortunately SPNEGO is JRE >=1.6.
+ */
+
+ /** Try SPNEGO by default, fall back to Kerberos later if error */
+ Oid negotiationOid = new Oid(SPNEGO_OID);
+
+ byte[] token = input;
+ boolean tryKerberos = false;
+ try {
+ token = generateGSSToken(token, negotiationOid, authServer);
+ } catch (GSSException ex){
+ // BAD MECH means we are likely to be using 1.5, fall back to Kerberos MECH.
+ // Rethrow any other exception.
+ if (ex.getMajor() == GSSException.BAD_MECH ){
+ log.debug("GSSException BAD_MECH, retry with Kerberos MECH");
+ tryKerberos = true;
+ } else {
+ throw ex;
+ }
+
+ }
+ if (tryKerberos){
+ /* Kerberos v5 GSS-API mechanism defined in RFC 1964.*/
+ log.debug("Using Kerberos MECH " + KERBEROS_OID);
+ negotiationOid = new Oid(KERBEROS_OID);
+ token = generateGSSToken(token, negotiationOid, authServer);
+
+ /*
+ * IIS accepts Kerberos and SPNEGO tokens. Some other servers Jboss, Glassfish?
+ * seem to only accept SPNEGO. Below wraps Kerberos into SPNEGO token.
+ */
+ if (token != null && spengoGenerator != null) {
+ try {
+ token = spengoGenerator.generateSpnegoDERObject(token);
+ } catch (IOException ex) {
+ log.error(ex.getMessage(), ex);
+ }
+ }
+ }
+ return token;
+ }
+
+ /**
+ * Returns the authentication parameter with the given name, if available.
+ *
+ * null
.
+ *
+ * @return null
+ */
+ public String getRealm() {
+ return null;
+ }
+
+ /**
+ * Returns true.
+ * Negotiate authentication scheme is connection based.
+ *
+ * @return true.
+ */
+ public boolean isConnectionBased() {
+ return true;
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/auth/NegotiateSchemeFactory.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/auth/NegotiateSchemeFactory.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/auth/NegotiateSchemeFactory.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,73 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * null
.
+ *
+ * @return null
+ */
+ public String getParameter(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException("Parameter name may not be null");
+ }
+ return null;
+ }
+
+ /**
+ * The concept of an authentication realm is not supported by the Negotiate
+ * authentication scheme. Always returns null
.
+ *
+ * @return null
+ */
+ public String getRealm() {
+ return null;
+ }
+
+ /**
+ * Returns true. SPNEGO authentication scheme is connection based.
+ *
+ * @return true.
+ */
+ public boolean isConnectionBased() {
+ return true;
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/auth/SPNegoSchemeFactory.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/auth/SPNegoSchemeFactory.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/auth/SPNegoSchemeFactory.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,62 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * AIMDBackoffManager
applies an additive increase,
+ * multiplicative decrease (AIMD) to managing a dynamic limit to
+ * the number of connections allowed to a given host. You may want
+ * to experiment with the settings for the cooldown periods and the
+ * backoff factor to get the adaptive behavior you want.AIMDBackoffManager
to manage
+ * per-host connection pool sizes represented by the
+ * given {@link ConnPoolControl}.
+ * @param connPerRoute per-host routing maximums to
+ * be managed
+ */
+ public AIMDBackoffManager(ConnPoolControlMath.floor
is applied in the
+ * case of non-integer outcomes to ensure we actually
+ * decrease the pool size. Pool sizes are never decreased
+ * below 1, however. Defaults to 0.5.
+ * @param d must be between 0.0 and 1.0, exclusive.
+ */
+ public void setBackoffFactor(double d) {
+ if (d <= 0.0 || d >= 1.0) {
+ throw new IllegalArgumentException("backoffFactor must be 0.0 < f < 1.0");
+ }
+ backoffFactor = d;
+ }
+
+ /**
+ * Sets the amount of time, in milliseconds, to wait between
+ * adjustments in pool sizes for a given host, to allow
+ * enough time for the adjustments to take effect. Defaults
+ * to 5000L (5 seconds).
+ * @param l must be positive
+ */
+ public void setCooldownMillis(long l) {
+ if (coolDown <= 0) {
+ throw new IllegalArgumentException("cooldownMillis must be positive");
+ }
+ coolDown = l;
+ }
+
+ /**
+ * Sets the absolute maximum per-host connection pool size to
+ * probe up to; defaults to 2 (the default per-host max).
+ * @param cap must be >= 1
+ */
+ public void setPerHostConnectionCap(int cap) {
+ if (cap < 1) {
+ throw new IllegalArgumentException("perHostConnectionCap must be >= 1");
+ }
+ this.cap = cap;
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/client/AbstractAuthenticationHandler.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/client/AbstractAuthenticationHandler.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/client/AbstractAuthenticationHandler.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,192 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ *
+ * null
to use a default context
+ */
+ public final HttpResponse execute(HttpUriRequest request,
+ HttpContext context)
+ throws IOException, ClientProtocolException {
+
+ if (request == null) {
+ throw new IllegalArgumentException
+ ("Request must not be null.");
+ }
+
+ return execute(determineTarget(request), request, context);
+ }
+
+ private static HttpHost determineTarget(HttpUriRequest request) throws ClientProtocolException {
+ // A null target may be acceptable if there is a default target.
+ // Otherwise, the null target is detected in the director.
+ HttpHost target = null;
+
+ URI requestURI = request.getURI();
+ if (requestURI.isAbsolute()) {
+ target = URIUtils.extractHost(requestURI);
+ if (target == null) {
+ throw new ClientProtocolException(
+ "URI does not specify a valid host name: " + requestURI);
+ }
+ }
+ return target;
+ }
+
+ public final HttpResponse execute(HttpHost target, HttpRequest request)
+ throws IOException, ClientProtocolException {
+
+ return execute(target, request, (HttpContext) null);
+ }
+
+ public final HttpResponse execute(HttpHost target, HttpRequest request,
+ HttpContext context)
+ throws IOException, ClientProtocolException {
+
+ if (request == null) {
+ throw new IllegalArgumentException
+ ("Request must not be null.");
+ }
+ // a null target may be acceptable, this depends on the route planner
+ // a null context is acceptable, default context created below
+
+ HttpContext execContext = null;
+ RequestDirector director = null;
+ HttpRoutePlanner routePlanner = null;
+ ConnectionBackoffStrategy connectionBackoffStrategy = null;
+ BackoffManager backoffManager = null;
+
+ // Initialize the request execution context making copies of
+ // all shared objects that are potentially threading unsafe.
+ synchronized (this) {
+
+ HttpContext defaultContext = createHttpContext();
+ if (context == null) {
+ execContext = defaultContext;
+ } else {
+ execContext = new DefaultedHttpContext(context, defaultContext);
+ }
+ // Create a director for this request
+ director = createClientRequestDirector(
+ getRequestExecutor(),
+ getConnectionManager(),
+ getConnectionReuseStrategy(),
+ getConnectionKeepAliveStrategy(),
+ getRoutePlanner(),
+ getProtocolProcessor(),
+ getHttpRequestRetryHandler(),
+ getRedirectStrategy(),
+ getTargetAuthenticationStrategy(),
+ getProxyAuthenticationStrategy(),
+ getUserTokenHandler(),
+ determineParams(request));
+ routePlanner = getRoutePlanner();
+ connectionBackoffStrategy = getConnectionBackoffStrategy();
+ backoffManager = getBackoffManager();
+ }
+
+ try {
+ if (connectionBackoffStrategy != null && backoffManager != null) {
+ HttpHost targetForRoute = (target != null) ? target
+ : (HttpHost) determineParams(request).getParameter(
+ ClientPNames.DEFAULT_HOST);
+ HttpRoute route = routePlanner.determineRoute(targetForRoute, request, execContext);
+
+ HttpResponse out;
+ try {
+ out = director.execute(target, request, execContext);
+ } catch (RuntimeException re) {
+ if (connectionBackoffStrategy.shouldBackoff(re)) {
+ backoffManager.backOff(route);
+ }
+ throw re;
+ } catch (Exception e) {
+ if (connectionBackoffStrategy.shouldBackoff(e)) {
+ backoffManager.backOff(route);
+ }
+ if (e instanceof HttpException) throw (HttpException)e;
+ if (e instanceof IOException) throw (IOException)e;
+ throw new UndeclaredThrowableException(e);
+ }
+ if (connectionBackoffStrategy.shouldBackoff(out)) {
+ backoffManager.backOff(route);
+ } else {
+ backoffManager.probe(route);
+ }
+ return out;
+ } else {
+ return director.execute(target, request, execContext);
+ }
+ } catch(HttpException httpException) {
+ throw new ClientProtocolException(httpException);
+ }
+ }
+
+ /**
+ * @deprecated (4.1) do not use
+ */
+ @Deprecated
+ protected RequestDirector createClientRequestDirector(
+ final HttpRequestExecutor requestExec,
+ final ClientConnectionManager conman,
+ final ConnectionReuseStrategy reustrat,
+ final ConnectionKeepAliveStrategy kastrat,
+ final HttpRoutePlanner rouplan,
+ final HttpProcessor httpProcessor,
+ final HttpRequestRetryHandler retryHandler,
+ final RedirectHandler redirectHandler,
+ final AuthenticationHandler targetAuthHandler,
+ final AuthenticationHandler proxyAuthHandler,
+ final UserTokenHandler userTokenHandler,
+ final HttpParams params) {
+ return new DefaultRequestDirector(
+ requestExec,
+ conman,
+ reustrat,
+ kastrat,
+ rouplan,
+ httpProcessor,
+ retryHandler,
+ redirectHandler,
+ targetAuthHandler,
+ proxyAuthHandler,
+ userTokenHandler,
+ params);
+ }
+
+ /**
+ * @deprecated (4.2) do not use
+ */
+ @Deprecated
+ protected RequestDirector createClientRequestDirector(
+ final HttpRequestExecutor requestExec,
+ final ClientConnectionManager conman,
+ final ConnectionReuseStrategy reustrat,
+ final ConnectionKeepAliveStrategy kastrat,
+ final HttpRoutePlanner rouplan,
+ final HttpProcessor httpProcessor,
+ final HttpRequestRetryHandler retryHandler,
+ final RedirectStrategy redirectStrategy,
+ final AuthenticationHandler targetAuthHandler,
+ final AuthenticationHandler proxyAuthHandler,
+ final UserTokenHandler userTokenHandler,
+ final HttpParams params) {
+ return new DefaultRequestDirector(
+ log,
+ requestExec,
+ conman,
+ reustrat,
+ kastrat,
+ rouplan,
+ httpProcessor,
+ retryHandler,
+ redirectStrategy,
+ targetAuthHandler,
+ proxyAuthHandler,
+ userTokenHandler,
+ params);
+ }
+
+
+ /**
+ * @since 4.2
+ */
+ protected RequestDirector createClientRequestDirector(
+ final HttpRequestExecutor requestExec,
+ final ClientConnectionManager conman,
+ final ConnectionReuseStrategy reustrat,
+ final ConnectionKeepAliveStrategy kastrat,
+ final HttpRoutePlanner rouplan,
+ final HttpProcessor httpProcessor,
+ final HttpRequestRetryHandler retryHandler,
+ final RedirectStrategy redirectStrategy,
+ final AuthenticationStrategy targetAuthStrategy,
+ final AuthenticationStrategy proxyAuthStrategy,
+ final UserTokenHandler userTokenHandler,
+ final HttpParams params) {
+ return new DefaultRequestDirector(
+ log,
+ requestExec,
+ conman,
+ reustrat,
+ kastrat,
+ rouplan,
+ httpProcessor,
+ retryHandler,
+ redirectStrategy,
+ targetAuthStrategy,
+ proxyAuthStrategy,
+ userTokenHandler,
+ params);
+ }
+
+ /**
+ * Obtains parameters for executing a request.
+ * The default implementation in this class creates a new
+ * {@link ClientParamsStack} from the request parameters
+ * and the client parameters.
+ *
+ * This method is called by the default implementation of
+ * {@link #execute(HttpHost,HttpRequest,HttpContext)}
+ * to obtain the parameters for the
+ * {@link DefaultRequestDirector}.
+ *
+ * @param req the request that will be executed
+ *
+ * @return the parameters to use
+ */
+ protected HttpParams determineParams(HttpRequest req) {
+ return new ClientParamsStack
+ (null, getParams(), req.getParams(), null);
+ }
+
+ public
+ *
+ * Each stack entry may be null
. That is preferable over
+ * an empty params collection, since it avoids searching the empty collection
+ * when looking up parameters.
+ *
+ *
+ *
+ * @since 4.0
+ */
+@NotThreadSafe
+public class ClientParamsStack extends AbstractHttpParams {
+
+ /** The application parameter collection, or null
. */
+ protected final HttpParams applicationParams;
+
+ /** The client parameter collection, or null
. */
+ protected final HttpParams clientParams;
+
+ /** The request parameter collection, or null
. */
+ protected final HttpParams requestParams;
+
+ /** The override parameter collection, or null
. */
+ protected final HttpParams overrideParams;
+
+
+ /**
+ * Creates a new parameter stack from elements.
+ * The arguments will be stored as-is, there is no copying to
+ * prevent modification.
+ *
+ * @param aparams application parameters, or null
+ * @param cparams client parameters, or null
+ * @param rparams request parameters, or null
+ * @param oparams override parameters, or null
+ */
+ public ClientParamsStack(HttpParams aparams, HttpParams cparams,
+ HttpParams rparams, HttpParams oparams) {
+ applicationParams = aparams;
+ clientParams = cparams;
+ requestParams = rparams;
+ overrideParams = oparams;
+ }
+
+
+ /**
+ * Creates a copy of a parameter stack.
+ * The new stack will have the exact same entries as the argument stack.
+ * There is no copying of parameters.
+ *
+ * @param stack the stack to copy
+ */
+ public ClientParamsStack(ClientParamsStack stack) {
+ this(stack.getApplicationParams(),
+ stack.getClientParams(),
+ stack.getRequestParams(),
+ stack.getOverrideParams());
+ }
+
+
+ /**
+ * Creates a modified copy of a parameter stack.
+ * The new stack will contain the explicitly passed elements.
+ * For elements where the explicit argument is null
,
+ * the corresponding element from the argument stack is used.
+ * There is no copying of parameters.
+ *
+ * @param stack the stack to modify
+ * @param aparams application parameters, or null
+ * @param cparams client parameters, or null
+ * @param rparams request parameters, or null
+ * @param oparams override parameters, or null
+ */
+ public ClientParamsStack(ClientParamsStack stack,
+ HttpParams aparams, HttpParams cparams,
+ HttpParams rparams, HttpParams oparams) {
+ this((aparams != null) ? aparams : stack.getApplicationParams(),
+ (cparams != null) ? cparams : stack.getClientParams(),
+ (rparams != null) ? rparams : stack.getRequestParams(),
+ (oparams != null) ? oparams : stack.getOverrideParams());
+ }
+
+
+ /**
+ * Obtains the application parameters of this stack.
+ *
+ * @return the application parameters, or null
+ */
+ public final HttpParams getApplicationParams() {
+ return applicationParams;
+ }
+
+ /**
+ * Obtains the client parameters of this stack.
+ *
+ * @return the client parameters, or null
+ */
+ public final HttpParams getClientParams() {
+ return clientParams;
+ }
+
+ /**
+ * Obtains the request parameters of this stack.
+ *
+ * @return the request parameters, or null
+ */
+ public final HttpParams getRequestParams() {
+ return requestParams;
+ }
+
+ /**
+ * Obtains the override parameters of this stack.
+ *
+ * @return the override parameters, or null
+ */
+ public final HttpParams getOverrideParams() {
+ return overrideParams;
+ }
+
+
+ /**
+ * Obtains a parameter from this stack.
+ * See class comment for search order.
+ *
+ * @param name the name of the parameter to obtain
+ *
+ * @return the highest-priority value for that parameter, or
+ * null
if it is not set anywhere in this stack
+ */
+ public Object getParameter(String name) {
+ if (name == null) {
+ throw new IllegalArgumentException
+ ("Parameter name must not be null.");
+ }
+
+ Object result = null;
+
+ if (overrideParams != null) {
+ result = overrideParams.getParameter(name);
+ }
+ if ((result == null) && (requestParams != null)) {
+ result = requestParams.getParameter(name);
+ }
+ if ((result == null) && (clientParams != null)) {
+ result = clientParams.getParameter(name);
+ }
+ if ((result == null) && (applicationParams != null)) {
+ result = applicationParams.getParameter(name);
+ }
+ return result;
+ }
+
+ /**
+ * Does not set a parameter.
+ * Parameter stacks are read-only. It is possible, though discouraged,
+ * to access and modify specific stack entries.
+ * Derived classes may change this behavior.
+ *
+ * @param name ignored
+ * @param value ignored
+ *
+ * @return nothing
+ *
+ * @throws UnsupportedOperationException always
+ */
+ public HttpParams setParameter(String name, Object value)
+ throws UnsupportedOperationException {
+
+ throw new UnsupportedOperationException
+ ("Setting parameters in a stack is not supported.");
+ }
+
+
+ /**
+ * Does not remove a parameter.
+ * Parameter stacks are read-only. It is possible, though discouraged,
+ * to access and modify specific stack entries.
+ * Derived classes may change this behavior.
+ *
+ * @param name ignored
+ *
+ * @return nothing
+ *
+ * @throws UnsupportedOperationException always
+ */
+ public boolean removeParameter(String name) {
+ throw new UnsupportedOperationException
+ ("Removing parameters in a stack is not supported.");
+ }
+
+
+ /**
+ * Does not copy parameters.
+ * Parameter stacks are lightweight objects, expected to be instantiated
+ * as needed and to be used only in a very specific context. On top of
+ * that, they are read-only. The typical copy operation to prevent
+ * accidental modification of parameters passed by the application to
+ * a framework object is therefore pointless and disabled.
+ * Create a new stack if you really need a copy.
+ *
+ * Derived classes may change this behavior.
+ *
+ * @return this
parameter stack
+ */
+ public HttpParams copy() {
+ return this;
+ }
+
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/client/Clock.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/client/Clock.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/client/Clock.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,42 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * Accept-Encoding
header on requests to indicate
+ * support for the gzip
and deflate
+ * compression schemes; it then checks the Content-Encoding
+ * header on the response to uncompress any compressed response bodies.
+ * The {@link java.io.InputStream} of the entity will contain the uncompressed
+ * content.Content-Length
header will
+ * correspond to the compressed entity length received from the server,
+ * but the content length experienced by reading the response body may
+ * be different (hopefully higher!).CachingHttpClient
in that the two decorators can be added
+ * in either order and still have cacheable responses be cached.
+ * DefaultHttpClient httpclient = new DefaultHttpClient();
+ * httpclient.addRequestInterceptor(new RequestAcceptEncoding());
+ * httpclient.addResponseInterceptor(new ResponseContentEncoding());
+ *
+ *
+ *
+ *
+ *
+ *
+ * @since 4.0
+ */
+@ThreadSafe
+public class DefaultHttpClient extends AbstractHttpClient {
+
+ /**
+ * Creates a new HTTP client from parameters and a connection manager.
+ *
+ * @param params the parameters
+ * @param conman the connection manager
+ */
+ public DefaultHttpClient(
+ final ClientConnectionManager conman,
+ final HttpParams params) {
+ super(conman, params);
+ }
+
+
+ /**
+ * @since 4.1
+ */
+ public DefaultHttpClient(
+ final ClientConnectionManager conman) {
+ super(conman, null);
+ }
+
+
+ public DefaultHttpClient(final HttpParams params) {
+ super(null, params);
+ }
+
+
+ public DefaultHttpClient() {
+ super(null, null);
+ }
+
+
+ /**
+ * Creates the default set of HttpParams by invoking {@link DefaultHttpClient#setDefaultHttpParams(HttpParams)}
+ *
+ * @return a new instance of {@link SyncBasicHttpParams} with the defaults applied to it.
+ */
+ @Override
+ protected HttpParams createHttpParams() {
+ HttpParams params = new SyncBasicHttpParams();
+ setDefaultHttpParams(params);
+ return params;
+ }
+
+ /**
+ * Saves the default set of HttpParams in the provided parameter.
+ * These are:
+ *
+ *
+ */
+ public static void setDefaultHttpParams(HttpParams params) {
+ HttpProtocolParams.setVersion(params, HttpVersion.HTTP_1_1);
+ HttpProtocolParams.setContentCharset(params, HTTP.DEF_CONTENT_CHARSET.name());
+ HttpConnectionParams.setTcpNoDelay(params, true);
+ HttpConnectionParams.setSocketBufferSize(params, 8192);
+
+ // determine the release version from packaged version info
+ final VersionInfo vi = VersionInfo.loadVersionInfo
+ ("org.apache.http.client", DefaultHttpClient.class.getClassLoader());
+ final String release = (vi != null) ?
+ vi.getRelease() : VersionInfo.UNAVAILABLE;
+ HttpProtocolParams.setUserAgent(params,
+ "Apache-HttpClient/" + release + " (java 1.5)");
+ }
+
+ /**
+ * Create the processor with the following interceptors:
+ *
+ *
+ * retryCount
and requestSentRetryEnabled
to determine
+ * if the given method should be retried.
+ */
+ public boolean retryRequest(
+ final IOException exception,
+ int executionCount,
+ final HttpContext context) {
+ if (exception == null) {
+ throw new IllegalArgumentException("Exception parameter may not be null");
+ }
+ if (context == null) {
+ throw new IllegalArgumentException("HTTP context may not be null");
+ }
+ if (executionCount > this.retryCount) {
+ // Do not retry if over max retry count
+ return false;
+ }
+ if (exception instanceof InterruptedIOException) {
+ // Timeout
+ return false;
+ }
+ if (exception instanceof UnknownHostException) {
+ // Unknown host
+ return false;
+ }
+ if (exception instanceof ConnectException) {
+ // Connection refused
+ return false;
+ }
+ if (exception instanceof SSLException) {
+ // SSL handshake exception
+ return false;
+ }
+
+ HttpRequest request = (HttpRequest)
+ context.getAttribute(ExecutionContext.HTTP_REQUEST);
+
+ if(requestIsAborted(request)){
+ return false;
+ }
+
+ if (handleAsIdempotent(request)) {
+ // Retry if the request is considered idempotent
+ return true;
+ }
+
+ Boolean b = (Boolean)
+ context.getAttribute(ExecutionContext.HTTP_REQ_SENT);
+ boolean sent = (b != null && b.booleanValue());
+
+ if (!sent || this.requestSentRetryEnabled) {
+ // Retry if the request has not been sent fully or
+ // if it's OK to retry methods that have been sent
+ return true;
+ }
+ // otherwise do not retry
+ return false;
+ }
+
+ /**
+ * @return true
if this handler will retry methods that have
+ * successfully sent their request, false
otherwise
+ */
+ public boolean isRequestSentRetryEnabled() {
+ return requestSentRetryEnabled;
+ }
+
+ /**
+ * @return the maximum number of times a method will be retried
+ */
+ public int getRetryCount() {
+ return retryCount;
+ }
+
+ /**
+ * @since 4.2
+ */
+ protected boolean handleAsIdempotent(final HttpRequest request) {
+ return !(request instanceof HttpEntityEnclosingRequest);
+ }
+
+ /**
+ * @since 4.2
+ */
+ protected boolean requestIsAborted(final HttpRequest request) {
+ HttpRequest req = request;
+ if (request instanceof RequestWrapper) { // does not forward request to original
+ req = ((RequestWrapper) request).getOriginal();
+ }
+ return (req instanceof HttpUriRequest && ((HttpUriRequest)req).isAborted());
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/client/DefaultProxyAuthenticationHandler.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,94 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ *
+ *
+ * @since 4.0
+ */
+@SuppressWarnings("deprecation")
+@NotThreadSafe // e.g. managedConn
+public class DefaultRequestDirector implements RequestDirector {
+
+ private final Log log;
+
+ /** The connection manager. */
+ protected final ClientConnectionManager connManager;
+
+ /** The route planner. */
+ protected final HttpRoutePlanner routePlanner;
+
+ /** The connection re-use strategy. */
+ protected final ConnectionReuseStrategy reuseStrategy;
+
+ /** The keep-alive duration strategy. */
+ protected final ConnectionKeepAliveStrategy keepAliveStrategy;
+
+ /** The request executor. */
+ protected final HttpRequestExecutor requestExec;
+
+ /** The HTTP protocol processor. */
+ protected final HttpProcessor httpProcessor;
+
+ /** The request retry handler. */
+ protected final HttpRequestRetryHandler retryHandler;
+
+ /** The redirect handler. */
+ @Deprecated
+ protected final RedirectHandler redirectHandler;
+
+ /** The redirect strategy. */
+ protected final RedirectStrategy redirectStrategy;
+
+ /** The target authentication handler. */
+ @Deprecated
+ protected final AuthenticationHandler targetAuthHandler;
+
+ /** The target authentication handler. */
+ protected final AuthenticationStrategy targetAuthStrategy;
+
+ /** The proxy authentication handler. */
+ @Deprecated
+ protected final AuthenticationHandler proxyAuthHandler;
+
+ /** The proxy authentication handler. */
+ protected final AuthenticationStrategy proxyAuthStrategy;
+
+ /** The user token handler. */
+ protected final UserTokenHandler userTokenHandler;
+
+ /** The HTTP parameters. */
+ protected final HttpParams params;
+
+ /** The currently allocated connection. */
+ protected ManagedClientConnection managedConn;
+
+ protected final AuthState targetAuthState;
+
+ protected final AuthState proxyAuthState;
+
+ private final HttpAuthenticator authenticator;
+
+ private int execCount;
+
+ private int redirectCount;
+
+ private int maxRedirects;
+
+ private HttpHost virtualHost;
+
+ @Deprecated
+ public DefaultRequestDirector(
+ final HttpRequestExecutor requestExec,
+ final ClientConnectionManager conman,
+ final ConnectionReuseStrategy reustrat,
+ final ConnectionKeepAliveStrategy kastrat,
+ final HttpRoutePlanner rouplan,
+ final HttpProcessor httpProcessor,
+ final HttpRequestRetryHandler retryHandler,
+ final RedirectHandler redirectHandler,
+ final AuthenticationHandler targetAuthHandler,
+ final AuthenticationHandler proxyAuthHandler,
+ final UserTokenHandler userTokenHandler,
+ final HttpParams params) {
+ this(LogFactory.getLog(DefaultRequestDirector.class),
+ requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
+ new DefaultRedirectStrategyAdaptor(redirectHandler),
+ new AuthenticationStrategyAdaptor(targetAuthHandler),
+ new AuthenticationStrategyAdaptor(proxyAuthHandler),
+ userTokenHandler,
+ params);
+ }
+
+
+ @Deprecated
+ public DefaultRequestDirector(
+ final Log log,
+ final HttpRequestExecutor requestExec,
+ final ClientConnectionManager conman,
+ final ConnectionReuseStrategy reustrat,
+ final ConnectionKeepAliveStrategy kastrat,
+ final HttpRoutePlanner rouplan,
+ final HttpProcessor httpProcessor,
+ final HttpRequestRetryHandler retryHandler,
+ final RedirectStrategy redirectStrategy,
+ final AuthenticationHandler targetAuthHandler,
+ final AuthenticationHandler proxyAuthHandler,
+ final UserTokenHandler userTokenHandler,
+ final HttpParams params) {
+ this(LogFactory.getLog(DefaultRequestDirector.class),
+ requestExec, conman, reustrat, kastrat, rouplan, httpProcessor, retryHandler,
+ redirectStrategy,
+ new AuthenticationStrategyAdaptor(targetAuthHandler),
+ new AuthenticationStrategyAdaptor(proxyAuthHandler),
+ userTokenHandler,
+ params);
+ }
+
+ /**
+ * @since 4.2
+ */
+ public DefaultRequestDirector(
+ final Log log,
+ final HttpRequestExecutor requestExec,
+ final ClientConnectionManager conman,
+ final ConnectionReuseStrategy reustrat,
+ final ConnectionKeepAliveStrategy kastrat,
+ final HttpRoutePlanner rouplan,
+ final HttpProcessor httpProcessor,
+ final HttpRequestRetryHandler retryHandler,
+ final RedirectStrategy redirectStrategy,
+ final AuthenticationStrategy targetAuthStrategy,
+ final AuthenticationStrategy proxyAuthStrategy,
+ final UserTokenHandler userTokenHandler,
+ final HttpParams params) {
+
+ if (log == null) {
+ throw new IllegalArgumentException
+ ("Log may not be null.");
+ }
+ if (requestExec == null) {
+ throw new IllegalArgumentException
+ ("Request executor may not be null.");
+ }
+ if (conman == null) {
+ throw new IllegalArgumentException
+ ("Client connection manager may not be null.");
+ }
+ if (reustrat == null) {
+ throw new IllegalArgumentException
+ ("Connection reuse strategy may not be null.");
+ }
+ if (kastrat == null) {
+ throw new IllegalArgumentException
+ ("Connection keep alive strategy may not be null.");
+ }
+ if (rouplan == null) {
+ throw new IllegalArgumentException
+ ("Route planner may not be null.");
+ }
+ if (httpProcessor == null) {
+ throw new IllegalArgumentException
+ ("HTTP protocol processor may not be null.");
+ }
+ if (retryHandler == null) {
+ throw new IllegalArgumentException
+ ("HTTP request retry handler may not be null.");
+ }
+ if (redirectStrategy == null) {
+ throw new IllegalArgumentException
+ ("Redirect strategy may not be null.");
+ }
+ if (targetAuthStrategy == null) {
+ throw new IllegalArgumentException
+ ("Target authentication strategy may not be null.");
+ }
+ if (proxyAuthStrategy == null) {
+ throw new IllegalArgumentException
+ ("Proxy authentication strategy may not be null.");
+ }
+ if (userTokenHandler == null) {
+ throw new IllegalArgumentException
+ ("User token handler may not be null.");
+ }
+ if (params == null) {
+ throw new IllegalArgumentException
+ ("HTTP parameters may not be null");
+ }
+ this.log = log;
+ this.authenticator = new HttpAuthenticator(log);
+ this.requestExec = requestExec;
+ this.connManager = conman;
+ this.reuseStrategy = reustrat;
+ this.keepAliveStrategy = kastrat;
+ this.routePlanner = rouplan;
+ this.httpProcessor = httpProcessor;
+ this.retryHandler = retryHandler;
+ this.redirectStrategy = redirectStrategy;
+ this.targetAuthStrategy = targetAuthStrategy;
+ this.proxyAuthStrategy = proxyAuthStrategy;
+ this.userTokenHandler = userTokenHandler;
+ this.params = params;
+
+ if (redirectStrategy instanceof DefaultRedirectStrategyAdaptor) {
+ this.redirectHandler = ((DefaultRedirectStrategyAdaptor) redirectStrategy).getHandler();
+ } else {
+ this.redirectHandler = null;
+ }
+ if (targetAuthStrategy instanceof AuthenticationStrategyAdaptor) {
+ this.targetAuthHandler = ((AuthenticationStrategyAdaptor) targetAuthStrategy).getHandler();
+ } else {
+ this.targetAuthHandler = null;
+ }
+ if (proxyAuthStrategy instanceof AuthenticationStrategyAdaptor) {
+ this.proxyAuthHandler = ((AuthenticationStrategyAdaptor) proxyAuthStrategy).getHandler();
+ } else {
+ this.proxyAuthHandler = null;
+ }
+
+ this.managedConn = null;
+
+ this.execCount = 0;
+ this.redirectCount = 0;
+ this.targetAuthState = new AuthState();
+ this.proxyAuthState = new AuthState();
+ this.maxRedirects = this.params.getIntParameter(ClientPNames.MAX_REDIRECTS, 100);
+ }
+
+
+ private RequestWrapper wrapRequest(
+ final HttpRequest request) throws ProtocolException {
+ if (request instanceof HttpEntityEnclosingRequest) {
+ return new EntityEnclosingRequestWrapper(
+ (HttpEntityEnclosingRequest) request);
+ } else {
+ return new RequestWrapper(
+ request);
+ }
+ }
+
+
+ protected void rewriteRequestURI(
+ final RequestWrapper request,
+ final HttpRoute route) throws ProtocolException {
+ try {
+
+ URI uri = request.getURI();
+ if (route.getProxyHost() != null && !route.isTunnelled()) {
+ // Make sure the request URI is absolute
+ if (!uri.isAbsolute()) {
+ HttpHost target = route.getTargetHost();
+ uri = URIUtils.rewriteURI(uri, target, true);
+ } else {
+ uri = URIUtils.rewriteURI(uri);
+ }
+ } else {
+ // Make sure the request URI is relative
+ if (uri.isAbsolute()) {
+ uri = URIUtils.rewriteURI(uri, null);
+ } else {
+ uri = URIUtils.rewriteURI(uri);
+ }
+ }
+ request.setURI(uri);
+
+ } catch (URISyntaxException ex) {
+ throw new ProtocolException("Invalid URI: " +
+ request.getRequestLine().getUri(), ex);
+ }
+ }
+
+
+ // non-javadoc, see interface ClientRequestDirector
+ public HttpResponse execute(HttpHost target, HttpRequest request,
+ HttpContext context)
+ throws HttpException, IOException {
+
+ context.setAttribute(ClientContext.TARGET_AUTH_STATE, targetAuthState);
+ context.setAttribute(ClientContext.PROXY_AUTH_STATE, proxyAuthState);
+
+ HttpRequest orig = request;
+ RequestWrapper origWrapper = wrapRequest(orig);
+ origWrapper.setParams(params);
+ HttpRoute origRoute = determineRoute(target, origWrapper, context);
+
+ virtualHost = (HttpHost) origWrapper.getParams().getParameter(ClientPNames.VIRTUAL_HOST);
+
+ // HTTPCLIENT-1092 - add the port if necessary
+ if (virtualHost != null && virtualHost.getPort() == -1) {
+ int port = target.getPort();
+ if (port != -1){
+ virtualHost = new HttpHost(virtualHost.getHostName(), port, virtualHost.getSchemeName());
+ }
+ }
+
+ RoutedRequest roureq = new RoutedRequest(origWrapper, origRoute);
+
+ boolean reuse = false;
+ boolean done = false;
+ try {
+ HttpResponse response = null;
+ while (!done) {
+ // In this loop, the RoutedRequest may be replaced by a
+ // followup request and route. The request and route passed
+ // in the method arguments will be replaced. The original
+ // request is still available in 'orig'.
+
+ RequestWrapper wrapper = roureq.getRequest();
+ HttpRoute route = roureq.getRoute();
+ response = null;
+
+ // See if we have a user token bound to the execution context
+ Object userToken = context.getAttribute(ClientContext.USER_TOKEN);
+
+ // Allocate connection if needed
+ if (managedConn == null) {
+ ClientConnectionRequest connRequest = connManager.requestConnection(
+ route, userToken);
+ if (orig instanceof AbortableHttpRequest) {
+ ((AbortableHttpRequest) orig).setConnectionRequest(connRequest);
+ }
+
+ long timeout = HttpClientParams.getConnectionManagerTimeout(params);
+ try {
+ managedConn = connRequest.getConnection(timeout, TimeUnit.MILLISECONDS);
+ } catch(InterruptedException interrupted) {
+ InterruptedIOException iox = new InterruptedIOException();
+ iox.initCause(interrupted);
+ throw iox;
+ }
+
+ if (HttpConnectionParams.isStaleCheckingEnabled(params)) {
+ // validate connection
+ if (managedConn.isOpen()) {
+ this.log.debug("Stale connection check");
+ if (managedConn.isStale()) {
+ this.log.debug("Stale connection detected");
+ managedConn.close();
+ }
+ }
+ }
+ }
+
+ if (orig instanceof AbortableHttpRequest) {
+ ((AbortableHttpRequest) orig).setReleaseTrigger(managedConn);
+ }
+
+ try {
+ tryConnect(roureq, context);
+ } catch (TunnelRefusedException ex) {
+ if (this.log.isDebugEnabled()) {
+ this.log.debug(ex.getMessage());
+ }
+ response = ex.getResponse();
+ break;
+ }
+
+ String userinfo = wrapper.getURI().getUserInfo();
+ if (userinfo != null) {
+ targetAuthState.update(
+ new BasicScheme(), new UsernamePasswordCredentials(userinfo));
+ }
+
+ // Reset headers on the request wrapper
+ wrapper.resetHeaders();
+
+ // Re-write request URI if needed
+ rewriteRequestURI(wrapper, route);
+
+ // Use virtual host if set
+ target = virtualHost;
+
+ if (target == null) {
+ target = route.getTargetHost();
+ }
+
+ HttpHost proxy = route.getProxyHost();
+
+ // Populate the execution context
+ context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
+ context.setAttribute(ExecutionContext.HTTP_PROXY_HOST, proxy);
+ context.setAttribute(ExecutionContext.HTTP_CONNECTION, managedConn);
+
+ // Run request protocol interceptors
+ requestExec.preProcess(wrapper, httpProcessor, context);
+
+ response = tryExecute(roureq, context);
+ if (response == null) {
+ // Need to start over
+ continue;
+ }
+
+ // Run response protocol interceptors
+ response.setParams(params);
+ requestExec.postProcess(response, httpProcessor, context);
+
+
+ // The connection is in or can be brought to a re-usable state.
+ reuse = reuseStrategy.keepAlive(response, context);
+ if (reuse) {
+ // Set the idle duration of this connection
+ long duration = keepAliveStrategy.getKeepAliveDuration(response, context);
+ if (this.log.isDebugEnabled()) {
+ String s;
+ if (duration > 0) {
+ s = "for " + duration + " " + TimeUnit.MILLISECONDS;
+ } else {
+ s = "indefinitely";
+ }
+ this.log.debug("Connection can be kept alive " + s);
+ }
+ managedConn.setIdleDuration(duration, TimeUnit.MILLISECONDS);
+ }
+
+ RoutedRequest followup = handleResponse(roureq, response, context);
+ if (followup == null) {
+ done = true;
+ } else {
+ if (reuse) {
+ // Make sure the response body is fully consumed, if present
+ HttpEntity entity = response.getEntity();
+ EntityUtils.consume(entity);
+ // entity consumed above is not an auto-release entity,
+ // need to mark the connection re-usable explicitly
+ managedConn.markReusable();
+ } else {
+ managedConn.close();
+ if (proxyAuthState.getState() == AuthProtocolState.SUCCESS
+ && proxyAuthState.getAuthScheme() != null
+ && proxyAuthState.getAuthScheme().isConnectionBased()) {
+ this.log.debug("Resetting proxy auth state");
+ proxyAuthState.reset();
+ }
+ if (targetAuthState.getState() == AuthProtocolState.SUCCESS
+ && targetAuthState.getAuthScheme() != null
+ && targetAuthState.getAuthScheme().isConnectionBased()) {
+ this.log.debug("Resetting target auth state");
+ targetAuthState.reset();
+ }
+ }
+ // check if we can use the same connection for the followup
+ if (!followup.getRoute().equals(roureq.getRoute())) {
+ releaseConnection();
+ }
+ roureq = followup;
+ }
+
+ if (managedConn != null) {
+ if (userToken == null) {
+ userToken = userTokenHandler.getUserToken(context);
+ context.setAttribute(ClientContext.USER_TOKEN, userToken);
+ }
+ if (userToken != null) {
+ managedConn.setState(userToken);
+ }
+ }
+
+ } // while not done
+
+
+ // check for entity, release connection if possible
+ if ((response == null) || (response.getEntity() == null) ||
+ !response.getEntity().isStreaming()) {
+ // connection not needed and (assumed to be) in re-usable state
+ if (reuse)
+ managedConn.markReusable();
+ releaseConnection();
+ } else {
+ // install an auto-release entity
+ HttpEntity entity = response.getEntity();
+ entity = new BasicManagedEntity(entity, managedConn, reuse);
+ response.setEntity(entity);
+ }
+
+ return response;
+
+ } catch (ConnectionShutdownException ex) {
+ InterruptedIOException ioex = new InterruptedIOException(
+ "Connection has been shut down");
+ ioex.initCause(ex);
+ throw ioex;
+ } catch (HttpException ex) {
+ abortConnection();
+ throw ex;
+ } catch (IOException ex) {
+ abortConnection();
+ throw ex;
+ } catch (RuntimeException ex) {
+ abortConnection();
+ throw ex;
+ }
+ } // execute
+
+ /**
+ * Establish connection either directly or through a tunnel and retry in case of
+ * a recoverable I/O failure
+ */
+ private void tryConnect(
+ final RoutedRequest req, final HttpContext context) throws HttpException, IOException {
+ HttpRoute route = req.getRoute();
+ HttpRequest wrapper = req.getRequest();
+
+ int connectCount = 0;
+ for (;;) {
+ context.setAttribute(ExecutionContext.HTTP_REQUEST, wrapper);
+ // Increment connect count
+ connectCount++;
+ try {
+ if (!managedConn.isOpen()) {
+ managedConn.open(route, context, params);
+ } else {
+ managedConn.setSocketTimeout(HttpConnectionParams.getSoTimeout(params));
+ }
+ establishRoute(route, context);
+ break;
+ } catch (IOException ex) {
+ try {
+ managedConn.close();
+ } catch (IOException ignore) {
+ }
+ if (retryHandler.retryRequest(ex, connectCount, context)) {
+ if (this.log.isInfoEnabled()) {
+ this.log.info("I/O exception ("+ ex.getClass().getName() +
+ ") caught when connecting to the target host: "
+ + ex.getMessage());
+ if (this.log.isDebugEnabled()) {
+ this.log.debug(ex.getMessage(), ex);
+ }
+ this.log.info("Retrying connect");
+ }
+ } else {
+ throw ex;
+ }
+ }
+ }
+ }
+
+ /**
+ * Execute request and retry in case of a recoverable I/O failure
+ */
+ private HttpResponse tryExecute(
+ final RoutedRequest req, final HttpContext context) throws HttpException, IOException {
+ RequestWrapper wrapper = req.getRequest();
+ HttpRoute route = req.getRoute();
+ HttpResponse response = null;
+
+ Exception retryReason = null;
+ for (;;) {
+ // Increment total exec count (with redirects)
+ execCount++;
+ // Increment exec count for this particular request
+ wrapper.incrementExecCount();
+ if (!wrapper.isRepeatable()) {
+ this.log.debug("Cannot retry non-repeatable request");
+ if (retryReason != null) {
+ throw new NonRepeatableRequestException("Cannot retry request " +
+ "with a non-repeatable request entity. The cause lists the " +
+ "reason the original request failed.", retryReason);
+ } else {
+ throw new NonRepeatableRequestException("Cannot retry request " +
+ "with a non-repeatable request entity.");
+ }
+ }
+
+ try {
+ if (!managedConn.isOpen()) {
+ // If we have a direct route to the target host
+ // just re-open connection and re-try the request
+ if (!route.isTunnelled()) {
+ this.log.debug("Reopening the direct connection.");
+ managedConn.open(route, context, params);
+ } else {
+ // otherwise give up
+ this.log.debug("Proxied connection. Need to start over.");
+ break;
+ }
+ }
+
+ if (this.log.isDebugEnabled()) {
+ this.log.debug("Attempt " + execCount + " to execute request");
+ }
+ response = requestExec.execute(wrapper, managedConn, context);
+ break;
+
+ } catch (IOException ex) {
+ this.log.debug("Closing the connection.");
+ try {
+ managedConn.close();
+ } catch (IOException ignore) {
+ }
+ if (retryHandler.retryRequest(ex, wrapper.getExecCount(), context)) {
+ if (this.log.isInfoEnabled()) {
+ this.log.info("I/O exception ("+ ex.getClass().getName() +
+ ") caught when processing request: "
+ + ex.getMessage());
+ }
+ if (this.log.isDebugEnabled()) {
+ this.log.debug(ex.getMessage(), ex);
+ }
+ this.log.info("Retrying request");
+ retryReason = ex;
+ } else {
+ throw ex;
+ }
+ }
+ }
+ return response;
+ }
+
+ /**
+ * Returns the connection back to the connection manager
+ * and prepares for retrieving a new connection during
+ * the next request.
+ */
+ protected void releaseConnection() {
+ // Release the connection through the ManagedConnection instead of the
+ // ConnectionManager directly. This lets the connection control how
+ // it is released.
+ try {
+ managedConn.releaseConnection();
+ } catch(IOException ignored) {
+ this.log.debug("IOException releasing connection", ignored);
+ }
+ managedConn = null;
+ }
+
+ /**
+ * Determines the route for a request.
+ * Called by {@link #execute}
+ * to determine the route for either the original or a followup request.
+ *
+ * @param target the target host for the request.
+ * Implementations may accept null
+ * if they can still determine a route, for example
+ * to a default target or by inspecting the request.
+ * @param request the request to execute
+ * @param context the context to use for the execution,
+ * never null
+ *
+ * @return the route the request should take
+ *
+ * @throws HttpException in case of a problem
+ */
+ protected HttpRoute determineRoute(HttpHost target,
+ HttpRequest request,
+ HttpContext context)
+ throws HttpException {
+
+ if (target == null) {
+ target = (HttpHost) request.getParams().getParameter(
+ ClientPNames.DEFAULT_HOST);
+ }
+ if (target == null) {
+ throw new IllegalStateException
+ ("Target host must not be null, or set in parameters.");
+ }
+
+ return this.routePlanner.determineRoute(target, request, context);
+ }
+
+
+ /**
+ * Establishes the target route.
+ *
+ * @param route the route to establish
+ * @param context the context for the request execution
+ *
+ * @throws HttpException in case of a problem
+ * @throws IOException in case of an IO problem
+ */
+ protected void establishRoute(HttpRoute route, HttpContext context)
+ throws HttpException, IOException {
+
+ HttpRouteDirector rowdy = new BasicRouteDirector();
+ int step;
+ do {
+ HttpRoute fact = managedConn.getRoute();
+ step = rowdy.nextStep(route, fact);
+
+ switch (step) {
+
+ case HttpRouteDirector.CONNECT_TARGET:
+ case HttpRouteDirector.CONNECT_PROXY:
+ managedConn.open(route, context, this.params);
+ break;
+
+ case HttpRouteDirector.TUNNEL_TARGET: {
+ boolean secure = createTunnelToTarget(route, context);
+ this.log.debug("Tunnel to target created.");
+ managedConn.tunnelTarget(secure, this.params);
+ } break;
+
+ case HttpRouteDirector.TUNNEL_PROXY: {
+ // The most simple example for this case is a proxy chain
+ // of two proxies, where P1 must be tunnelled to P2.
+ // route: Source -> P1 -> P2 -> Target (3 hops)
+ // fact: Source -> P1 -> Target (2 hops)
+ final int hop = fact.getHopCount()-1; // the hop to establish
+ boolean secure = createTunnelToProxy(route, hop, context);
+ this.log.debug("Tunnel to proxy created.");
+ managedConn.tunnelProxy(route.getHopTarget(hop),
+ secure, this.params);
+ } break;
+
+
+ case HttpRouteDirector.LAYER_PROTOCOL:
+ managedConn.layerProtocol(context, this.params);
+ break;
+
+ case HttpRouteDirector.UNREACHABLE:
+ throw new HttpException("Unable to establish route: " +
+ "planned = " + route + "; current = " + fact);
+ case HttpRouteDirector.COMPLETE:
+ // do nothing
+ break;
+ default:
+ throw new IllegalStateException("Unknown step indicator "
+ + step + " from RouteDirector.");
+ }
+
+ } while (step > HttpRouteDirector.COMPLETE);
+
+ } // establishConnection
+
+
+ /**
+ * Creates a tunnel to the target server.
+ * The connection must be established to the (last) proxy.
+ * A CONNECT request for tunnelling through the proxy will
+ * be created and sent, the response received and checked.
+ * This method does not update the connection with
+ * information about the tunnel, that is left to the caller.
+ *
+ * @param route the route to establish
+ * @param context the context for request execution
+ *
+ * @return true
if the tunnelled route is secure,
+ * false
otherwise.
+ * The implementation here always returns false
,
+ * but derived classes may override.
+ *
+ * @throws HttpException in case of a problem
+ * @throws IOException in case of an IO problem
+ */
+ protected boolean createTunnelToTarget(HttpRoute route,
+ HttpContext context)
+ throws HttpException, IOException {
+
+ HttpHost proxy = route.getProxyHost();
+ HttpHost target = route.getTargetHost();
+ HttpResponse response = null;
+
+ for (;;) {
+ if (!this.managedConn.isOpen()) {
+ this.managedConn.open(route, context, this.params);
+ }
+
+ HttpRequest connect = createConnectRequest(route, context);
+ connect.setParams(this.params);
+
+ // Populate the execution context
+ context.setAttribute(ExecutionContext.HTTP_TARGET_HOST, target);
+ context.setAttribute(ExecutionContext.HTTP_PROXY_HOST, proxy);
+ context.setAttribute(ExecutionContext.HTTP_CONNECTION, managedConn);
+ context.setAttribute(ExecutionContext.HTTP_REQUEST, connect);
+
+ this.requestExec.preProcess(connect, this.httpProcessor, context);
+
+ response = this.requestExec.execute(connect, this.managedConn, context);
+
+ response.setParams(this.params);
+ this.requestExec.postProcess(response, this.httpProcessor, context);
+
+ int status = response.getStatusLine().getStatusCode();
+ if (status < 200) {
+ throw new HttpException("Unexpected response to CONNECT request: " +
+ response.getStatusLine());
+ }
+
+ if (HttpClientParams.isAuthenticating(this.params)) {
+ if (this.authenticator.isAuthenticationRequested(proxy, response,
+ this.proxyAuthStrategy, this.proxyAuthState, context)) {
+ if (this.authenticator.authenticate(proxy, response,
+ this.proxyAuthStrategy, this.proxyAuthState, context)) {
+ // Retry request
+ if (this.reuseStrategy.keepAlive(response, context)) {
+ this.log.debug("Connection kept alive");
+ // Consume response content
+ HttpEntity entity = response.getEntity();
+ EntityUtils.consume(entity);
+ } else {
+ this.managedConn.close();
+ }
+ } else {
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ }
+
+ int status = response.getStatusLine().getStatusCode();
+
+ if (status > 299) {
+
+ // Buffer response content
+ HttpEntity entity = response.getEntity();
+ if (entity != null) {
+ response.setEntity(new BufferedHttpEntity(entity));
+ }
+
+ this.managedConn.close();
+ throw new TunnelRefusedException("CONNECT refused by proxy: " +
+ response.getStatusLine(), response);
+ }
+
+ this.managedConn.markReusable();
+
+ // How to decide on security of the tunnelled connection?
+ // The socket factory knows only about the segment to the proxy.
+ // Even if that is secure, the hop to the target may be insecure.
+ // Leave it to derived classes, consider insecure by default here.
+ return false;
+
+ } // createTunnelToTarget
+
+
+
+ /**
+ * Creates a tunnel to an intermediate proxy.
+ * This method is not implemented in this class.
+ * It just throws an exception here.
+ *
+ * @param route the route to establish
+ * @param hop the hop in the route to establish now.
+ * route.getHopTarget(hop)
+ * will return the proxy to tunnel to.
+ * @param context the context for request execution
+ *
+ * @return true
if the partially tunnelled connection
+ * is secure, false
otherwise.
+ *
+ * @throws HttpException in case of a problem
+ * @throws IOException in case of an IO problem
+ */
+ protected boolean createTunnelToProxy(HttpRoute route, int hop,
+ HttpContext context)
+ throws HttpException, IOException {
+
+ // Have a look at createTunnelToTarget and replicate the parts
+ // you need in a custom derived class. If your proxies don't require
+ // authentication, it is not too hard. But for the stock version of
+ // HttpClient, we cannot make such simplifying assumptions and would
+ // have to include proxy authentication code. The HttpComponents team
+ // is currently not in a position to support rarely used code of this
+ // complexity. Feel free to submit patches that refactor the code in
+ // createTunnelToTarget to facilitate re-use for proxy tunnelling.
+
+ throw new HttpException("Proxy chains are not supported.");
+ }
+
+
+
+ /**
+ * Creates the CONNECT request for tunnelling.
+ * Called by {@link #createTunnelToTarget createTunnelToTarget}.
+ *
+ * @param route the route to establish
+ * @param context the context for request execution
+ *
+ * @return the CONNECT request for tunnelling
+ */
+ protected HttpRequest createConnectRequest(HttpRoute route,
+ HttpContext context) {
+ // see RFC 2817, section 5.2 and
+ // INTERNET-DRAFT: Tunneling TCP based protocols through
+ // Web proxy servers
+
+ HttpHost target = route.getTargetHost();
+
+ String host = target.getHostName();
+ int port = target.getPort();
+ if (port < 0) {
+ Scheme scheme = connManager.getSchemeRegistry().
+ getScheme(target.getSchemeName());
+ port = scheme.getDefaultPort();
+ }
+
+ StringBuilder buffer = new StringBuilder(host.length() + 6);
+ buffer.append(host);
+ buffer.append(':');
+ buffer.append(Integer.toString(port));
+
+ String authority = buffer.toString();
+ ProtocolVersion ver = HttpProtocolParams.getVersion(params);
+ HttpRequest req = new BasicHttpRequest
+ ("CONNECT", authority, ver);
+
+ return req;
+ }
+
+
+ /**
+ * Analyzes a response to check need for a followup.
+ *
+ * @param roureq the request and route.
+ * @param response the response to analayze
+ * @param context the context used for the current request execution
+ *
+ * @return the followup request and route if there is a followup, or
+ * null
if the response should be returned as is
+ *
+ * @throws HttpException in case of a problem
+ * @throws IOException in case of an IO problem
+ */
+ protected RoutedRequest handleResponse(RoutedRequest roureq,
+ HttpResponse response,
+ HttpContext context)
+ throws HttpException, IOException {
+
+ HttpRoute route = roureq.getRoute();
+ RequestWrapper request = roureq.getRequest();
+
+ HttpParams params = request.getParams();
+ if (HttpClientParams.isRedirecting(params) &&
+ this.redirectStrategy.isRedirected(request, response, context)) {
+
+ if (redirectCount >= maxRedirects) {
+ throw new RedirectException("Maximum redirects ("
+ + maxRedirects + ") exceeded");
+ }
+ redirectCount++;
+
+ // Virtual host cannot be used any longer
+ virtualHost = null;
+
+ HttpUriRequest redirect = redirectStrategy.getRedirect(request, response, context);
+ HttpRequest orig = request.getOriginal();
+ redirect.setHeaders(orig.getAllHeaders());
+
+ URI uri = redirect.getURI();
+ if (uri.getHost() == null) {
+ throw new ProtocolException("Redirect URI does not specify a valid host name: " + uri);
+ }
+
+ HttpHost newTarget = new HttpHost(
+ uri.getHost(),
+ uri.getPort(),
+ uri.getScheme());
+
+ // Reset auth states if redirecting to another host
+ if (!route.getTargetHost().equals(newTarget)) {
+ this.log.debug("Resetting target auth state");
+ targetAuthState.reset();
+ AuthScheme authScheme = proxyAuthState.getAuthScheme();
+ if (authScheme != null && authScheme.isConnectionBased()) {
+ this.log.debug("Resetting proxy auth state");
+ proxyAuthState.reset();
+ }
+ }
+
+ RequestWrapper wrapper = wrapRequest(redirect);
+ wrapper.setParams(params);
+
+ HttpRoute newRoute = determineRoute(newTarget, wrapper, context);
+ RoutedRequest newRequest = new RoutedRequest(wrapper, newRoute);
+
+ if (this.log.isDebugEnabled()) {
+ this.log.debug("Redirecting to '" + uri + "' via " + newRoute);
+ }
+
+ return newRequest;
+ }
+
+ if (HttpClientParams.isAuthenticating(params)) {
+ HttpHost target = (HttpHost) context.getAttribute(ExecutionContext.HTTP_TARGET_HOST);
+ if (target == null) {
+ target = route.getTargetHost();
+ }
+ if (target.getPort() < 0) {
+ Scheme scheme = connManager.getSchemeRegistry().getScheme(target);
+ target = new HttpHost(target.getHostName(), scheme.getDefaultPort(), target.getSchemeName());
+ }
+ if (this.authenticator.isAuthenticationRequested(target, response,
+ this.targetAuthStrategy, this.targetAuthState, context)) {
+ if (this.authenticator.authenticate(target, response,
+ this.targetAuthStrategy, this.targetAuthState, context)) {
+ // Re-try the same request via the same route
+ return roureq;
+ } else {
+ return null;
+ }
+ }
+
+ HttpHost proxy = route.getProxyHost();
+ if (this.authenticator.isAuthenticationRequested(proxy, response,
+ this.proxyAuthStrategy, this.proxyAuthState, context)) {
+ if (this.authenticator.authenticate(proxy, response,
+ this.proxyAuthStrategy, this.proxyAuthState, context)) {
+ // Re-try the same request via the same route
+ return roureq;
+ } else {
+ return null;
+ }
+ }
+ }
+ return null;
+ } // handleResponse
+
+
+ /**
+ * Shuts down the connection.
+ * This method is called from a catch
block in
+ * {@link #execute execute} during exception handling.
+ */
+ private void abortConnection() {
+ ManagedClientConnection mcc = managedConn;
+ if (mcc != null) {
+ // we got here as the result of an exception
+ // no response will be returned, release the connection
+ managedConn = null;
+ try {
+ mcc.abortConnection();
+ } catch (IOException ex) {
+ if (this.log.isDebugEnabled()) {
+ this.log.debug(ex.getMessage(), ex);
+ }
+ }
+ // ensure the connection manager properly releases this connection
+ try {
+ mcc.releaseConnection();
+ } catch(IOException ignored) {
+ this.log.debug("Error releasing connection", ignored);
+ }
+ }
+ } // abortConnection
+
+
+} // class DefaultClientRequestDirector
Index: 3rdParty_sources/httpclient/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,83 @@
+/*
+ * ====================================================================
+ * 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
+ * 503
(Service Unavailable) responses for a fixed number of times
+ * at a fixed interval.
+ *
+ * @since 4.2
+ */
+@Immutable
+public class DefaultServiceUnavailableRetryStrategy implements ServiceUnavailableRetryStrategy {
+
+ /**
+ * Maximum number of allowed retries if the server responds with a HTTP code
+ * in our retry code list. Default value is 1.
+ */
+ private final int maxRetries;
+
+ /**
+ * Retry interval between subsequent requests, in milliseconds. Default
+ * value is 1 second.
+ */
+ private final long retryInterval;
+
+ public DefaultServiceUnavailableRetryStrategy(int maxRetries, int retryInterval) {
+ super();
+ if (maxRetries < 1) {
+ throw new IllegalArgumentException("MaxRetries must be greater than 1");
+ }
+ if (retryInterval < 1) {
+ throw new IllegalArgumentException("Retry interval must be greater than 1");
+ }
+ this.maxRetries = maxRetries;
+ this.retryInterval = retryInterval;
+ }
+
+ public DefaultServiceUnavailableRetryStrategy() {
+ this(1, 1000);
+ }
+
+ public boolean retryRequest(final HttpResponse response, int executionCount, final HttpContext context) {
+ return executionCount <= maxRetries &&
+ response.getStatusLine().getStatusCode() == HttpStatus.SC_SERVICE_UNAVAILABLE;
+ }
+
+ public long getRetryInterval() {
+ return retryInterval;
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/client/DefaultTargetAuthenticationHandler.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,95 @@
+/*
+ * ====================================================================
+ * 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
+ * null
token will be returned.
+ *
+ * @since 4.0
+ */
+@Immutable
+public class DefaultUserTokenHandler implements UserTokenHandler {
+
+ public Object getUserToken(final HttpContext context) {
+
+ Principal userPrincipal = null;
+
+ AuthState targetAuthState = (AuthState) context.getAttribute(
+ ClientContext.TARGET_AUTH_STATE);
+ if (targetAuthState != null) {
+ userPrincipal = getAuthPrincipal(targetAuthState);
+ if (userPrincipal == null) {
+ AuthState proxyAuthState = (AuthState) context.getAttribute(
+ ClientContext.PROXY_AUTH_STATE);
+ userPrincipal = getAuthPrincipal(proxyAuthState);
+ }
+ }
+
+ if (userPrincipal == null) {
+ HttpRoutedConnection conn = (HttpRoutedConnection) context.getAttribute(
+ ExecutionContext.HTTP_CONNECTION);
+ if (conn.isOpen()) {
+ SSLSession sslsession = conn.getSSLSession();
+ if (sslsession != null) {
+ userPrincipal = sslsession.getLocalPrincipal();
+ }
+ }
+ }
+
+ return userPrincipal;
+ }
+
+ private static Principal getAuthPrincipal(final AuthState authState) {
+ AuthScheme scheme = authState.getAuthScheme();
+ if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
+ Credentials creds = authState.getCredentials();
+ if (creds != null) {
+ return creds.getUserPrincipal();
+ }
+ }
+ return null;
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/client/EntityEnclosingRequestWrapper.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,113 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ *
+ *
+ *
+ * null
+ * @param conn the connection to wrap, or null
+ */
+ protected AbstractClientConnAdapter(ClientConnectionManager mgr,
+ OperatedClientConnection conn) {
+ super();
+ connManager = mgr;
+ wrappedConnection = conn;
+ markedReusable = false;
+ released = false;
+ duration = Long.MAX_VALUE;
+ }
+
+ /**
+ * Detaches this adapter from the wrapped connection.
+ * This adapter becomes useless.
+ */
+ protected synchronized void detach() {
+ wrappedConnection = null;
+ duration = Long.MAX_VALUE;
+ }
+
+ protected OperatedClientConnection getWrappedConnection() {
+ return wrappedConnection;
+ }
+
+ protected ClientConnectionManager getManager() {
+ return connManager;
+ }
+
+ /**
+ * @deprecated (4.1) use {@link #assertValid(OperatedClientConnection)}
+ */
+ protected final void assertNotAborted() throws InterruptedIOException {
+ if (isReleased()) {
+ throw new InterruptedIOException("Connection has been shut down");
+ }
+ }
+
+ /**
+ * @since 4.1
+ * @return value of released flag
+ */
+ protected boolean isReleased() {
+ return released;
+ }
+
+ /**
+ * Asserts that there is a valid wrapped connection to delegate to.
+ *
+ * @throws ConnectionShutdownException if there is no wrapped connection
+ * or connection has been aborted
+ */
+ protected final void assertValid(
+ final OperatedClientConnection wrappedConn) throws ConnectionShutdownException {
+ if (isReleased() || wrappedConn == null) {
+ throw new ConnectionShutdownException();
+ }
+ }
+
+ public boolean isOpen() {
+ OperatedClientConnection conn = getWrappedConnection();
+ if (conn == null)
+ return false;
+
+ return conn.isOpen();
+ }
+
+ public boolean isStale() {
+ if (isReleased())
+ return true;
+ OperatedClientConnection conn = getWrappedConnection();
+ if (conn == null)
+ return true;
+
+ return conn.isStale();
+ }
+
+ public void setSocketTimeout(int timeout) {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ conn.setSocketTimeout(timeout);
+ }
+
+ public int getSocketTimeout() {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ return conn.getSocketTimeout();
+ }
+
+ public HttpConnectionMetrics getMetrics() {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ return conn.getMetrics();
+ }
+
+ public void flush() throws IOException {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ conn.flush();
+ }
+
+ public boolean isResponseAvailable(int timeout) throws IOException {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ return conn.isResponseAvailable(timeout);
+ }
+
+ public void receiveResponseEntity(HttpResponse response)
+ throws HttpException, IOException {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ unmarkReusable();
+ conn.receiveResponseEntity(response);
+ }
+
+ public HttpResponse receiveResponseHeader()
+ throws HttpException, IOException {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ unmarkReusable();
+ return conn.receiveResponseHeader();
+ }
+
+ public void sendRequestEntity(HttpEntityEnclosingRequest request)
+ throws HttpException, IOException {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ unmarkReusable();
+ conn.sendRequestEntity(request);
+ }
+
+ public void sendRequestHeader(HttpRequest request)
+ throws HttpException, IOException {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ unmarkReusable();
+ conn.sendRequestHeader(request);
+ }
+
+ public InetAddress getLocalAddress() {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ return conn.getLocalAddress();
+ }
+
+ public int getLocalPort() {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ return conn.getLocalPort();
+ }
+
+ public InetAddress getRemoteAddress() {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ return conn.getRemoteAddress();
+ }
+
+ public int getRemotePort() {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ return conn.getRemotePort();
+ }
+
+ public boolean isSecure() {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ return conn.isSecure();
+ }
+
+ public SSLSession getSSLSession() {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ if (!isOpen())
+ return null;
+
+ SSLSession result = null;
+ Socket sock = conn.getSocket();
+ if (sock instanceof SSLSocket) {
+ result = ((SSLSocket)sock).getSession();
+ }
+ return result;
+ }
+
+ public void markReusable() {
+ markedReusable = true;
+ }
+
+ public void unmarkReusable() {
+ markedReusable = false;
+ }
+
+ public boolean isMarkedReusable() {
+ return markedReusable;
+ }
+
+ public void setIdleDuration(long duration, TimeUnit unit) {
+ if(duration > 0) {
+ this.duration = unit.toMillis(duration);
+ } else {
+ this.duration = -1;
+ }
+ }
+
+ public synchronized void releaseConnection() {
+ if (released) {
+ return;
+ }
+ released = true;
+ connManager.releaseConnection(this, duration, TimeUnit.MILLISECONDS);
+ }
+
+ public synchronized void abortConnection() {
+ if (released) {
+ return;
+ }
+ released = true;
+ unmarkReusable();
+ try {
+ shutdown();
+ } catch (IOException ignore) {
+ }
+ connManager.releaseConnection(this, duration, TimeUnit.MILLISECONDS);
+ }
+
+ public Object getAttribute(final String id) {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ if (conn instanceof HttpContext) {
+ return ((HttpContext) conn).getAttribute(id);
+ } else {
+ return null;
+ }
+ }
+
+ public Object removeAttribute(final String id) {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ if (conn instanceof HttpContext) {
+ return ((HttpContext) conn).removeAttribute(id);
+ } else {
+ return null;
+ }
+ }
+
+ public void setAttribute(final String id, final Object obj) {
+ OperatedClientConnection conn = getWrappedConnection();
+ assertValid(conn);
+ if (conn instanceof HttpContext) {
+ ((HttpContext) conn).setAttribute(id, obj);
+ }
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/conn/AbstractPoolEntry.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/conn/AbstractPoolEntry.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/conn/AbstractPoolEntry.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,298 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * null
before tracking starts. */
+ protected volatile RouteTracker tracker;
+
+
+ /**
+ * Creates a new pool entry.
+ *
+ * @param connOperator the Connection Operator for this entry
+ * @param route the planned route for the connection,
+ * or null
+ */
+ protected AbstractPoolEntry(ClientConnectionOperator connOperator,
+ HttpRoute route) {
+ super();
+ if (connOperator == null) {
+ throw new IllegalArgumentException("Connection operator may not be null");
+ }
+ this.connOperator = connOperator;
+ this.connection = connOperator.createConnection();
+ this.route = route;
+ this.tracker = null;
+ }
+
+ /**
+ * Returns the state object associated with this pool entry.
+ *
+ * @return The state object
+ */
+ public Object getState() {
+ return state;
+ }
+
+ /**
+ * Assigns a state object to this pool entry.
+ *
+ * @param state The state object
+ */
+ public void setState(final Object state) {
+ this.state = state;
+ }
+
+ /**
+ * Opens the underlying connection.
+ *
+ * @param route the route along which to open the connection
+ * @param context the context for opening the connection
+ * @param params the parameters for opening the connection
+ *
+ * @throws IOException in case of a problem
+ */
+ public void open(HttpRoute route,
+ HttpContext context, HttpParams params)
+ throws IOException {
+
+ if (route == null) {
+ throw new IllegalArgumentException
+ ("Route must not be null.");
+ }
+ if (params == null) {
+ throw new IllegalArgumentException
+ ("Parameters must not be null.");
+ }
+ if ((this.tracker != null) && this.tracker.isConnected()) {
+ throw new IllegalStateException("Connection already open.");
+ }
+
+ // - collect the arguments
+ // - call the operator
+ // - update the tracking data
+ // In this order, we can be sure that only a successful
+ // opening of the connection will be tracked.
+
+ this.tracker = new RouteTracker(route);
+ final HttpHost proxy = route.getProxyHost();
+
+ connOperator.openConnection
+ (this.connection,
+ (proxy != null) ? proxy : route.getTargetHost(),
+ route.getLocalAddress(),
+ context, params);
+
+ RouteTracker localTracker = tracker; // capture volatile
+
+ // If this tracker was reset while connecting,
+ // fail early.
+ if (localTracker == null) {
+ throw new InterruptedIOException("Request aborted");
+ }
+
+ if (proxy == null) {
+ localTracker.connectTarget(this.connection.isSecure());
+ } else {
+ localTracker.connectProxy(proxy, this.connection.isSecure());
+ }
+
+ }
+
+ /**
+ * Tracks tunnelling of the connection to the target.
+ * The tunnel has to be established outside by sending a CONNECT
+ * request to the (last) proxy.
+ *
+ * @param secure true
if the tunnel should be
+ * considered secure, false
otherwise
+ * @param params the parameters for tunnelling the connection
+ *
+ * @throws IOException in case of a problem
+ */
+ public void tunnelTarget(boolean secure, HttpParams params)
+ throws IOException {
+
+ if (params == null) {
+ throw new IllegalArgumentException
+ ("Parameters must not be null.");
+ }
+
+ if ((this.tracker == null) || !this.tracker.isConnected()) {
+ throw new IllegalStateException("Connection not open.");
+ }
+ if (this.tracker.isTunnelled()) {
+ throw new IllegalStateException
+ ("Connection is already tunnelled.");
+ }
+
+ this.connection.update(null, tracker.getTargetHost(),
+ secure, params);
+ this.tracker.tunnelTarget(secure);
+ }
+
+ /**
+ * Tracks tunnelling of the connection to a chained proxy.
+ * The tunnel has to be established outside by sending a CONNECT
+ * request to the previous proxy.
+ *
+ * @param next the proxy to which the tunnel was established.
+ * See {@link org.apache.http.conn.ManagedClientConnection#tunnelProxy
+ * ManagedClientConnection.tunnelProxy}
+ * for details.
+ * @param secure true
if the tunnel should be
+ * considered secure, false
otherwise
+ * @param params the parameters for tunnelling the connection
+ *
+ * @throws IOException in case of a problem
+ */
+ public void tunnelProxy(HttpHost next, boolean secure, HttpParams params)
+ throws IOException {
+
+ if (next == null) {
+ throw new IllegalArgumentException
+ ("Next proxy must not be null.");
+ }
+ if (params == null) {
+ throw new IllegalArgumentException
+ ("Parameters must not be null.");
+ }
+
+ //@@@ check for proxy in planned route?
+ if ((this.tracker == null) || !this.tracker.isConnected()) {
+ throw new IllegalStateException("Connection not open.");
+ }
+
+ this.connection.update(null, next, secure, params);
+ this.tracker.tunnelProxy(next, secure);
+ }
+
+ /**
+ * Layers a protocol on top of an established tunnel.
+ *
+ * @param context the context for layering
+ * @param params the parameters for layering
+ *
+ * @throws IOException in case of a problem
+ */
+ public void layerProtocol(HttpContext context, HttpParams params)
+ throws IOException {
+
+ //@@@ is context allowed to be null? depends on operator?
+ if (params == null) {
+ throw new IllegalArgumentException
+ ("Parameters must not be null.");
+ }
+
+ if ((this.tracker == null) || !this.tracker.isConnected()) {
+ throw new IllegalStateException("Connection not open.");
+ }
+ if (!this.tracker.isTunnelled()) {
+ //@@@ allow this?
+ throw new IllegalStateException
+ ("Protocol layering without a tunnel not supported.");
+ }
+ if (this.tracker.isLayered()) {
+ throw new IllegalStateException
+ ("Multiple protocol layering not supported.");
+ }
+
+ // - collect the arguments
+ // - call the operator
+ // - update the tracking data
+ // In this order, we can be sure that only a successful
+ // layering on top of the connection will be tracked.
+
+ final HttpHost target = tracker.getTargetHost();
+
+ connOperator.updateSecureConnection(this.connection, target,
+ context, params);
+
+ this.tracker.layerProtocol(this.connection.isSecure());
+
+ }
+
+ /**
+ * Shuts down the entry.
+ *
+ * If {@link #open(HttpRoute, HttpContext, HttpParams)} is in progress,
+ * this will cause that open to possibly throw an {@link IOException}.
+ */
+ protected void shutdownEntry() {
+ tracker = null;
+ state = null;
+ }
+
+}
+
Index: 3rdParty_sources/httpclient/org/apache/http/impl/conn/AbstractPooledConnAdapter.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/conn/AbstractPooledConnAdapter.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/conn/AbstractPooledConnAdapter.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,183 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * null
if detached
+ *
+ * @deprecated (4.0.1)
+ */
+ protected AbstractPoolEntry getPoolEntry() {
+ return this.poolEntry;
+ }
+
+ /**
+ * Asserts that there is a valid pool entry.
+ *
+ * @throws ConnectionShutdownException if there is no pool entry
+ * or connection has been aborted
+ *
+ * @see #assertValid(OperatedClientConnection)
+ */
+ protected void assertValid(final AbstractPoolEntry entry) {
+ if (isReleased() || entry == null) {
+ throw new ConnectionShutdownException();
+ }
+ }
+
+ /**
+ * @deprecated (4.1) use {@link #assertValid(AbstractPoolEntry)}
+ */
+ protected final void assertAttached() {
+ if (poolEntry == null) {
+ throw new ConnectionShutdownException();
+ }
+ }
+
+ /**
+ * Detaches this adapter from the wrapped connection.
+ * This adapter becomes useless.
+ */
+ @Override
+ protected synchronized void detach() {
+ poolEntry = null;
+ super.detach();
+ }
+
+ public HttpRoute getRoute() {
+ AbstractPoolEntry entry = getPoolEntry();
+ assertValid(entry);
+ return (entry.tracker == null) ? null : entry.tracker.toRoute();
+ }
+
+ public void open(HttpRoute route,
+ HttpContext context, HttpParams params)
+ throws IOException {
+ AbstractPoolEntry entry = getPoolEntry();
+ assertValid(entry);
+ entry.open(route, context, params);
+ }
+
+ public void tunnelTarget(boolean secure, HttpParams params)
+ throws IOException {
+ AbstractPoolEntry entry = getPoolEntry();
+ assertValid(entry);
+ entry.tunnelTarget(secure, params);
+ }
+
+ public void tunnelProxy(HttpHost next, boolean secure, HttpParams params)
+ throws IOException {
+ AbstractPoolEntry entry = getPoolEntry();
+ assertValid(entry);
+ entry.tunnelProxy(next, secure, params);
+ }
+
+ public void layerProtocol(HttpContext context, HttpParams params)
+ throws IOException {
+ AbstractPoolEntry entry = getPoolEntry();
+ assertValid(entry);
+ entry.layerProtocol(context, params);
+ }
+
+ public void close() throws IOException {
+ AbstractPoolEntry entry = getPoolEntry();
+ if (entry != null)
+ entry.shutdownEntry();
+
+ OperatedClientConnection conn = getWrappedConnection();
+ if (conn != null) {
+ conn.close();
+ }
+ }
+
+ public void shutdown() throws IOException {
+ AbstractPoolEntry entry = getPoolEntry();
+ if (entry != null)
+ entry.shutdownEntry();
+
+ OperatedClientConnection conn = getWrappedConnection();
+ if (conn != null) {
+ conn.shutdown();
+ }
+ }
+
+ public Object getState() {
+ AbstractPoolEntry entry = getPoolEntry();
+ assertValid(entry);
+ return entry.getState();
+ }
+
+ public void setState(final Object state) {
+ AbstractPoolEntry entry = getPoolEntry();
+ assertValid(entry);
+ entry.setState(state);
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/conn/BasicClientConnectionManager.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/conn/BasicClientConnectionManager.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/conn/BasicClientConnectionManager.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,275 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ *
+ *
+ * @since 4.0
+ */
+@NotThreadSafe // connSecure, targetHost
+public class DefaultClientConnection extends SocketHttpClientConnection
+ implements OperatedClientConnection, HttpContext {
+
+ private final Log log = LogFactory.getLog(getClass());
+ private final Log headerLog = LogFactory.getLog("org.apache.http.headers");
+ private final Log wireLog = LogFactory.getLog("org.apache.http.wire");
+
+ /** The unconnected socket */
+ private volatile Socket socket;
+
+ /** The target host of this connection. */
+ private HttpHost targetHost;
+
+ /** Whether this connection is secure. */
+ private boolean connSecure;
+
+ /** True if this connection was shutdown. */
+ private volatile boolean shutdown;
+
+ /** connection specific attributes */
+ private final MapCONNECTION_TIMEOUT * n
where n
is the number of IP addresses
+ * of the given host. One can disable multihome support by overriding
+ * the {@link #resolveHostname(String)} method and returning only one IP address for the given
+ * host name.
+ *
+ *
+ *
+ * @since 4.0
+ */
+@ThreadSafe
+public class DefaultClientConnectionOperator implements ClientConnectionOperator {
+
+ private final Log log = LogFactory.getLog(getClass());
+
+ /** The scheme registry for looking up socket factories. */
+ protected final SchemeRegistry schemeRegistry; // @ThreadSafe
+
+ /** the custom-configured DNS lookup mechanism. */
+ protected final DnsResolver dnsResolver;
+
+ /**
+ * Creates a new client connection operator for the given scheme registry.
+ *
+ * @param schemes the scheme registry
+ *
+ * @since 4.2
+ */
+ public DefaultClientConnectionOperator(final SchemeRegistry schemes) {
+ if (schemes == null) {
+ throw new IllegalArgumentException("Scheme registry amy not be null");
+ }
+ this.schemeRegistry = schemes;
+ this.dnsResolver = new SystemDefaultDnsResolver();
+ }
+
+ /**
+ * Creates a new client connection operator for the given scheme registry
+ * and the given custom DNS lookup mechanism.
+ *
+ * @param schemes
+ * the scheme registry
+ * @param dnsResolver
+ * the custom DNS lookup mechanism
+ */
+ public DefaultClientConnectionOperator(final SchemeRegistry schemes,final DnsResolver dnsResolver) {
+ if (schemes == null) {
+ throw new IllegalArgumentException(
+ "Scheme registry may not be null");
+ }
+
+ if(dnsResolver == null){
+ throw new IllegalArgumentException("DNS resolver may not be null");
+ }
+
+ this.schemeRegistry = schemes;
+ this.dnsResolver = dnsResolver;
+ }
+
+ public OperatedClientConnection createConnection() {
+ return new DefaultClientConnection();
+ }
+
+ public void openConnection(
+ final OperatedClientConnection conn,
+ final HttpHost target,
+ final InetAddress local,
+ final HttpContext context,
+ final HttpParams params) throws IOException {
+ if (conn == null) {
+ throw new IllegalArgumentException("Connection may not be null");
+ }
+ if (target == null) {
+ throw new IllegalArgumentException("Target host may not be null");
+ }
+ if (params == null) {
+ throw new IllegalArgumentException("Parameters may not be null");
+ }
+ if (conn.isOpen()) {
+ throw new IllegalStateException("Connection must not be open");
+ }
+
+ Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
+ SchemeSocketFactory sf = schm.getSchemeSocketFactory();
+
+ InetAddress[] addresses = resolveHostname(target.getHostName());
+ int port = schm.resolvePort(target.getPort());
+ for (int i = 0; i < addresses.length; i++) {
+ InetAddress address = addresses[i];
+ boolean last = i == addresses.length - 1;
+
+ Socket sock = sf.createSocket(params);
+ conn.opening(sock, target);
+
+ InetSocketAddress remoteAddress = new HttpInetSocketAddress(target, address, port);
+ InetSocketAddress localAddress = null;
+ if (local != null) {
+ localAddress = new InetSocketAddress(local, 0);
+ }
+ if (this.log.isDebugEnabled()) {
+ this.log.debug("Connecting to " + remoteAddress);
+ }
+ try {
+ Socket connsock = sf.connectSocket(sock, remoteAddress, localAddress, params);
+ if (sock != connsock) {
+ sock = connsock;
+ conn.opening(sock, target);
+ }
+ prepareSocket(sock, context, params);
+ conn.openCompleted(sf.isSecure(sock), params);
+ return;
+ } catch (ConnectException ex) {
+ if (last) {
+ throw new HttpHostConnectException(target, ex);
+ }
+ } catch (ConnectTimeoutException ex) {
+ if (last) {
+ throw ex;
+ }
+ }
+ if (this.log.isDebugEnabled()) {
+ this.log.debug("Connect to " + remoteAddress + " timed out. " +
+ "Connection will be retried using another IP address");
+ }
+ }
+ }
+
+ public void updateSecureConnection(
+ final OperatedClientConnection conn,
+ final HttpHost target,
+ final HttpContext context,
+ final HttpParams params) throws IOException {
+ if (conn == null) {
+ throw new IllegalArgumentException("Connection may not be null");
+ }
+ if (target == null) {
+ throw new IllegalArgumentException("Target host may not be null");
+ }
+ if (params == null) {
+ throw new IllegalArgumentException("Parameters may not be null");
+ }
+ if (!conn.isOpen()) {
+ throw new IllegalStateException("Connection must be open");
+ }
+
+ final Scheme schm = schemeRegistry.getScheme(target.getSchemeName());
+ if (!(schm.getSchemeSocketFactory() instanceof SchemeLayeredSocketFactory)) {
+ throw new IllegalArgumentException
+ ("Target scheme (" + schm.getName() +
+ ") must have layered socket factory.");
+ }
+
+ SchemeLayeredSocketFactory lsf = (SchemeLayeredSocketFactory) schm.getSchemeSocketFactory();
+ Socket sock;
+ try {
+ sock = lsf.createLayeredSocket(
+ conn.getSocket(), target.getHostName(), target.getPort(), params);
+ } catch (ConnectException ex) {
+ throw new HttpHostConnectException(target, ex);
+ }
+ prepareSocket(sock, context, params);
+ conn.update(sock, target, lsf.isSecure(sock), params);
+ }
+
+ /**
+ * Performs standard initializations on a newly created socket.
+ *
+ * @param sock the socket to prepare
+ * @param context the context for the connection
+ * @param params the parameters from which to prepare the socket
+ *
+ * @throws IOException in case of an IO problem
+ */
+ protected void prepareSocket(
+ final Socket sock,
+ final HttpContext context,
+ final HttpParams params) throws IOException {
+ sock.setTcpNoDelay(HttpConnectionParams.getTcpNoDelay(params));
+ sock.setSoTimeout(HttpConnectionParams.getSoTimeout(params));
+
+ int linger = HttpConnectionParams.getLinger(params);
+ if (linger >= 0) {
+ sock.setSoLinger(linger > 0, linger);
+ }
+ }
+
+ /**
+ * Resolves the given host name to an array of corresponding IP addresses, based on the
+ * configured name service on the provided DNS resolver. If one wasn't provided, the system
+ * configuration is used.
+ *
+ * @param host host name to resolve
+ * @return array of IP addresses
+ * @exception UnknownHostException if no IP address for the host could be determined.
+ *
+ * @see DnsResolver
+ * @see SystemDefaultDnsResolver
+ *
+ * @since 4.1
+ */
+ protected InetAddress[] resolveHostname(final String host) throws UnknownHostException {
+ return dnsResolver.resolve(host);
+ }
+
+}
+
Index: 3rdParty_sources/httpclient/org/apache/http/impl/conn/DefaultHttpResponseParser.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/conn/DefaultHttpResponseParser.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/conn/DefaultHttpResponseParser.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,120 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ *
+ *
+ * @since 4.2
+ */
+@ThreadSafe // no public methods
+public class DefaultHttpResponseParser extends AbstractMessageParser
+ *
+ *
+ * @since 4.0
+ */
+@ThreadSafe
+public class DefaultHttpRoutePlanner implements HttpRoutePlanner {
+
+ /** The scheme registry. */
+ protected final SchemeRegistry schemeRegistry; // class is @ThreadSafe
+
+ /**
+ * Creates a new default route planner.
+ *
+ * @param schreg the scheme registry
+ */
+ public DefaultHttpRoutePlanner(SchemeRegistry schreg) {
+ if (schreg == null) {
+ throw new IllegalArgumentException
+ ("SchemeRegistry must not be null.");
+ }
+ schemeRegistry = schreg;
+ }
+
+ public HttpRoute determineRoute(HttpHost target,
+ HttpRequest request,
+ HttpContext context)
+ throws HttpException {
+
+ if (request == null) {
+ throw new IllegalStateException
+ ("Request must not be null.");
+ }
+
+ // If we have a forced route, we can do without a target.
+ HttpRoute route =
+ ConnRouteParams.getForcedRoute(request.getParams());
+ if (route != null)
+ return route;
+
+ // If we get here, there is no forced route.
+ // So we need a target to compute a route.
+
+ if (target == null) {
+ throw new IllegalStateException
+ ("Target host must not be null.");
+ }
+
+ final InetAddress local =
+ ConnRouteParams.getLocalAddress(request.getParams());
+ final HttpHost proxy =
+ ConnRouteParams.getDefaultProxy(request.getParams());
+
+ final Scheme schm;
+ try {
+ schm = schemeRegistry.getScheme(target.getSchemeName());
+ } catch (IllegalStateException ex) {
+ throw new HttpException(ex.getMessage());
+ }
+ // as it is typically used for TLS/SSL, we assume that
+ // a layered scheme implies a secure connection
+ final boolean secure = schm.isLayered();
+
+ if (proxy == null) {
+ route = new HttpRoute(target, local, secure);
+ } else {
+ route = new HttpRoute(target, local, proxy, secure);
+ }
+ return route;
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/conn/DefaultResponseParser.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/conn/DefaultResponseParser.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/conn/DefaultResponseParser.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,127 @@
+/*
+ * ====================================================================
+ * 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
+ *
+ *
+ *
+ * @since 4.0
+ *
+ * @deprecated (4.2) use {@link DefaultHttpResponseParser}
+ */
+@ThreadSafe // no public methods
+public class DefaultResponseParser extends AbstractMessageParserASCII
if null
+ */
+ public LoggingSessionInputBuffer(
+ final SessionInputBuffer in, final Wire wire, final String charset) {
+ super();
+ this.in = in;
+ this.eofSensor = in instanceof EofSensor ? (EofSensor) in : null;
+ this.wire = wire;
+ this.charset = charset != null ? charset : Consts.ASCII.name();
+ }
+
+ public LoggingSessionInputBuffer(final SessionInputBuffer in, final Wire wire) {
+ this(in, wire, null);
+ }
+
+ public boolean isDataAvailable(int timeout) throws IOException {
+ return this.in.isDataAvailable(timeout);
+ }
+
+ public int read(byte[] b, int off, int len) throws IOException {
+ int l = this.in.read(b, off, len);
+ if (this.wire.enabled() && l > 0) {
+ this.wire.input(b, off, l);
+ }
+ return l;
+ }
+
+ public int read() throws IOException {
+ int l = this.in.read();
+ if (this.wire.enabled() && l != -1) {
+ this.wire.input(l);
+ }
+ return l;
+ }
+
+ public int read(byte[] b) throws IOException {
+ int l = this.in.read(b);
+ if (this.wire.enabled() && l > 0) {
+ this.wire.input(b, 0, l);
+ }
+ return l;
+ }
+
+ public String readLine() throws IOException {
+ String s = this.in.readLine();
+ if (this.wire.enabled() && s != null) {
+ String tmp = s + "\r\n";
+ this.wire.input(tmp.getBytes(this.charset));
+ }
+ return s;
+ }
+
+ public int readLine(final CharArrayBuffer buffer) throws IOException {
+ int l = this.in.readLine(buffer);
+ if (this.wire.enabled() && l >= 0) {
+ int pos = buffer.length() - l;
+ String s = new String(buffer.buffer(), pos, l);
+ String tmp = s + "\r\n";
+ this.wire.input(tmp.getBytes(this.charset));
+ }
+ return l;
+ }
+
+ public HttpTransportMetrics getMetrics() {
+ return this.in.getMetrics();
+ }
+
+ public boolean isEof() {
+ if (this.eofSensor != null) {
+ return this.eofSensor.isEof();
+ } else {
+ return false;
+ }
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/conn/LoggingSessionOutputBuffer.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,119 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ * ASCII
if null
+ */
+ public LoggingSessionOutputBuffer(
+ final SessionOutputBuffer out, final Wire wire, final String charset) {
+ super();
+ this.out = out;
+ this.wire = wire;
+ this.charset = charset != null ? charset : Consts.ASCII.name();
+ }
+
+ public LoggingSessionOutputBuffer(final SessionOutputBuffer out, final Wire wire) {
+ this(out, wire, null);
+ }
+
+ public void write(byte[] b, int off, int len) throws IOException {
+ this.out.write(b, off, len);
+ if (this.wire.enabled()) {
+ this.wire.output(b, off, len);
+ }
+ }
+
+ public void write(int b) throws IOException {
+ this.out.write(b);
+ if (this.wire.enabled()) {
+ this.wire.output(b);
+ }
+ }
+
+ public void write(byte[] b) throws IOException {
+ this.out.write(b);
+ if (this.wire.enabled()) {
+ this.wire.output(b);
+ }
+ }
+
+ public void flush() throws IOException {
+ this.out.flush();
+ }
+
+ public void writeLine(final CharArrayBuffer buffer) throws IOException {
+ this.out.writeLine(buffer);
+ if (this.wire.enabled()) {
+ String s = new String(buffer.buffer(), 0, buffer.length());
+ String tmp = s + "\r\n";
+ this.wire.output(tmp.getBytes(this.charset));
+ }
+ }
+
+ public void writeLine(final String s) throws IOException {
+ this.out.writeLine(s);
+ if (this.wire.enabled()) {
+ String tmp = s + "\r\n";
+ this.wire.output(tmp.getBytes(this.charset));
+ }
+ }
+
+ public HttpTransportMetrics getMetrics() {
+ return this.out.getMetrics();
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/conn/ManagedClientConnectionImpl.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/conn/ManagedClientConnectionImpl.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/conn/ManagedClientConnectionImpl.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,468 @@
+/*
+ * ====================================================================
+ *
+ * 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
+ *
+ *
+ *
+ * @since 4.0
+ */
+@NotThreadSafe // e.g [gs]etProxySelector()
+public class ProxySelectorRoutePlanner implements HttpRoutePlanner {
+
+ /** The scheme registry. */
+ protected final SchemeRegistry schemeRegistry; // @ThreadSafe
+
+ /** The proxy selector to use, or null
for system default. */
+ protected ProxySelector proxySelector;
+
+ /**
+ * Creates a new proxy selector route planner.
+ *
+ * @param schreg the scheme registry
+ * @param prosel the proxy selector, or
+ * null
for the system default
+ */
+ public ProxySelectorRoutePlanner(SchemeRegistry schreg,
+ ProxySelector prosel) {
+
+ if (schreg == null) {
+ throw new IllegalArgumentException
+ ("SchemeRegistry must not be null.");
+ }
+ schemeRegistry = schreg;
+ proxySelector = prosel;
+ }
+
+ /**
+ * Obtains the proxy selector to use.
+ *
+ * @return the proxy selector, or null
for the system default
+ */
+ public ProxySelector getProxySelector() {
+ return this.proxySelector;
+ }
+
+ /**
+ * Sets the proxy selector to use.
+ *
+ * @param prosel the proxy selector, or
+ * null
to use the system default
+ */
+ public void setProxySelector(ProxySelector prosel) {
+ this.proxySelector = prosel;
+ }
+
+ public HttpRoute determineRoute(HttpHost target,
+ HttpRequest request,
+ HttpContext context)
+ throws HttpException {
+
+ if (request == null) {
+ throw new IllegalStateException
+ ("Request must not be null.");
+ }
+
+ // If we have a forced route, we can do without a target.
+ HttpRoute route =
+ ConnRouteParams.getForcedRoute(request.getParams());
+ if (route != null)
+ return route;
+
+ // If we get here, there is no forced route.
+ // So we need a target to compute a route.
+
+ if (target == null) {
+ throw new IllegalStateException
+ ("Target host must not be null.");
+ }
+
+ final InetAddress local =
+ ConnRouteParams.getLocalAddress(request.getParams());
+ final HttpHost proxy = determineProxy(target, request, context);
+
+ final Scheme schm =
+ this.schemeRegistry.getScheme(target.getSchemeName());
+ // as it is typically used for TLS/SSL, we assume that
+ // a layered scheme implies a secure connection
+ final boolean secure = schm.isLayered();
+
+ if (proxy == null) {
+ route = new HttpRoute(target, local, secure);
+ } else {
+ route = new HttpRoute(target, local, proxy, secure);
+ }
+ return route;
+ }
+
+ /**
+ * Determines a proxy for the given target.
+ *
+ * @param target the planned target, never null
+ * @param request the request to be sent, never null
+ * @param context the context, or null
+ *
+ * @return the proxy to use, or null
for a direct route
+ *
+ * @throws HttpException
+ * in case of system proxy settings that cannot be handled
+ */
+ protected HttpHost determineProxy(HttpHost target,
+ HttpRequest request,
+ HttpContext context)
+ throws HttpException {
+
+ // the proxy selector can be 'unset', so we better deal with null here
+ ProxySelector psel = this.proxySelector;
+ if (psel == null)
+ psel = ProxySelector.getDefault();
+ if (psel == null)
+ return null;
+
+ URI targetURI = null;
+ try {
+ targetURI = new URI(target.toURI());
+ } catch (URISyntaxException usx) {
+ throw new HttpException
+ ("Cannot convert host to URI: " + target, usx);
+ }
+ List
+ * (TODO: determine format for IPv6 addresses, with or without [brackets])
+ */
+ protected String getHost(InetSocketAddress isa) {
+
+ //@@@ Will this work with literal IPv6 addresses, or do we
+ //@@@ need to wrap these in [] for the string representation?
+ //@@@ Having it in this method at least allows for easy workarounds.
+ return isa.isUnresolved() ?
+ isa.getHostName() : isa.getAddress().getHostAddress();
+
+ }
+
+ /**
+ * Chooses a proxy from a list of available proxies.
+ * The default implementation just picks the first non-SOCKS proxy
+ * from the list. If there are only SOCKS proxies,
+ * {@link Proxy#NO_PROXY Proxy.NO_PROXY} is returned.
+ * Derived classes may implement more advanced strategies,
+ * such as proxy rotation if there are multiple options.
+ *
+ * @param proxies the list of proxies to choose from,
+ * never null
or empty
+ * @param target the planned target, never null
+ * @param request the request to be sent, never null
+ * @param context the context, or null
+ *
+ * @return a proxy type
+ */
+ protected Proxy chooseProxy(List
+ *
+ * null
+ *
+ * @return the connection operator to use
+ */
+ protected ClientConnectionOperator
+ createConnectionOperator(SchemeRegistry schreg) {
+ return new DefaultClientConnectionOperator(schreg);
+ }
+
+ /**
+ * Asserts that this manager is not shut down.
+ *
+ * @throws IllegalStateException if this manager is shut down
+ */
+ protected final void assertStillUp() throws IllegalStateException {
+ if (this.isShutDown)
+ throw new IllegalStateException("Manager is shut down.");
+ }
+
+ public final ClientConnectionRequest requestConnection(
+ final HttpRoute route,
+ final Object state) {
+
+ return new ClientConnectionRequest() {
+
+ public void abortRequest() {
+ // Nothing to abort, since requests are immediate.
+ }
+
+ public ManagedClientConnection getConnection(
+ long timeout, TimeUnit tunit) {
+ return SingleClientConnManager.this.getConnection(
+ route, state);
+ }
+
+ };
+ }
+
+ /**
+ * Obtains a connection.
+ *
+ * @param route where the connection should point to
+ *
+ * @return a connection that can be used to communicate
+ * along the given route
+ */
+ public ManagedClientConnection getConnection(HttpRoute route, Object state) {
+ if (route == null) {
+ throw new IllegalArgumentException("Route may not be null.");
+ }
+ assertStillUp();
+
+ if (log.isDebugEnabled()) {
+ log.debug("Get connection for route " + route);
+ }
+
+ synchronized (this) {
+ if (managedConn != null)
+ throw new IllegalStateException(MISUSE_MESSAGE);
+
+ // check re-usability of the connection
+ boolean recreate = false;
+ boolean shutdown = false;
+
+ // Kill the connection if it expired.
+ closeExpiredConnections();
+
+ if (uniquePoolEntry.connection.isOpen()) {
+ RouteTracker tracker = uniquePoolEntry.tracker;
+ shutdown = (tracker == null || // can happen if method is aborted
+ !tracker.toRoute().equals(route));
+ } else {
+ // If the connection is not open, create a new PoolEntry,
+ // as the connection may have been marked not reusable,
+ // due to aborts -- and the PoolEntry should not be reused
+ // either. There's no harm in recreating an entry if
+ // the connection is closed.
+ recreate = true;
+ }
+
+ if (shutdown) {
+ recreate = true;
+ try {
+ uniquePoolEntry.shutdown();
+ } catch (IOException iox) {
+ log.debug("Problem shutting down connection.", iox);
+ }
+ }
+
+ if (recreate)
+ uniquePoolEntry = new PoolEntry();
+
+ managedConn = new ConnAdapter(uniquePoolEntry, route);
+
+ return managedConn;
+ }
+ }
+
+ public void releaseConnection(
+ ManagedClientConnection conn,
+ long validDuration, TimeUnit timeUnit) {
+ assertStillUp();
+
+ if (!(conn instanceof ConnAdapter)) {
+ throw new IllegalArgumentException
+ ("Connection class mismatch, " +
+ "connection not obtained from this manager.");
+ }
+
+ if (log.isDebugEnabled()) {
+ log.debug("Releasing connection " + conn);
+ }
+
+ ConnAdapter sca = (ConnAdapter) conn;
+ synchronized (sca) {
+ if (sca.poolEntry == null)
+ return; // already released
+ ClientConnectionManager manager = sca.getManager();
+ if (manager != null && manager != this) {
+ throw new IllegalArgumentException
+ ("Connection not obtained from this manager.");
+ }
+ try {
+ // make sure that the response has been read completely
+ if (sca.isOpen() && (this.alwaysShutDown ||
+ !sca.isMarkedReusable())
+ ) {
+ if (log.isDebugEnabled()) {
+ log.debug
+ ("Released connection open but not reusable.");
+ }
+
+ // make sure this connection will not be re-used
+ // we might have gotten here because of a shutdown trigger
+ // shutdown of the adapter also clears the tracked route
+ sca.shutdown();
+ }
+ } catch (IOException iox) {
+ if (log.isDebugEnabled())
+ log.debug("Exception shutting down released connection.",
+ iox);
+ } finally {
+ sca.detach();
+ synchronized (this) {
+ managedConn = null;
+ lastReleaseTime = System.currentTimeMillis();
+ if(validDuration > 0)
+ connectionExpiresTime = timeUnit.toMillis(validDuration) + lastReleaseTime;
+ else
+ connectionExpiresTime = Long.MAX_VALUE;
+ }
+ }
+ }
+ }
+
+ public void closeExpiredConnections() {
+ long time = connectionExpiresTime;
+ if (System.currentTimeMillis() >= time) {
+ closeIdleConnections(0, TimeUnit.MILLISECONDS);
+ }
+ }
+
+ public void closeIdleConnections(long idletime, TimeUnit tunit) {
+ assertStillUp();
+
+ // idletime can be 0 or negative, no problem there
+ if (tunit == null) {
+ throw new IllegalArgumentException("Time unit must not be null.");
+ }
+
+ synchronized (this) {
+ if ((managedConn == null) && uniquePoolEntry.connection.isOpen()) {
+ final long cutoff =
+ System.currentTimeMillis() - tunit.toMillis(idletime);
+ if (lastReleaseTime <= cutoff) {
+ try {
+ uniquePoolEntry.close();
+ } catch (IOException iox) {
+ // ignore
+ log.debug("Problem closing idle connection.", iox);
+ }
+ }
+ }
+ }
+ }
+
+ public void shutdown() {
+ this.isShutDown = true;
+ synchronized (this) {
+ try {
+ if (uniquePoolEntry != null) // and connection open?
+ uniquePoolEntry.shutdown();
+ } catch (IOException iox) {
+ // ignore
+ log.debug("Problem while shutting down manager.", iox);
+ } finally {
+ uniquePoolEntry = null;
+ managedConn = null;
+ }
+ }
+ }
+
+ protected void revokeConnection() {
+ ConnAdapter conn = managedConn;
+ if (conn == null)
+ return;
+ conn.detach();
+
+ synchronized (this) {
+ try {
+ uniquePoolEntry.shutdown();
+ } catch (IOException iox) {
+ // ignore
+ log.debug("Problem while shutting down connection.", iox);
+ }
+ }
+ }
+
+ /**
+ * The pool entry for this connection manager.
+ */
+ protected class PoolEntry extends AbstractPoolEntry {
+
+ /**
+ * Creates a new pool entry.
+ *
+ */
+ protected PoolEntry() {
+ super(SingleClientConnManager.this.connOperator, null);
+ }
+
+ /**
+ * Closes the connection in this pool entry.
+ */
+ protected void close() throws IOException {
+ shutdownEntry();
+ if (connection.isOpen())
+ connection.close();
+ }
+
+ /**
+ * Shuts down the connection in this pool entry.
+ */
+ protected void shutdown() throws IOException {
+ shutdownEntry();
+ if (connection.isOpen())
+ connection.shutdown();
+ }
+
+ }
+
+ /**
+ * The connection adapter used by this manager.
+ */
+ protected class ConnAdapter extends AbstractPooledConnAdapter {
+
+ /**
+ * Creates a new connection adapter.
+ *
+ * @param entry the pool entry for the connection being wrapped
+ * @param route the planned route for this connection
+ */
+ protected ConnAdapter(PoolEntry entry, HttpRoute route) {
+ super(SingleClientConnManager.this, entry);
+ markReusable();
+ entry.route = route;
+ }
+
+ }
+
+}
Index: 3rdParty_sources/httpclient/org/apache/http/impl/conn/SystemDefaultDnsResolver.java
===================================================================
diff -u
--- 3rdParty_sources/httpclient/org/apache/http/impl/conn/SystemDefaultDnsResolver.java (revision 0)
+++ 3rdParty_sources/httpclient/org/apache/http/impl/conn/SystemDefaultDnsResolver.java (revision 96f14f440726936ee35b0547416534e59d3db24c)
@@ -0,0 +1,48 @@
+/*
+ * ====================================================================
+ * 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
+ * synchronized
for that purpose!
+ *
+ * @since 4.0
+ *
+ * @deprecated (4.2) use {@link org.apache.http.pool.AbstractConnPool}
+ */
+@Deprecated
+public abstract class AbstractConnPool {
+
+ private final Log log;
+
+ /**
+ * The global lock for this pool.
+ */
+ protected final Lock poolLock;
+
+ /** References to issued connections */
+ @GuardedBy("poolLock")
+ protected Set