зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1058146. r=nalexander
This commit is contained in:
Родитель
aa1d2d7d4e
Коммит
e7723d3dd4
|
@ -5,67 +5,115 @@
|
|||
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
||||
|
||||
sync_thirdparty_java_files = [
|
||||
'ch/boye/httpclientandroidlib/androidextra/Base64.java',
|
||||
'ch/boye/httpclientandroidlib/androidextra/HttpClientAndroidLog.java',
|
||||
'ch/boye/httpclientandroidlib/annotation/GuardedBy.java',
|
||||
'ch/boye/httpclientandroidlib/annotation/Immutable.java',
|
||||
'ch/boye/httpclientandroidlib/annotation/NotThreadSafe.java',
|
||||
'ch/boye/httpclientandroidlib/annotation/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/annotation/ThreadSafe.java',
|
||||
'ch/boye/httpclientandroidlib/auth/AUTH.java',
|
||||
'ch/boye/httpclientandroidlib/auth/AuthenticationException.java',
|
||||
'ch/boye/httpclientandroidlib/auth/AuthOption.java',
|
||||
'ch/boye/httpclientandroidlib/auth/AuthProtocolState.java',
|
||||
'ch/boye/httpclientandroidlib/auth/AuthScheme.java',
|
||||
'ch/boye/httpclientandroidlib/auth/AuthSchemeFactory.java',
|
||||
'ch/boye/httpclientandroidlib/auth/AuthSchemeProvider.java',
|
||||
'ch/boye/httpclientandroidlib/auth/AuthSchemeRegistry.java',
|
||||
'ch/boye/httpclientandroidlib/auth/AuthScope.java',
|
||||
'ch/boye/httpclientandroidlib/auth/AuthState.java',
|
||||
'ch/boye/httpclientandroidlib/auth/BasicUserPrincipal.java',
|
||||
'ch/boye/httpclientandroidlib/auth/ChallengeState.java',
|
||||
'ch/boye/httpclientandroidlib/auth/ContextAwareAuthScheme.java',
|
||||
'ch/boye/httpclientandroidlib/auth/Credentials.java',
|
||||
'ch/boye/httpclientandroidlib/auth/InvalidCredentialsException.java',
|
||||
'ch/boye/httpclientandroidlib/auth/MalformedChallengeException.java',
|
||||
'ch/boye/httpclientandroidlib/auth/NTCredentials.java',
|
||||
'ch/boye/httpclientandroidlib/auth/NTUserPrincipal.java',
|
||||
'ch/boye/httpclientandroidlib/auth/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/auth/params/AuthParamBean.java',
|
||||
'ch/boye/httpclientandroidlib/auth/params/AuthParams.java',
|
||||
'ch/boye/httpclientandroidlib/auth/params/AuthPNames.java',
|
||||
'ch/boye/httpclientandroidlib/auth/params/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/auth/UsernamePasswordCredentials.java',
|
||||
'ch/boye/httpclientandroidlib/client/AuthCache.java',
|
||||
'ch/boye/httpclientandroidlib/client/AuthenticationHandler.java',
|
||||
'ch/boye/httpclientandroidlib/client/AuthenticationStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/client/BackoffManager.java',
|
||||
'ch/boye/httpclientandroidlib/client/cache/CacheResponseStatus.java',
|
||||
'ch/boye/httpclientandroidlib/client/cache/HeaderConstants.java',
|
||||
'ch/boye/httpclientandroidlib/client/cache/HttpCacheContext.java',
|
||||
'ch/boye/httpclientandroidlib/client/cache/HttpCacheEntry.java',
|
||||
'ch/boye/httpclientandroidlib/client/cache/HttpCacheEntrySerializationException.java',
|
||||
'ch/boye/httpclientandroidlib/client/cache/HttpCacheEntrySerializer.java',
|
||||
'ch/boye/httpclientandroidlib/client/cache/HttpCacheInvalidator.java',
|
||||
'ch/boye/httpclientandroidlib/client/cache/HttpCacheStorage.java',
|
||||
'ch/boye/httpclientandroidlib/client/cache/HttpCacheUpdateCallback.java',
|
||||
'ch/boye/httpclientandroidlib/client/cache/HttpCacheUpdateException.java',
|
||||
'ch/boye/httpclientandroidlib/client/cache/InputLimit.java',
|
||||
'ch/boye/httpclientandroidlib/client/cache/Resource.java',
|
||||
'ch/boye/httpclientandroidlib/client/cache/ResourceFactory.java',
|
||||
'ch/boye/httpclientandroidlib/client/CircularRedirectException.java',
|
||||
'ch/boye/httpclientandroidlib/client/ClientProtocolException.java',
|
||||
'ch/boye/httpclientandroidlib/client/config/AuthSchemes.java',
|
||||
'ch/boye/httpclientandroidlib/client/config/CookieSpecs.java',
|
||||
'ch/boye/httpclientandroidlib/client/config/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/client/config/RequestConfig.java',
|
||||
'ch/boye/httpclientandroidlib/client/ConnectionBackoffStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/client/CookieStore.java',
|
||||
'ch/boye/httpclientandroidlib/client/CredentialsProvider.java',
|
||||
'ch/boye/httpclientandroidlib/client/entity/DecompressingEntity.java',
|
||||
'ch/boye/httpclientandroidlib/client/entity/DeflateDecompressingEntity.java',
|
||||
'ch/boye/httpclientandroidlib/client/entity/DeflateInputStream.java',
|
||||
'ch/boye/httpclientandroidlib/client/entity/EntityBuilder.java',
|
||||
'ch/boye/httpclientandroidlib/client/entity/GzipCompressingEntity.java',
|
||||
'ch/boye/httpclientandroidlib/client/entity/GzipDecompressingEntity.java',
|
||||
'ch/boye/httpclientandroidlib/client/entity/LazyDecompressingInputStream.java',
|
||||
'ch/boye/httpclientandroidlib/client/entity/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/client/entity/UrlEncodedFormEntity.java',
|
||||
'ch/boye/httpclientandroidlib/client/HttpClient.java',
|
||||
'ch/boye/httpclientandroidlib/client/HttpRequestRetryHandler.java',
|
||||
'ch/boye/httpclientandroidlib/client/HttpResponseException.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/AbortableHttpRequest.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/AbstractExecutionAwareRequest.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/CloseableHttpResponse.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/Configurable.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/HttpDelete.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/HttpEntityEnclosingRequestBase.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/HttpExecutionAware.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/HttpGet.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/HttpHead.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/HttpOptions.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/HttpPatch.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/HttpPost.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/HttpPut.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/HttpRequestBase.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/HttpRequestWrapper.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/HttpTrace.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/HttpUriRequest.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/client/methods/RequestBuilder.java',
|
||||
'ch/boye/httpclientandroidlib/client/NonRepeatableRequestException.java',
|
||||
'ch/boye/httpclientandroidlib/client/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/client/params/AllClientPNames.java',
|
||||
'ch/boye/httpclientandroidlib/client/params/AuthPolicy.java',
|
||||
'ch/boye/httpclientandroidlib/client/params/ClientParamBean.java',
|
||||
'ch/boye/httpclientandroidlib/client/params/ClientPNames.java',
|
||||
'ch/boye/httpclientandroidlib/client/params/CookiePolicy.java',
|
||||
'ch/boye/httpclientandroidlib/client/params/HttpClientParamConfig.java',
|
||||
'ch/boye/httpclientandroidlib/client/params/HttpClientParams.java',
|
||||
'ch/boye/httpclientandroidlib/client/params/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/ClientContext.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/ClientContextConfigurer.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/HttpClientContext.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/RequestAcceptEncoding.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/RequestAddCookies.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/RequestAuthCache.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/RequestAuthenticationBase.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/RequestClientConnControl.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/RequestDefaultHeaders.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/RequestExpectContinue.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/RequestProxyAuthentication.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/RequestTargetAuthentication.java',
|
||||
'ch/boye/httpclientandroidlib/client/protocol/ResponseAuthCache.java',
|
||||
|
@ -76,14 +124,30 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/client/RedirectStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/client/RequestDirector.java',
|
||||
'ch/boye/httpclientandroidlib/client/ResponseHandler.java',
|
||||
'ch/boye/httpclientandroidlib/client/ServiceUnavailableRetryStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/client/UserTokenHandler.java',
|
||||
'ch/boye/httpclientandroidlib/client/utils/CloneUtils.java',
|
||||
'ch/boye/httpclientandroidlib/client/utils/DateUtils.java',
|
||||
'ch/boye/httpclientandroidlib/client/utils/HttpClientUtils.java',
|
||||
'ch/boye/httpclientandroidlib/client/utils/Idn.java',
|
||||
'ch/boye/httpclientandroidlib/client/utils/JdkIdn.java',
|
||||
'ch/boye/httpclientandroidlib/client/utils/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/client/utils/Punycode.java',
|
||||
'ch/boye/httpclientandroidlib/client/utils/Rfc3492Idn.java',
|
||||
'ch/boye/httpclientandroidlib/client/utils/URIBuilder.java',
|
||||
'ch/boye/httpclientandroidlib/client/utils/URIUtils.java',
|
||||
'ch/boye/httpclientandroidlib/client/utils/URLEncodedUtils.java',
|
||||
'ch/boye/httpclientandroidlib/concurrent/BasicFuture.java',
|
||||
'ch/boye/httpclientandroidlib/concurrent/Cancellable.java',
|
||||
'ch/boye/httpclientandroidlib/concurrent/FutureCallback.java',
|
||||
'ch/boye/httpclientandroidlib/concurrent/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/config/ConnectionConfig.java',
|
||||
'ch/boye/httpclientandroidlib/config/Lookup.java',
|
||||
'ch/boye/httpclientandroidlib/config/MessageConstraints.java',
|
||||
'ch/boye/httpclientandroidlib/config/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/config/Registry.java',
|
||||
'ch/boye/httpclientandroidlib/config/RegistryBuilder.java',
|
||||
'ch/boye/httpclientandroidlib/config/SocketConfig.java',
|
||||
'ch/boye/httpclientandroidlib/conn/BasicEofSensorWatcher.java',
|
||||
'ch/boye/httpclientandroidlib/conn/BasicManagedEntity.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ClientConnectionManager.java',
|
||||
|
@ -93,14 +157,21 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/conn/ConnectionKeepAliveStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ConnectionPoolTimeoutException.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ConnectionReleaseTrigger.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ConnectionRequest.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ConnectTimeoutException.java',
|
||||
'ch/boye/httpclientandroidlib/conn/DnsResolver.java',
|
||||
'ch/boye/httpclientandroidlib/conn/EofSensorInputStream.java',
|
||||
'ch/boye/httpclientandroidlib/conn/EofSensorWatcher.java',
|
||||
'ch/boye/httpclientandroidlib/conn/HttpClientConnectionManager.java',
|
||||
'ch/boye/httpclientandroidlib/conn/HttpConnectionFactory.java',
|
||||
'ch/boye/httpclientandroidlib/conn/HttpHostConnectException.java',
|
||||
'ch/boye/httpclientandroidlib/conn/HttpInetSocketAddress.java',
|
||||
'ch/boye/httpclientandroidlib/conn/HttpRoutedConnection.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ManagedClientConnection.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ManagedHttpClientConnection.java',
|
||||
'ch/boye/httpclientandroidlib/conn/MultihomePlainSocketFactory.java',
|
||||
'ch/boye/httpclientandroidlib/conn/OperatedClientConnection.java',
|
||||
'ch/boye/httpclientandroidlib/conn/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/conn/params/ConnConnectionParamBean.java',
|
||||
'ch/boye/httpclientandroidlib/conn/params/ConnConnectionPNames.java',
|
||||
'ch/boye/httpclientandroidlib/conn/params/ConnManagerParamBean.java',
|
||||
|
@ -111,36 +182,58 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/conn/params/ConnRouteParamBean.java',
|
||||
'ch/boye/httpclientandroidlib/conn/params/ConnRouteParams.java',
|
||||
'ch/boye/httpclientandroidlib/conn/params/ConnRoutePNames.java',
|
||||
'ch/boye/httpclientandroidlib/conn/params/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/conn/routing/BasicRouteDirector.java',
|
||||
'ch/boye/httpclientandroidlib/conn/routing/HttpRoute.java',
|
||||
'ch/boye/httpclientandroidlib/conn/routing/HttpRouteDirector.java',
|
||||
'ch/boye/httpclientandroidlib/conn/routing/HttpRoutePlanner.java',
|
||||
'ch/boye/httpclientandroidlib/conn/routing/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/conn/routing/RouteInfo.java',
|
||||
'ch/boye/httpclientandroidlib/conn/routing/RouteTracker.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/HostNameResolver.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/LayeredSchemeSocketFactory.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/LayeredSchemeSocketFactoryAdaptor.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/LayeredSocketFactory.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/LayeredSocketFactoryAdaptor.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/PlainSocketFactory.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/Scheme.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/SchemeLayeredSocketFactory.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/SchemeLayeredSocketFactoryAdaptor.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/SchemeLayeredSocketFactoryAdaptor2.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/SchemeRegistry.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/SchemeSocketFactory.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/SchemeSocketFactoryAdaptor.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/SocketFactory.java',
|
||||
'ch/boye/httpclientandroidlib/conn/scheme/SocketFactoryAdaptor.java',
|
||||
'ch/boye/httpclientandroidlib/conn/SchemePortResolver.java',
|
||||
'ch/boye/httpclientandroidlib/conn/socket/ConnectionSocketFactory.java',
|
||||
'ch/boye/httpclientandroidlib/conn/socket/LayeredConnectionSocketFactory.java',
|
||||
'ch/boye/httpclientandroidlib/conn/socket/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/conn/socket/PlainConnectionSocketFactory.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/AbstractVerifier.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/AllowAllHostnameVerifier.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/BrowserCompatHostnameVerifier.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/DistinguishedNameParser.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/PrivateKeyDetails.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/PrivateKeyStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/SSLConnectionSocketFactory.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/SSLContextBuilder.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/SSLContexts.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/SSLInitializationException.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/SSLSocketFactory.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/StrictHostnameVerifier.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/TrustManagerDecorator.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/TokenParser.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/TrustSelfSignedStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/TrustStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/conn/ssl/X509HostnameVerifier.java',
|
||||
'ch/boye/httpclientandroidlib/conn/UnsupportedSchemeException.java',
|
||||
'ch/boye/httpclientandroidlib/conn/util/InetAddressUtils.java',
|
||||
'ch/boye/httpclientandroidlib/conn/util/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/ConnectionClosedException.java',
|
||||
'ch/boye/httpclientandroidlib/ConnectionReuseStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/Consts.java',
|
||||
'ch/boye/httpclientandroidlib/ContentTooLongException.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/ClientCookie.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/Cookie.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/CookieAttributeHandler.java',
|
||||
|
@ -150,10 +243,13 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/cookie/CookieRestrictionViolationException.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/CookieSpec.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/CookieSpecFactory.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/CookieSpecProvider.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/CookieSpecRegistry.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/MalformedCookieException.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/params/CookieSpecParamBean.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/params/CookieSpecPNames.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/params/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/SetCookie.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/SetCookie2.java',
|
||||
'ch/boye/httpclientandroidlib/cookie/SM.java',
|
||||
|
@ -163,10 +259,32 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/entity/ByteArrayEntity.java',
|
||||
'ch/boye/httpclientandroidlib/entity/ContentLengthStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/entity/ContentProducer.java',
|
||||
'ch/boye/httpclientandroidlib/entity/ContentType.java',
|
||||
'ch/boye/httpclientandroidlib/entity/EntityTemplate.java',
|
||||
'ch/boye/httpclientandroidlib/entity/FileEntity.java',
|
||||
'ch/boye/httpclientandroidlib/entity/HttpEntityWrapper.java',
|
||||
'ch/boye/httpclientandroidlib/entity/InputStreamEntity.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/AbstractMultipartForm.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/content/AbstractContentBody.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/content/ByteArrayBody.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/content/ContentBody.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/content/ContentDescriptor.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/content/FileBody.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/content/InputStreamBody.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/content/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/content/StringBody.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/FormBodyPart.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/Header.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/HttpBrowserCompatibleMultipart.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/HttpMultipartMode.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/HttpRFC6532Multipart.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/HttpStrictMultipart.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/MIME.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/MinimalField.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/MultipartEntityBuilder.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/MultipartFormEntity.java',
|
||||
'ch/boye/httpclientandroidlib/entity/mime/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/entity/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/entity/SerializableEntity.java',
|
||||
'ch/boye/httpclientandroidlib/entity/StringEntity.java',
|
||||
'ch/boye/httpclientandroidlib/FormattedHeader.java',
|
||||
|
@ -176,6 +294,7 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/HeaderIterator.java',
|
||||
'ch/boye/httpclientandroidlib/HttpClientConnection.java',
|
||||
'ch/boye/httpclientandroidlib/HttpConnection.java',
|
||||
'ch/boye/httpclientandroidlib/HttpConnectionFactory.java',
|
||||
'ch/boye/httpclientandroidlib/HttpConnectionMetrics.java',
|
||||
'ch/boye/httpclientandroidlib/HttpEntity.java',
|
||||
'ch/boye/httpclientandroidlib/HttpEntityEnclosingRequest.java',
|
||||
|
@ -200,22 +319,80 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/impl/auth/BasicSchemeFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/auth/DigestScheme.java',
|
||||
'ch/boye/httpclientandroidlib/impl/auth/DigestSchemeFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/auth/HttpAuthenticator.java',
|
||||
'ch/boye/httpclientandroidlib/impl/auth/HttpEntityDigester.java',
|
||||
'ch/boye/httpclientandroidlib/impl/auth/NTLMEngine.java',
|
||||
'ch/boye/httpclientandroidlib/impl/auth/NTLMEngineException.java',
|
||||
'ch/boye/httpclientandroidlib/impl/auth/NTLMEngineImpl.java',
|
||||
'ch/boye/httpclientandroidlib/impl/auth/NTLMScheme.java',
|
||||
'ch/boye/httpclientandroidlib/impl/auth/NTLMSchemeFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/auth/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/impl/auth/RFC2617Scheme.java',
|
||||
'ch/boye/httpclientandroidlib/impl/auth/SpnegoTokenGenerator.java',
|
||||
'ch/boye/httpclientandroidlib/impl/auth/UnsupportedDigestAlgorithmException.java',
|
||||
'ch/boye/httpclientandroidlib/impl/BHttpConnectionBase.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/AbstractAuthenticationHandler.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/AbstractHttpClient.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/AIMDBackoffManager.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/AuthenticationStrategyAdaptor.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/AuthenticationStrategyImpl.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/AutoRetryHttpClient.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/BasicAuthCache.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/BasicCookieStore.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/BasicCredentialsProvider.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/BasicResponseHandler.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/AsynchronousValidationRequest.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/AsynchronousValidator.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/BasicHttpCache.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/BasicHttpCacheStorage.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/BasicIdGenerator.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CacheableRequestPolicy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CacheConfig.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CachedHttpResponseGenerator.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CachedResponseSuitabilityChecker.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CacheEntity.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CacheEntryUpdater.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CacheInvalidator.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CacheKeyGenerator.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CacheMap.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CacheValidityPolicy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CachingExec.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CachingHttpClientBuilder.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CachingHttpClients.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/CombinedEntity.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/ConditionalRequestBuilder.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/DefaultFailureCache.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/DefaultHttpCacheEntrySerializer.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/ExponentialBackOffSchedulingStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/FailureCache.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/FailureCacheValue.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/FileResource.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/FileResourceFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/HeapResource.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/HeapResourceFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/HttpCache.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/ImmediateSchedulingStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/IOUtils.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/ManagedHttpCacheStorage.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/OptionsHttp11Response.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/Proxies.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/RequestProtocolCompliance.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/RequestProtocolError.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/ResourceReference.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/ResponseCachingPolicy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/ResponseProtocolCompliance.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/ResponseProxyHandler.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/SchedulingStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/SizeLimitedResponseReader.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/Variant.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/cache/WarningValue.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/ClientParamsStack.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/Clock.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/CloseableHttpClient.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/CloseableHttpResponseProxy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/ContentEncodingHttpClient.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/DecompressingHttpClient.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/DefaultBackoffStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/DefaultConnectionKeepAliveStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/DefaultHttpClient.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/DefaultHttpRequestRetryHandler.java',
|
||||
|
@ -224,41 +401,86 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/impl/client/DefaultRedirectStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/DefaultRedirectStrategyAdaptor.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/DefaultRequestDirector.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/DefaultServiceUnavailableRetryStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/DefaultTargetAuthenticationHandler.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/DefaultUserTokenHandler.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/EntityEnclosingRequestWrapper.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/FutureRequestExecutionMetrics.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/FutureRequestExecutionService.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/HttpAuthenticator.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/HttpClientBuilder.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/HttpClients.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/HttpRequestFutureTask.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/HttpRequestTaskCallable.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/InternalHttpClient.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/LaxRedirectStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/MinimalHttpClient.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/NoopUserTokenHandler.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/NullBackoffStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/ProxyAuthenticationStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/ProxyClient.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/RedirectLocations.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/RequestWrapper.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/RoutedRequest.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/StandardHttpRequestRetryHandler.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/SystemClock.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/SystemDefaultCredentialsProvider.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/SystemDefaultHttpClient.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/TargetAuthenticationStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/client/TunnelRefusedException.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/AbstractClientConnAdapter.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/AbstractPooledConnAdapter.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/AbstractPoolEntry.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/BasicClientConnectionManager.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/BasicHttpClientConnectionManager.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/ConnectionShutdownException.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/CPool.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/CPoolEntry.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/CPoolProxy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/DefaultClientConnection.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/DefaultClientConnectionOperator.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/DefaultHttpResponseParser.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/DefaultHttpResponseParserFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/DefaultHttpRoutePlanner.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/DefaultManagedHttpClientConnection.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/DefaultProxyRoutePlanner.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/DefaultResponseParser.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/HttpInetSocketAddress.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/DefaultRoutePlanner.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/DefaultSchemePortResolver.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/HttpClientConnectionOperator.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/HttpConnPool.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/HttpPoolEntry.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/IdleConnectionHandler.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/InMemoryDnsResolver.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/LoggingInputStream.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/LoggingManagedHttpClientConnection.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/LoggingOutputStream.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/LoggingSessionInputBuffer.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/LoggingSessionOutputBuffer.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/ManagedClientConnectionImpl.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/ManagedHttpClientConnectionFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/PoolingClientConnectionManager.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/PoolingHttpClientConnectionManager.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/ProxySelectorRoutePlanner.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/SchemeRegistryFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/SingleClientConnManager.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/SystemDefaultDnsResolver.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/SystemDefaultRoutePlanner.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/tsccm/AbstractConnPool.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/tsccm/BasicPooledConnAdapter.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/tsccm/BasicPoolEntry.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/tsccm/BasicPoolEntryRef.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/tsccm/ConnPoolByRoute.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/tsccm/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/tsccm/PoolEntryRequest.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/tsccm/RefQueueHandler.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/tsccm/RefQueueWorker.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/tsccm/RouteSpecificPool.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/tsccm/ThreadSafeClientConnManager.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/tsccm/WaitingThread.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/tsccm/WaitingThreadAborter.java',
|
||||
'ch/boye/httpclientandroidlib/impl/conn/Wire.java',
|
||||
'ch/boye/httpclientandroidlib/impl/ConnSupport.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/AbstractCookieAttributeHandler.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/AbstractCookieSpec.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/BasicClientCookie.java',
|
||||
|
@ -273,6 +495,7 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/impl/cookie/BestMatchSpecFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/BrowserCompatSpec.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/BrowserCompatSpecFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/BrowserCompatVersionAttributeHandler.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/CookieSpecBase.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/DateParseException.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/DateUtils.java',
|
||||
|
@ -282,6 +505,7 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/impl/cookie/NetscapeDraftHeaderParser.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/NetscapeDraftSpec.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/NetscapeDraftSpecFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/PublicSuffixFilter.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/PublicSuffixListParser.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/RFC2109DomainHandler.java',
|
||||
|
@ -295,16 +519,37 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/impl/cookie/RFC2965Spec.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/RFC2965SpecFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/cookie/RFC2965VersionAttributeHandler.java',
|
||||
'ch/boye/httpclientandroidlib/impl/DefaultBHttpClientConnection.java',
|
||||
'ch/boye/httpclientandroidlib/impl/DefaultBHttpClientConnectionFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/DefaultBHttpServerConnection.java',
|
||||
'ch/boye/httpclientandroidlib/impl/DefaultBHttpServerConnectionFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/DefaultConnectionReuseStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/DefaultHttpClientConnection.java',
|
||||
'ch/boye/httpclientandroidlib/impl/DefaultHttpRequestFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/DefaultHttpResponseFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/DefaultHttpServerConnection.java',
|
||||
'ch/boye/httpclientandroidlib/impl/EnglishReasonPhraseCatalog.java',
|
||||
'ch/boye/httpclientandroidlib/impl/entity/DisallowIdentityContentLengthStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/entity/EntityDeserializer.java',
|
||||
'ch/boye/httpclientandroidlib/impl/entity/EntitySerializer.java',
|
||||
'ch/boye/httpclientandroidlib/impl/entity/LaxContentLengthStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/entity/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/impl/entity/StrictContentLengthStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/BackoffStrategyExec.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/ClientExecChain.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/ConnectionHolder.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/HttpResponseProxy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/MainClientExec.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/MinimalClientExec.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/ProtocolExec.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/RedirectExec.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/RequestAbortedException.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/RequestEntityProxy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/ResponseEntityProxy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/RetryExec.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/ServiceUnavailableRetryExec.java',
|
||||
'ch/boye/httpclientandroidlib/impl/execchain/TunnelRefusedException.java',
|
||||
'ch/boye/httpclientandroidlib/impl/HttpConnectionMetricsImpl.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/AbstractMessageParser.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/AbstractMessageWriter.java',
|
||||
|
@ -314,6 +559,14 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/impl/io/ChunkedOutputStream.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/ContentLengthInputStream.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/ContentLengthOutputStream.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/DefaultHttpRequestParser.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/DefaultHttpRequestParserFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/DefaultHttpRequestWriter.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/DefaultHttpRequestWriterFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/DefaultHttpResponseParser.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/DefaultHttpResponseParserFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/DefaultHttpResponseWriter.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/DefaultHttpResponseWriterFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/HttpRequestParser.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/HttpRequestWriter.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/HttpResponseParser.java',
|
||||
|
@ -321,16 +574,27 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/impl/io/HttpTransportMetricsImpl.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/IdentityInputStream.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/IdentityOutputStream.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/SessionInputBufferImpl.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/SessionOutputBufferImpl.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/SocketInputBuffer.java',
|
||||
'ch/boye/httpclientandroidlib/impl/io/SocketOutputBuffer.java',
|
||||
'ch/boye/httpclientandroidlib/impl/NoConnectionReuseStrategy.java',
|
||||
'ch/boye/httpclientandroidlib/impl/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/impl/pool/BasicConnFactory.java',
|
||||
'ch/boye/httpclientandroidlib/impl/pool/BasicConnPool.java',
|
||||
'ch/boye/httpclientandroidlib/impl/pool/BasicPoolEntry.java',
|
||||
'ch/boye/httpclientandroidlib/impl/pool/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/impl/SocketHttpClientConnection.java',
|
||||
'ch/boye/httpclientandroidlib/impl/SocketHttpServerConnection.java',
|
||||
'ch/boye/httpclientandroidlib/io/BufferInfo.java',
|
||||
'ch/boye/httpclientandroidlib/io/EofSensor.java',
|
||||
'ch/boye/httpclientandroidlib/io/HttpMessageParser.java',
|
||||
'ch/boye/httpclientandroidlib/io/HttpMessageParserFactory.java',
|
||||
'ch/boye/httpclientandroidlib/io/HttpMessageWriter.java',
|
||||
'ch/boye/httpclientandroidlib/io/HttpMessageWriterFactory.java',
|
||||
'ch/boye/httpclientandroidlib/io/HttpTransportMetrics.java',
|
||||
'ch/boye/httpclientandroidlib/io/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/io/SessionInputBuffer.java',
|
||||
'ch/boye/httpclientandroidlib/io/SessionOutputBuffer.java',
|
||||
'ch/boye/httpclientandroidlib/MalformedChunkCodingException.java',
|
||||
|
@ -357,10 +621,13 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/message/HeaderValueParser.java',
|
||||
'ch/boye/httpclientandroidlib/message/LineFormatter.java',
|
||||
'ch/boye/httpclientandroidlib/message/LineParser.java',
|
||||
'ch/boye/httpclientandroidlib/message/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/message/ParserCursor.java',
|
||||
'ch/boye/httpclientandroidlib/MessageConstraintException.java',
|
||||
'ch/boye/httpclientandroidlib/MethodNotSupportedException.java',
|
||||
'ch/boye/httpclientandroidlib/NameValuePair.java',
|
||||
'ch/boye/httpclientandroidlib/NoHttpResponseException.java',
|
||||
'ch/boye/httpclientandroidlib/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/params/AbstractHttpParams.java',
|
||||
'ch/boye/httpclientandroidlib/params/BasicHttpParams.java',
|
||||
'ch/boye/httpclientandroidlib/params/CoreConnectionPNames.java',
|
||||
|
@ -369,28 +636,46 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/params/HttpAbstractParamBean.java',
|
||||
'ch/boye/httpclientandroidlib/params/HttpConnectionParamBean.java',
|
||||
'ch/boye/httpclientandroidlib/params/HttpConnectionParams.java',
|
||||
'ch/boye/httpclientandroidlib/params/HttpParamConfig.java',
|
||||
'ch/boye/httpclientandroidlib/params/HttpParams.java',
|
||||
'ch/boye/httpclientandroidlib/params/HttpParamsNames.java',
|
||||
'ch/boye/httpclientandroidlib/params/HttpProtocolParamBean.java',
|
||||
'ch/boye/httpclientandroidlib/params/HttpProtocolParams.java',
|
||||
'ch/boye/httpclientandroidlib/params/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/params/SyncBasicHttpParams.java',
|
||||
'ch/boye/httpclientandroidlib/ParseException.java',
|
||||
'ch/boye/httpclientandroidlib/pool/AbstractConnPool.java',
|
||||
'ch/boye/httpclientandroidlib/pool/ConnFactory.java',
|
||||
'ch/boye/httpclientandroidlib/pool/ConnPool.java',
|
||||
'ch/boye/httpclientandroidlib/pool/ConnPoolControl.java',
|
||||
'ch/boye/httpclientandroidlib/pool/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/pool/PoolEntry.java',
|
||||
'ch/boye/httpclientandroidlib/pool/PoolEntryCallback.java',
|
||||
'ch/boye/httpclientandroidlib/pool/PoolEntryFuture.java',
|
||||
'ch/boye/httpclientandroidlib/pool/PoolStats.java',
|
||||
'ch/boye/httpclientandroidlib/pool/RouteSpecificPool.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/BasicHttpContext.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/BasicHttpProcessor.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/ChainBuilder.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/DefaultedHttpContext.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/ExecutionContext.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HTTP.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpContext.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpCoreContext.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpDateGenerator.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpExpectationVerifier.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpProcessor.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpProcessorBuilder.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpRequestExecutor.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpRequestHandler.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpRequestHandlerMapper.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpRequestHandlerRegistry.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpRequestHandlerResolver.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpRequestInterceptorList.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpResponseInterceptorList.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/HttpService.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/ImmutableHttpProcessor.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/RequestConnControl.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/RequestContent.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/RequestDate.java',
|
||||
|
@ -402,6 +687,7 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/protocol/ResponseDate.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/ResponseServer.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/SyncBasicHttpContext.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/UriHttpRequestHandlerMapper.java',
|
||||
'ch/boye/httpclientandroidlib/protocol/UriPatternMatcher.java',
|
||||
'ch/boye/httpclientandroidlib/ProtocolException.java',
|
||||
'ch/boye/httpclientandroidlib/ProtocolVersion.java',
|
||||
|
@ -411,12 +697,18 @@ sync_thirdparty_java_files = [
|
|||
'ch/boye/httpclientandroidlib/TokenIterator.java',
|
||||
'ch/boye/httpclientandroidlib/TruncatedChunkException.java',
|
||||
'ch/boye/httpclientandroidlib/UnsupportedHttpVersionException.java',
|
||||
'ch/boye/httpclientandroidlib/util/Args.java',
|
||||
'ch/boye/httpclientandroidlib/util/Asserts.java',
|
||||
'ch/boye/httpclientandroidlib/util/ByteArrayBuffer.java',
|
||||
'ch/boye/httpclientandroidlib/util/CharArrayBuffer.java',
|
||||
'ch/boye/httpclientandroidlib/util/CharsetUtils.java',
|
||||
'ch/boye/httpclientandroidlib/util/EncodingUtils.java',
|
||||
'ch/boye/httpclientandroidlib/util/EntityUtils.java',
|
||||
'ch/boye/httpclientandroidlib/util/ExceptionUtils.java',
|
||||
'ch/boye/httpclientandroidlib/util/LangUtils.java',
|
||||
'ch/boye/httpclientandroidlib/util/NetUtils.java',
|
||||
'ch/boye/httpclientandroidlib/util/package-info.java',
|
||||
'ch/boye/httpclientandroidlib/util/TextUtils.java',
|
||||
'ch/boye/httpclientandroidlib/util/VersionInfo.java',
|
||||
'org/json/simple/ItemList.java',
|
||||
'org/json/simple/JSONArray.java',
|
||||
|
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Commons constants.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public final class Consts {
|
||||
|
||||
public static final int CR = 13; // <US-ASCII CR, carriage return (13)>
|
||||
public static final int LF = 10; // <US-ASCII LF, linefeed (10)>
|
||||
public static final int SP = 32; // <US-ASCII SP, space (32)>
|
||||
public static final int HT = 9; // <US-ASCII HT, horizontal-tab (9)>
|
||||
|
||||
public static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
public static final Charset ASCII = Charset.forName("US-ASCII");
|
||||
public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
|
||||
|
||||
private Consts() {
|
||||
}
|
||||
|
||||
}
|
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ContentTooLongException.java
поставляемый
Normal file
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ContentTooLongException.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Signals that HTTP entity content is too long.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public class ContentTooLongException extends IOException {
|
||||
|
||||
private static final long serialVersionUID = -924287689552495383L;
|
||||
|
||||
/**
|
||||
* Creates a new ContentTooLongException with the specified detail message.
|
||||
*
|
||||
* @param message exception message
|
||||
*/
|
||||
public ContentTooLongException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -99,7 +99,7 @@ public interface HeaderElement {
|
|||
/**
|
||||
* Returns parameter with the given index.
|
||||
*
|
||||
* @param index
|
||||
* @param index index
|
||||
* @return name / value pair
|
||||
*/
|
||||
NameValuePair getParameter(int index);
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.Iterator;
|
|||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HeaderElementIterator extends Iterator {
|
||||
public interface HeaderElementIterator extends Iterator<Object> {
|
||||
|
||||
/**
|
||||
* Indicates whether there is another header element in this
|
||||
|
|
|
@ -34,7 +34,7 @@ import java.util.Iterator;
|
|||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HeaderIterator extends Iterator {
|
||||
public interface HeaderIterator extends Iterator<Object> {
|
||||
|
||||
/**
|
||||
* Indicates whether there is another header in this iteration.
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +35,7 @@ import java.io.IOException;
|
|||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpConnection {
|
||||
public interface HttpConnection extends Closeable {
|
||||
|
||||
/**
|
||||
* Closes this connection gracefully.
|
||||
|
@ -43,13 +44,13 @@ public interface HttpConnection {
|
|||
* This method MUST NOT be called from a different thread to force
|
||||
* shutdown of the connection. Use {@link #shutdown shutdown} instead.
|
||||
*/
|
||||
public void close() throws IOException;
|
||||
void close() throws IOException;
|
||||
|
||||
/**
|
||||
* Checks if this connection is open.
|
||||
* @return true if it is open, false if it is closed.
|
||||
*/
|
||||
public boolean isOpen();
|
||||
boolean isOpen();
|
||||
|
||||
/**
|
||||
* Checks whether this connection has gone down.
|
||||
|
@ -66,7 +67,7 @@ public interface HttpConnection {
|
|||
* likely to succeed, or <code>false</code> if they are likely
|
||||
* to fail and this connection should be closed
|
||||
*/
|
||||
public boolean isStale();
|
||||
boolean isStale();
|
||||
|
||||
/**
|
||||
* Sets the socket timeout value.
|
||||
|
@ -91,7 +92,7 @@ public interface HttpConnection {
|
|||
* This method will not attempt to flush the transmitter's
|
||||
* internal buffer prior to closing the underlying socket.
|
||||
*/
|
||||
public void shutdown() throws IOException;
|
||||
void shutdown() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns a collection of connection metrics.
|
||||
|
|
42
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpConnectionFactory.java
поставляемый
Normal file
42
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpConnectionFactory.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
|
||||
/**
|
||||
* Factory for {@link HttpConnection} instances.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public interface HttpConnectionFactory<T extends HttpConnection> {
|
||||
|
||||
T createConnection(Socket socket) throws IOException;
|
||||
|
||||
}
|
|
@ -189,10 +189,11 @@ public interface HttpEntity {
|
|||
*
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*
|
||||
* @deprecated Use {@link ch.boye.httpclientandroidlib.util.EntityUtils#consume(HttpEntity)}
|
||||
* @deprecated (4.1) Use {@link ch.boye.httpclientandroidlib.util.EntityUtils#consume(HttpEntity)}
|
||||
*
|
||||
* @see #getContent() and #writeTo(OutputStream)
|
||||
*/
|
||||
@Deprecated
|
||||
void consumeContent() throws IOException;
|
||||
|
||||
}
|
||||
|
|
|
@ -1,5 +1,4 @@
|
|||
/*
|
||||
* $Header: $
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
|
@ -25,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import ch.boye.httpclientandroidlib.util.ExceptionUtils;
|
||||
|
||||
/**
|
||||
* Signals that an HTTP exception has occurred.
|
||||
*
|
||||
|
@ -63,7 +61,7 @@ public class HttpException extends Exception {
|
|||
*/
|
||||
public HttpException(final String message, final Throwable cause) {
|
||||
super(message);
|
||||
ExceptionUtils.initCause(this, cause);
|
||||
initCause(cause);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -28,9 +28,11 @@
|
|||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Locale;
|
||||
|
||||
import ch.boye.httpclientandroidlib.util.CharArrayBuffer;
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
import ch.boye.httpclientandroidlib.util.LangUtils;
|
||||
|
||||
/**
|
||||
|
@ -40,7 +42,7 @@ import ch.boye.httpclientandroidlib.util.LangUtils;
|
|||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
//@Immutable
|
||||
@Immutable
|
||||
public final class HttpHost implements Cloneable, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7529410654042457626L;
|
||||
|
@ -55,12 +57,13 @@ public final class HttpHost implements Cloneable, Serializable {
|
|||
protected final String lcHostname;
|
||||
|
||||
|
||||
/** The port to use. */
|
||||
/** The port to use, defaults to -1 if not set. */
|
||||
protected final int port;
|
||||
|
||||
/** The scheme (lowercased) */
|
||||
protected final String schemeName;
|
||||
|
||||
protected final InetAddress address;
|
||||
|
||||
/**
|
||||
* Creates a new {@link HttpHost HttpHost}, specifying all values.
|
||||
|
@ -73,12 +76,9 @@ public final class HttpHost implements Cloneable, Serializable {
|
|||
* <code>null</code> indicates the
|
||||
* {@link #DEFAULT_SCHEME_NAME default scheme}
|
||||
*/
|
||||
public HttpHost(final String hostname, int port, final String scheme) {
|
||||
public HttpHost(final String hostname, final int port, final String scheme) {
|
||||
super();
|
||||
if (hostname == null) {
|
||||
throw new IllegalArgumentException("Host name may not be null");
|
||||
}
|
||||
this.hostname = hostname;
|
||||
this.hostname = Args.notBlank(hostname, "Host name");
|
||||
this.lcHostname = hostname.toLowerCase(Locale.ENGLISH);
|
||||
if (scheme != null) {
|
||||
this.schemeName = scheme.toLowerCase(Locale.ENGLISH);
|
||||
|
@ -86,6 +86,7 @@ public final class HttpHost implements Cloneable, Serializable {
|
|||
this.schemeName = DEFAULT_SCHEME_NAME;
|
||||
}
|
||||
this.port = port;
|
||||
this.address = null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -95,7 +96,7 @@ public final class HttpHost implements Cloneable, Serializable {
|
|||
* @param port the port number.
|
||||
* <code>-1</code> indicates the scheme default port.
|
||||
*/
|
||||
public HttpHost(final String hostname, int port) {
|
||||
public HttpHost(final String hostname, final int port) {
|
||||
this(hostname, port, null);
|
||||
}
|
||||
|
||||
|
@ -108,13 +109,69 @@ public final class HttpHost implements Cloneable, Serializable {
|
|||
this(hostname, -1, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link HttpHost HttpHost}, specifying all values.
|
||||
* Constructor for HttpHost.
|
||||
*
|
||||
* @param address the inet address.
|
||||
* @param port the port number.
|
||||
* <code>-1</code> indicates the scheme default port.
|
||||
* @param scheme the name of the scheme.
|
||||
* <code>null</code> indicates the
|
||||
* {@link #DEFAULT_SCHEME_NAME default scheme}
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public HttpHost(final InetAddress address, final int port, final String scheme) {
|
||||
super();
|
||||
this.address = Args.notNull(address, "Inet address");
|
||||
this.hostname = address.getHostAddress();
|
||||
this.lcHostname = this.hostname.toLowerCase(Locale.ENGLISH);
|
||||
if (scheme != null) {
|
||||
this.schemeName = scheme.toLowerCase(Locale.ENGLISH);
|
||||
} else {
|
||||
this.schemeName = DEFAULT_SCHEME_NAME;
|
||||
}
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link HttpHost HttpHost}, with default scheme.
|
||||
*
|
||||
* @param address the inet address.
|
||||
* @param port the port number.
|
||||
* <code>-1</code> indicates the scheme default port.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public HttpHost(final InetAddress address, final int port) {
|
||||
this(address, port, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link HttpHost HttpHost}, with default scheme and port.
|
||||
*
|
||||
* @param address the inet address.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public HttpHost(final InetAddress address) {
|
||||
this(address, -1, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor for {@link HttpHost HttpHost}.
|
||||
*
|
||||
* @param httphost the HTTP host to copy details from
|
||||
*/
|
||||
public HttpHost (final HttpHost httphost) {
|
||||
this(httphost.hostname, httphost.port, httphost.schemeName);
|
||||
super();
|
||||
Args.notNull(httphost, "HTTP host");
|
||||
this.hostname = httphost.hostname;
|
||||
this.lcHostname = httphost.lcHostname;
|
||||
this.schemeName = httphost.schemeName;
|
||||
this.port = httphost.port;
|
||||
this.address = httphost.address;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -144,13 +201,24 @@ public final class HttpHost implements Cloneable, Serializable {
|
|||
return this.schemeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the inet address if explicitly set by a constructor,
|
||||
* <code>null</code> otherwise.
|
||||
* @return the inet address
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public InetAddress getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the host URI, as a string.
|
||||
*
|
||||
* @return the host URI
|
||||
*/
|
||||
public String toURI() {
|
||||
CharArrayBuffer buffer = new CharArrayBuffer(32);
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buffer.append(this.schemeName);
|
||||
buffer.append("://");
|
||||
buffer.append(this.hostname);
|
||||
|
@ -170,7 +238,7 @@ public final class HttpHost implements Cloneable, Serializable {
|
|||
public String toHostString() {
|
||||
if (this.port != -1) {
|
||||
//the highest port number is 65535, which is length 6 with the addition of the colon
|
||||
CharArrayBuffer buffer = new CharArrayBuffer(this.hostname.length() + 6);
|
||||
final StringBuilder buffer = new StringBuilder(this.hostname.length() + 6);
|
||||
buffer.append(this.hostname);
|
||||
buffer.append(":");
|
||||
buffer.append(Integer.toString(this.port));
|
||||
|
@ -181,15 +249,19 @@ public final class HttpHost implements Cloneable, Serializable {
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toURI();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) return true;
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof HttpHost) {
|
||||
HttpHost that = (HttpHost) obj;
|
||||
final HttpHost that = (HttpHost) obj;
|
||||
return this.lcHostname.equals(that.lcHostname)
|
||||
&& this.port == that.port
|
||||
&& this.schemeName.equals(that.schemeName);
|
||||
|
@ -201,6 +273,7 @@ public final class HttpHost implements Cloneable, Serializable {
|
|||
/**
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = LangUtils.HASH_SEED;
|
||||
hash = LangUtils.hashCode(hash, this.lcHostname);
|
||||
|
@ -209,6 +282,7 @@ public final class HttpHost implements Cloneable, Serializable {
|
|||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@ import ch.boye.httpclientandroidlib.params.HttpParams;
|
|||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface HttpMessage {
|
||||
|
||||
/**
|
||||
|
@ -189,13 +190,21 @@ public interface HttpMessage {
|
|||
/**
|
||||
* Returns the parameters effective for this message as set by
|
||||
* {@link #setParams(HttpParams)}.
|
||||
*
|
||||
* @deprecated (4.3) use configuration classes provided 'ch.boye.httpclientandroidlib.config'
|
||||
* and 'ch.boye.httpclientandroidlib.client.config'
|
||||
*/
|
||||
@Deprecated
|
||||
HttpParams getParams();
|
||||
|
||||
/**
|
||||
* Provides parameters to be used for the processing of this message.
|
||||
* @param params the parameters
|
||||
*
|
||||
* @deprecated (4.3) use configuration classes provided 'ch.boye.httpclientandroidlib.config'
|
||||
* and 'ch.boye.httpclientandroidlib.client.config'
|
||||
*/
|
||||
@Deprecated
|
||||
void setParams(HttpParams params);
|
||||
|
||||
}
|
||||
|
|
|
@ -83,12 +83,6 @@ public interface HttpResponse extends HttpMessage {
|
|||
|
||||
/**
|
||||
* Updates the status line of this response with a new status code.
|
||||
* The status line can only be updated if it is available. It must
|
||||
* have been set either explicitly or in a constructor.
|
||||
* <br/>
|
||||
* The reason phrase will be updated according to the new status code,
|
||||
* based on the current {@link #getLocale locale}. It can be set
|
||||
* explicitly using {@link #setReasonPhrase setReasonPhrase}.
|
||||
*
|
||||
* @param code the HTTP status code.
|
||||
*
|
||||
|
@ -104,8 +98,6 @@ public interface HttpResponse extends HttpMessage {
|
|||
|
||||
/**
|
||||
* Updates the status line of this response with a new reason phrase.
|
||||
* The status line can only be updated if it is available. It must
|
||||
* have been set either explicitly or in a constructor.
|
||||
*
|
||||
* @param reason the new reason phrase as a single-line string, or
|
||||
* <code>null</code> to unset the reason phrase
|
||||
|
@ -130,9 +122,16 @@ public interface HttpResponse extends HttpMessage {
|
|||
|
||||
/**
|
||||
* Associates a response entity with this response.
|
||||
* <p/>
|
||||
* Please note that if an entity has already been set for this response and it depends on
|
||||
* an input stream ({@link HttpEntity#isStreaming()} returns <code>true</code>),
|
||||
* it must be fully consumed in order to ensure release of resources.
|
||||
*
|
||||
* @param entity the entity to associate with this response, or
|
||||
* <code>null</code> to unset
|
||||
*
|
||||
* @see HttpEntity#isStreaming()
|
||||
* @see ch.boye.httpclientandroidlib.util.EntityUtils#updateEntity(HttpResponse, HttpEntity)
|
||||
*/
|
||||
void setEntity(HttpEntity entity);
|
||||
|
||||
|
@ -148,13 +147,9 @@ public interface HttpResponse extends HttpMessage {
|
|||
|
||||
/**
|
||||
* Changes the locale of this response.
|
||||
* If there is a status line, it's reason phrase will be updated
|
||||
* according to the status code and new locale.
|
||||
*
|
||||
* @param loc the new locale
|
||||
*
|
||||
* @see #getLocale getLocale
|
||||
* @see #setStatusCode setStatusCode
|
||||
*/
|
||||
void setLocale(Locale loc);
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,8 @@ package ch.boye.httpclientandroidlib;
|
|||
|
||||
import java.io.Serializable;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Represents an HTTP version. HTTP uses a "major.minor" numbering
|
||||
* scheme to indicate versions of the protocol.
|
||||
|
@ -42,6 +44,7 @@ import java.io.Serializable;
|
|||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public final class HttpVersion extends ProtocolVersion
|
||||
implements Serializable {
|
||||
|
||||
|
@ -68,7 +71,7 @@ public final class HttpVersion extends ProtocolVersion
|
|||
*
|
||||
* @throws IllegalArgumentException if either major or minor version number is negative
|
||||
*/
|
||||
public HttpVersion(int major, int minor) {
|
||||
public HttpVersion(final int major, final int minor) {
|
||||
super(HTTP, major, minor);
|
||||
}
|
||||
|
||||
|
@ -81,7 +84,8 @@ public final class HttpVersion extends ProtocolVersion
|
|||
*
|
||||
* @return an instance of {@link HttpVersion} with the argument version
|
||||
*/
|
||||
public ProtocolVersion forVersion(int major, int minor) {
|
||||
@Override
|
||||
public ProtocolVersion forVersion(final int major, final int minor) {
|
||||
|
||||
if ((major == this.major) && (minor == this.minor)) {
|
||||
return this;
|
||||
|
|
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/MessageConstraintException.java
поставляемый
Normal file
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/MessageConstraintException.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Signals a message constraint violation.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public class MessageConstraintException extends IOException {
|
||||
|
||||
private static final long serialVersionUID = 6077207720446368695L;
|
||||
|
||||
/**
|
||||
* Creates a TruncatedChunkException with the specified detail message.
|
||||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public MessageConstraintException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
|
@ -43,7 +43,7 @@ public class NoHttpResponseException extends IOException {
|
|||
*
|
||||
* @param message exception message
|
||||
*/
|
||||
public NoHttpResponseException(String message) {
|
||||
public NoHttpResponseException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ public class ParseException extends RuntimeException {
|
|||
*
|
||||
* @param message the exception detail message, or <code>null</code>
|
||||
*/
|
||||
public ParseException(String message) {
|
||||
public ParseException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
|
|
@ -50,7 +50,7 @@ public class ProtocolException extends HttpException {
|
|||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public ProtocolException(String message) {
|
||||
public ProtocolException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
@ -61,7 +61,7 @@ public class ProtocolException extends HttpException {
|
|||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public ProtocolException(String message, Throwable cause) {
|
||||
public ProtocolException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,9 @@
|
|||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.Serializable;
|
||||
import ch.boye.httpclientandroidlib.util.CharArrayBuffer;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* Represents a protocol version. The "major.minor" numbering
|
||||
|
@ -42,6 +44,7 @@ import ch.boye.httpclientandroidlib.util.CharArrayBuffer;
|
|||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class ProtocolVersion implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 8950662842175091068L;
|
||||
|
@ -64,22 +67,10 @@ public class ProtocolVersion implements Serializable, Cloneable {
|
|||
* @param major the major version number of the protocol
|
||||
* @param minor the minor version number of the protocol
|
||||
*/
|
||||
public ProtocolVersion(String protocol, int major, int minor) {
|
||||
if (protocol == null) {
|
||||
throw new IllegalArgumentException
|
||||
("Protocol name must not be null.");
|
||||
}
|
||||
if (major < 0) {
|
||||
throw new IllegalArgumentException
|
||||
("Protocol major version number must not be negative.");
|
||||
}
|
||||
if (minor < 0) {
|
||||
throw new IllegalArgumentException
|
||||
("Protocol minor version number may not be negative");
|
||||
}
|
||||
this.protocol = protocol;
|
||||
this.major = major;
|
||||
this.minor = minor;
|
||||
public ProtocolVersion(final String protocol, final int major, final int minor) {
|
||||
this.protocol = Args.notNull(protocol, "Protocol name");
|
||||
this.major = Args.notNegative(major, "Protocol minor version");
|
||||
this.minor = Args.notNegative(minor, "Protocol minor version");
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -125,7 +116,7 @@ public class ProtocolVersion implements Serializable, Cloneable {
|
|||
* @return a protocol version with the same protocol name
|
||||
* and the argument version
|
||||
*/
|
||||
public ProtocolVersion forVersion(int major, int minor) {
|
||||
public ProtocolVersion forVersion(final int major, final int minor) {
|
||||
|
||||
if ((major == this.major) && (minor == this.minor)) {
|
||||
return this;
|
||||
|
@ -141,6 +132,7 @@ public class ProtocolVersion implements Serializable, Cloneable {
|
|||
*
|
||||
* @return the hashcode of this protocol version
|
||||
*/
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return this.protocol.hashCode() ^ (this.major * 100000) ^ this.minor;
|
||||
}
|
||||
|
@ -159,14 +151,15 @@ public class ProtocolVersion implements Serializable, Cloneable {
|
|||
* @return <code>true</code> if the argument is the same protocol version,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public final boolean equals(Object obj) {
|
||||
@Override
|
||||
public final boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ProtocolVersion)) {
|
||||
return false;
|
||||
}
|
||||
ProtocolVersion that = (ProtocolVersion) obj;
|
||||
final ProtocolVersion that = (ProtocolVersion) obj;
|
||||
|
||||
return ((this.protocol.equals(that.protocol)) &&
|
||||
(this.major == that.major) &&
|
||||
|
@ -184,7 +177,7 @@ public class ProtocolVersion implements Serializable, Cloneable {
|
|||
* @return <code>true</code> if {@link #compareToVersion compareToVersion}
|
||||
* can be called with the argument, <code>false</code> otherwise
|
||||
*/
|
||||
public boolean isComparable(ProtocolVersion that) {
|
||||
public boolean isComparable(final ProtocolVersion that) {
|
||||
return (that != null) && this.protocol.equals(that.protocol);
|
||||
}
|
||||
|
||||
|
@ -195,7 +188,7 @@ public class ProtocolVersion implements Serializable, Cloneable {
|
|||
* This method does <i>not</i> define a total ordering, as it would be
|
||||
* required for {@link java.lang.Comparable}.
|
||||
*
|
||||
* @param that the protocl version to compare with
|
||||
* @param that the protocol version to compare with
|
||||
*
|
||||
* @return a negative integer, zero, or a positive integer
|
||||
* as this version is less than, equal to, or greater than
|
||||
|
@ -205,17 +198,10 @@ public class ProtocolVersion implements Serializable, Cloneable {
|
|||
* if the argument has a different protocol name than this object,
|
||||
* or if the argument is <code>null</code>
|
||||
*/
|
||||
public int compareToVersion(ProtocolVersion that) {
|
||||
if (that == null) {
|
||||
throw new IllegalArgumentException
|
||||
("Protocol version must not be null.");
|
||||
}
|
||||
if (!this.protocol.equals(that.protocol)) {
|
||||
throw new IllegalArgumentException
|
||||
("Versions for different protocols cannot be compared. " +
|
||||
this + " " + that);
|
||||
}
|
||||
|
||||
public int compareToVersion(final ProtocolVersion that) {
|
||||
Args.notNull(that, "Protocol version");
|
||||
Args.check(this.protocol.equals(that.protocol),
|
||||
"Versions for different protocols cannot be compared: %s %s", this, that);
|
||||
int delta = getMajor() - that.getMajor();
|
||||
if (delta == 0) {
|
||||
delta = getMinor() - that.getMinor();
|
||||
|
@ -234,7 +220,7 @@ public class ProtocolVersion implements Serializable, Cloneable {
|
|||
* and {@link #compareToVersion compares} as greater or equal,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public final boolean greaterEquals(ProtocolVersion version) {
|
||||
public final boolean greaterEquals(final ProtocolVersion version) {
|
||||
return isComparable(version) && (compareToVersion(version) >= 0);
|
||||
}
|
||||
|
||||
|
@ -249,7 +235,7 @@ public class ProtocolVersion implements Serializable, Cloneable {
|
|||
* and {@link #compareToVersion compares} as less or equal,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public final boolean lessEquals(ProtocolVersion version) {
|
||||
public final boolean lessEquals(final ProtocolVersion version) {
|
||||
return isComparable(version) && (compareToVersion(version) <= 0);
|
||||
}
|
||||
|
||||
|
@ -259,8 +245,9 @@ public class ProtocolVersion implements Serializable, Cloneable {
|
|||
*
|
||||
* @return a protocol version string, like "HTTP/1.1"
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
CharArrayBuffer buffer = new CharArrayBuffer(16);
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buffer.append(this.protocol);
|
||||
buffer.append('/');
|
||||
buffer.append(Integer.toString(this.major));
|
||||
|
@ -269,6 +256,7 @@ public class ProtocolVersion implements Serializable, Cloneable {
|
|||
return buffer.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
|
|
@ -46,6 +46,6 @@ public interface ReasonPhraseCatalog {
|
|||
*
|
||||
* @return the reason phrase, or <code>null</code> if unknown
|
||||
*/
|
||||
public String getReason(int status, Locale loc);
|
||||
String getReason(int status, Locale loc);
|
||||
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ import java.util.Iterator;
|
|||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface TokenIterator extends Iterator {
|
||||
public interface TokenIterator extends Iterator<Object> {
|
||||
|
||||
/**
|
||||
* Indicates whether there is another token in this iteration.
|
||||
|
|
|
@ -27,7 +27,6 @@
|
|||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import ch.boye.httpclientandroidlib.ProtocolException;
|
||||
|
||||
/**
|
||||
* Signals an unsupported version of the HTTP protocol.
|
||||
|
|
741
mobile/android/thirdparty/ch/boye/httpclientandroidlib/androidextra/Base64.java
поставляемый
Normal file
741
mobile/android/thirdparty/ch/boye/httpclientandroidlib/androidextra/Base64.java
поставляемый
Normal file
|
@ -0,0 +1,741 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed 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.
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.androidextra;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* Utilities for encoding and decoding the Base64 representation of
|
||||
* binary data. See RFCs <a
|
||||
* href="http://www.ietf.org/rfc/rfc2045.txt">2045</a> and <a
|
||||
* href="http://www.ietf.org/rfc/rfc3548.txt">3548</a>.
|
||||
*/
|
||||
public class Base64 {
|
||||
/**
|
||||
* Default values for encoder/decoder flags.
|
||||
*/
|
||||
public static final int DEFAULT = 0;
|
||||
|
||||
/**
|
||||
* Encoder flag bit to omit the padding '=' characters at the end
|
||||
* of the output (if any).
|
||||
*/
|
||||
public static final int NO_PADDING = 1;
|
||||
|
||||
/**
|
||||
* Encoder flag bit to omit all line terminators (i.e., the output
|
||||
* will be on one long line).
|
||||
*/
|
||||
public static final int NO_WRAP = 2;
|
||||
|
||||
/**
|
||||
* Encoder flag bit to indicate lines should be terminated with a
|
||||
* CRLF pair instead of just an LF. Has no effect if {@code
|
||||
* NO_WRAP} is specified as well.
|
||||
*/
|
||||
public static final int CRLF = 4;
|
||||
|
||||
/**
|
||||
* Encoder/decoder flag bit to indicate using the "URL and
|
||||
* filename safe" variant of Base64 (see RFC 3548 section 4) where
|
||||
* {@code -} and {@code _} are used in place of {@code +} and
|
||||
* {@code /}.
|
||||
*/
|
||||
public static final int URL_SAFE = 8;
|
||||
|
||||
/**
|
||||
* Flag to pass to {@link Base64OutputStream} to indicate that it
|
||||
* should not close the output stream it is wrapping when it
|
||||
* itself is closed.
|
||||
*/
|
||||
public static final int NO_CLOSE = 16;
|
||||
|
||||
// --------------------------------------------------------
|
||||
// shared code
|
||||
// --------------------------------------------------------
|
||||
|
||||
/* package */ static abstract class Coder {
|
||||
public byte[] output;
|
||||
public int op;
|
||||
|
||||
/**
|
||||
* Encode/decode another block of input data. this.output is
|
||||
* provided by the caller, and must be big enough to hold all
|
||||
* the coded data. On exit, this.opwill be set to the length
|
||||
* of the coded data.
|
||||
*
|
||||
* @param finish true if this is the final call to process for
|
||||
* this object. Will finalize the coder state and
|
||||
* include any final bytes in the output.
|
||||
*
|
||||
* @return true if the input so far is good; false if some
|
||||
* error has been detected in the input stream..
|
||||
*/
|
||||
public abstract boolean process(byte[] input, int offset, int len, boolean finish);
|
||||
|
||||
/**
|
||||
* @return the maximum number of bytes a call to process()
|
||||
* could produce for the given number of input bytes. This may
|
||||
* be an overestimate.
|
||||
*/
|
||||
public abstract int maxOutputSize(int len);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// decoding
|
||||
// --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Decode the Base64-encoded data in input and return the data in
|
||||
* a new byte array.
|
||||
*
|
||||
* <p>The padding '=' characters at the end are considered optional, but
|
||||
* if any are present, there must be the correct number of them.
|
||||
*
|
||||
* @param str the input String to decode, which is converted to
|
||||
* bytes using the default charset
|
||||
* @param flags controls certain features of the decoded output.
|
||||
* Pass {@code DEFAULT} to decode standard Base64.
|
||||
*
|
||||
* @throws IllegalArgumentException if the input contains
|
||||
* incorrect padding
|
||||
*/
|
||||
public static byte[] decode(String str, int flags) {
|
||||
return decode(str.getBytes(), flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode the Base64-encoded data in input and return the data in
|
||||
* a new byte array.
|
||||
*
|
||||
* <p>The padding '=' characters at the end are considered optional, but
|
||||
* if any are present, there must be the correct number of them.
|
||||
*
|
||||
* @param input the input array to decode
|
||||
* @param flags controls certain features of the decoded output.
|
||||
* Pass {@code DEFAULT} to decode standard Base64.
|
||||
*
|
||||
* @throws IllegalArgumentException if the input contains
|
||||
* incorrect padding
|
||||
*/
|
||||
public static byte[] decode(byte[] input, int flags) {
|
||||
return decode(input, 0, input.length, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode the Base64-encoded data in input and return the data in
|
||||
* a new byte array.
|
||||
*
|
||||
* <p>The padding '=' characters at the end are considered optional, but
|
||||
* if any are present, there must be the correct number of them.
|
||||
*
|
||||
* @param input the data to decode
|
||||
* @param offset the position within the input array at which to start
|
||||
* @param len the number of bytes of input to decode
|
||||
* @param flags controls certain features of the decoded output.
|
||||
* Pass {@code DEFAULT} to decode standard Base64.
|
||||
*
|
||||
* @throws IllegalArgumentException if the input contains
|
||||
* incorrect padding
|
||||
*/
|
||||
public static byte[] decode(byte[] input, int offset, int len, int flags) {
|
||||
// Allocate space for the most data the input could represent.
|
||||
// (It could contain less if it contains whitespace, etc.)
|
||||
Decoder decoder = new Decoder(flags, new byte[len*3/4]);
|
||||
|
||||
if (!decoder.process(input, offset, len, true)) {
|
||||
throw new IllegalArgumentException("bad base-64");
|
||||
}
|
||||
|
||||
// Maybe we got lucky and allocated exactly enough output space.
|
||||
if (decoder.op == decoder.output.length) {
|
||||
return decoder.output;
|
||||
}
|
||||
|
||||
// Need to shorten the array, so allocate a new one of the
|
||||
// right size and copy.
|
||||
byte[] temp = new byte[decoder.op];
|
||||
System.arraycopy(decoder.output, 0, temp, 0, decoder.op);
|
||||
return temp;
|
||||
}
|
||||
|
||||
/* package */ static class Decoder extends Coder {
|
||||
/**
|
||||
* Lookup table for turning bytes into their position in the
|
||||
* Base64 alphabet.
|
||||
*/
|
||||
private static final int DECODE[] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1,
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
|
||||
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode lookup table for the "web safe" variant (RFC 3548
|
||||
* sec. 4) where - and _ replace + and /.
|
||||
*/
|
||||
private static final int DECODE_WEBSAFE[] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1,
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63,
|
||||
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
};
|
||||
|
||||
/** Non-data values in the DECODE arrays. */
|
||||
private static final int SKIP = -1;
|
||||
private static final int EQUALS = -2;
|
||||
|
||||
/**
|
||||
* States 0-3 are reading through the next input tuple.
|
||||
* State 4 is having read one '=' and expecting exactly
|
||||
* one more.
|
||||
* State 5 is expecting no more data or padding characters
|
||||
* in the input.
|
||||
* State 6 is the error state; an error has been detected
|
||||
* in the input and no future input can "fix" it.
|
||||
*/
|
||||
private int state; // state number (0 to 6)
|
||||
private int value;
|
||||
|
||||
final private int[] alphabet;
|
||||
|
||||
public Decoder(int flags, byte[] output) {
|
||||
this.output = output;
|
||||
|
||||
alphabet = ((flags & URL_SAFE) == 0) ? DECODE : DECODE_WEBSAFE;
|
||||
state = 0;
|
||||
value = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an overestimate for the number of bytes {@code
|
||||
* len} bytes could decode to.
|
||||
*/
|
||||
public int maxOutputSize(int len) {
|
||||
return len * 3/4 + 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode another block of input data.
|
||||
*
|
||||
* @return true if the state machine is still healthy. false if
|
||||
* bad base-64 data has been detected in the input stream.
|
||||
*/
|
||||
public boolean process(byte[] input, int offset, int len, boolean finish) {
|
||||
if (this.state == 6) return false;
|
||||
|
||||
int p = offset;
|
||||
len += offset;
|
||||
|
||||
// Using local variables makes the decoder about 12%
|
||||
// faster than if we manipulate the member variables in
|
||||
// the loop. (Even alphabet makes a measurable
|
||||
// difference, which is somewhat surprising to me since
|
||||
// the member variable is final.)
|
||||
int state = this.state;
|
||||
int value = this.value;
|
||||
int op = 0;
|
||||
final byte[] output = this.output;
|
||||
final int[] alphabet = this.alphabet;
|
||||
|
||||
while (p < len) {
|
||||
// Try the fast path: we're starting a new tuple and the
|
||||
// next four bytes of the input stream are all data
|
||||
// bytes. This corresponds to going through states
|
||||
// 0-1-2-3-0. We expect to use this method for most of
|
||||
// the data.
|
||||
//
|
||||
// If any of the next four bytes of input are non-data
|
||||
// (whitespace, etc.), value will end up negative. (All
|
||||
// the non-data values in decode are small negative
|
||||
// numbers, so shifting any of them up and or'ing them
|
||||
// together will result in a value with its top bit set.)
|
||||
//
|
||||
// You can remove this whole block and the output should
|
||||
// be the same, just slower.
|
||||
if (state == 0) {
|
||||
while (p+4 <= len &&
|
||||
(value = ((alphabet[input[p] & 0xff] << 18) |
|
||||
(alphabet[input[p+1] & 0xff] << 12) |
|
||||
(alphabet[input[p+2] & 0xff] << 6) |
|
||||
(alphabet[input[p+3] & 0xff]))) >= 0) {
|
||||
output[op+2] = (byte) value;
|
||||
output[op+1] = (byte) (value >> 8);
|
||||
output[op] = (byte) (value >> 16);
|
||||
op += 3;
|
||||
p += 4;
|
||||
}
|
||||
if (p >= len) break;
|
||||
}
|
||||
|
||||
// The fast path isn't available -- either we've read a
|
||||
// partial tuple, or the next four input bytes aren't all
|
||||
// data, or whatever. Fall back to the slower state
|
||||
// machine implementation.
|
||||
|
||||
int d = alphabet[input[p++] & 0xff];
|
||||
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (d >= 0) {
|
||||
value = d;
|
||||
++state;
|
||||
} else if (d != SKIP) {
|
||||
this.state = 6;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (d >= 0) {
|
||||
value = (value << 6) | d;
|
||||
++state;
|
||||
} else if (d != SKIP) {
|
||||
this.state = 6;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (d >= 0) {
|
||||
value = (value << 6) | d;
|
||||
++state;
|
||||
} else if (d == EQUALS) {
|
||||
// Emit the last (partial) output tuple;
|
||||
// expect exactly one more padding character.
|
||||
output[op++] = (byte) (value >> 4);
|
||||
state = 4;
|
||||
} else if (d != SKIP) {
|
||||
this.state = 6;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (d >= 0) {
|
||||
// Emit the output triple and return to state 0.
|
||||
value = (value << 6) | d;
|
||||
output[op+2] = (byte) value;
|
||||
output[op+1] = (byte) (value >> 8);
|
||||
output[op] = (byte) (value >> 16);
|
||||
op += 3;
|
||||
state = 0;
|
||||
} else if (d == EQUALS) {
|
||||
// Emit the last (partial) output tuple;
|
||||
// expect no further data or padding characters.
|
||||
output[op+1] = (byte) (value >> 2);
|
||||
output[op] = (byte) (value >> 10);
|
||||
op += 2;
|
||||
state = 5;
|
||||
} else if (d != SKIP) {
|
||||
this.state = 6;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (d == EQUALS) {
|
||||
++state;
|
||||
} else if (d != SKIP) {
|
||||
this.state = 6;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if (d != SKIP) {
|
||||
this.state = 6;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!finish) {
|
||||
// We're out of input, but a future call could provide
|
||||
// more.
|
||||
this.state = state;
|
||||
this.value = value;
|
||||
this.op = op;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Done reading input. Now figure out where we are left in
|
||||
// the state machine and finish up.
|
||||
|
||||
switch (state) {
|
||||
case 0:
|
||||
// Output length is a multiple of three. Fine.
|
||||
break;
|
||||
case 1:
|
||||
// Read one extra input byte, which isn't enough to
|
||||
// make another output byte. Illegal.
|
||||
this.state = 6;
|
||||
return false;
|
||||
case 2:
|
||||
// Read two extra input bytes, enough to emit 1 more
|
||||
// output byte. Fine.
|
||||
output[op++] = (byte) (value >> 4);
|
||||
break;
|
||||
case 3:
|
||||
// Read three extra input bytes, enough to emit 2 more
|
||||
// output bytes. Fine.
|
||||
output[op++] = (byte) (value >> 10);
|
||||
output[op++] = (byte) (value >> 2);
|
||||
break;
|
||||
case 4:
|
||||
// Read one padding '=' when we expected 2. Illegal.
|
||||
this.state = 6;
|
||||
return false;
|
||||
case 5:
|
||||
// Read all the padding '='s we expected and no more.
|
||||
// Fine.
|
||||
break;
|
||||
}
|
||||
|
||||
this.state = state;
|
||||
this.op = op;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// encoding
|
||||
// --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Base64-encode the given data and return a newly allocated
|
||||
* String with the result.
|
||||
*
|
||||
* @param input the data to encode
|
||||
* @param flags controls certain features of the encoded output.
|
||||
* Passing {@code DEFAULT} results in output that
|
||||
* adheres to RFC 2045.
|
||||
*/
|
||||
public static String encodeToString(byte[] input, int flags) {
|
||||
try {
|
||||
return new String(encode(input, flags), "US-ASCII");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// US-ASCII is guaranteed to be available.
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encode the given data and return a newly allocated
|
||||
* String with the result.
|
||||
*
|
||||
* @param input the data to encode
|
||||
* @param offset the position within the input array at which to
|
||||
* start
|
||||
* @param len the number of bytes of input to encode
|
||||
* @param flags controls certain features of the encoded output.
|
||||
* Passing {@code DEFAULT} results in output that
|
||||
* adheres to RFC 2045.
|
||||
*/
|
||||
public static String encodeToString(byte[] input, int offset, int len, int flags) {
|
||||
try {
|
||||
return new String(encode(input, offset, len, flags), "US-ASCII");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// US-ASCII is guaranteed to be available.
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encode the given data and return a newly allocated
|
||||
* byte[] with the result.
|
||||
*
|
||||
* @param input the data to encode
|
||||
* @param flags controls certain features of the encoded output.
|
||||
* Passing {@code DEFAULT} results in output that
|
||||
* adheres to RFC 2045.
|
||||
*/
|
||||
public static byte[] encode(byte[] input, int flags) {
|
||||
return encode(input, 0, input.length, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encode the given data and return a newly allocated
|
||||
* byte[] with the result.
|
||||
*
|
||||
* @param input the data to encode
|
||||
* @param offset the position within the input array at which to
|
||||
* start
|
||||
* @param len the number of bytes of input to encode
|
||||
* @param flags controls certain features of the encoded output.
|
||||
* Passing {@code DEFAULT} results in output that
|
||||
* adheres to RFC 2045.
|
||||
*/
|
||||
public static byte[] encode(byte[] input, int offset, int len, int flags) {
|
||||
Encoder encoder = new Encoder(flags, null);
|
||||
|
||||
// Compute the exact length of the array we will produce.
|
||||
int output_len = len / 3 * 4;
|
||||
|
||||
// Account for the tail of the data and the padding bytes, if any.
|
||||
if (encoder.do_padding) {
|
||||
if (len % 3 > 0) {
|
||||
output_len += 4;
|
||||
}
|
||||
} else {
|
||||
switch (len % 3) {
|
||||
case 0: break;
|
||||
case 1: output_len += 2; break;
|
||||
case 2: output_len += 3; break;
|
||||
}
|
||||
}
|
||||
|
||||
// Account for the newlines, if any.
|
||||
if (encoder.do_newline && len > 0) {
|
||||
output_len += (((len-1) / (3 * Encoder.LINE_GROUPS)) + 1) *
|
||||
(encoder.do_cr ? 2 : 1);
|
||||
}
|
||||
|
||||
encoder.output = new byte[output_len];
|
||||
encoder.process(input, offset, len, true);
|
||||
|
||||
assert encoder.op == output_len;
|
||||
|
||||
return encoder.output;
|
||||
}
|
||||
|
||||
/* package */ static class Encoder extends Coder {
|
||||
/**
|
||||
* Emit a new line every this many output tuples. Corresponds to
|
||||
* a 76-character line length (the maximum allowable according to
|
||||
* <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>).
|
||||
*/
|
||||
public static final int LINE_GROUPS = 19;
|
||||
|
||||
/**
|
||||
* Lookup table for turning Base64 alphabet positions (6 bits)
|
||||
* into output bytes.
|
||||
*/
|
||||
private static final byte ENCODE[] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/',
|
||||
};
|
||||
|
||||
/**
|
||||
* Lookup table for turning Base64 alphabet positions (6 bits)
|
||||
* into output bytes.
|
||||
*/
|
||||
private static final byte ENCODE_WEBSAFE[] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_',
|
||||
};
|
||||
|
||||
final private byte[] tail;
|
||||
/* package */ int tailLen;
|
||||
private int count;
|
||||
|
||||
final public boolean do_padding;
|
||||
final public boolean do_newline;
|
||||
final public boolean do_cr;
|
||||
final private byte[] alphabet;
|
||||
|
||||
public Encoder(int flags, byte[] output) {
|
||||
this.output = output;
|
||||
|
||||
do_padding = (flags & NO_PADDING) == 0;
|
||||
do_newline = (flags & NO_WRAP) == 0;
|
||||
do_cr = (flags & CRLF) != 0;
|
||||
alphabet = ((flags & URL_SAFE) == 0) ? ENCODE : ENCODE_WEBSAFE;
|
||||
|
||||
tail = new byte[2];
|
||||
tailLen = 0;
|
||||
|
||||
count = do_newline ? LINE_GROUPS : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an overestimate for the number of bytes {@code
|
||||
* len} bytes could encode to.
|
||||
*/
|
||||
public int maxOutputSize(int len) {
|
||||
return len * 8/5 + 10;
|
||||
}
|
||||
|
||||
public boolean process(byte[] input, int offset, int len, boolean finish) {
|
||||
// Using local variables makes the encoder about 9% faster.
|
||||
final byte[] alphabet = this.alphabet;
|
||||
final byte[] output = this.output;
|
||||
int op = 0;
|
||||
int count = this.count;
|
||||
|
||||
int p = offset;
|
||||
len += offset;
|
||||
int v = -1;
|
||||
|
||||
// First we need to concatenate the tail of the previous call
|
||||
// with any input bytes available now and see if we can empty
|
||||
// the tail.
|
||||
|
||||
switch (tailLen) {
|
||||
case 0:
|
||||
// There was no tail.
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (p+2 <= len) {
|
||||
// A 1-byte tail with at least 2 bytes of
|
||||
// input available now.
|
||||
v = ((tail[0] & 0xff) << 16) |
|
||||
((input[p++] & 0xff) << 8) |
|
||||
(input[p++] & 0xff);
|
||||
tailLen = 0;
|
||||
};
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (p+1 <= len) {
|
||||
// A 2-byte tail with at least 1 byte of input.
|
||||
v = ((tail[0] & 0xff) << 16) |
|
||||
((tail[1] & 0xff) << 8) |
|
||||
(input[p++] & 0xff);
|
||||
tailLen = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (v != -1) {
|
||||
output[op++] = alphabet[(v >> 18) & 0x3f];
|
||||
output[op++] = alphabet[(v >> 12) & 0x3f];
|
||||
output[op++] = alphabet[(v >> 6) & 0x3f];
|
||||
output[op++] = alphabet[v & 0x3f];
|
||||
if (--count == 0) {
|
||||
if (do_cr) output[op++] = '\r';
|
||||
output[op++] = '\n';
|
||||
count = LINE_GROUPS;
|
||||
}
|
||||
}
|
||||
|
||||
// At this point either there is no tail, or there are fewer
|
||||
// than 3 bytes of input available.
|
||||
|
||||
// The main loop, turning 3 input bytes into 4 output bytes on
|
||||
// each iteration.
|
||||
while (p+3 <= len) {
|
||||
v = ((input[p] & 0xff) << 16) |
|
||||
((input[p+1] & 0xff) << 8) |
|
||||
(input[p+2] & 0xff);
|
||||
output[op] = alphabet[(v >> 18) & 0x3f];
|
||||
output[op+1] = alphabet[(v >> 12) & 0x3f];
|
||||
output[op+2] = alphabet[(v >> 6) & 0x3f];
|
||||
output[op+3] = alphabet[v & 0x3f];
|
||||
p += 3;
|
||||
op += 4;
|
||||
if (--count == 0) {
|
||||
if (do_cr) output[op++] = '\r';
|
||||
output[op++] = '\n';
|
||||
count = LINE_GROUPS;
|
||||
}
|
||||
}
|
||||
|
||||
if (finish) {
|
||||
// Finish up the tail of the input. Note that we need to
|
||||
// consume any bytes in tail before any bytes
|
||||
// remaining in input; there should be at most two bytes
|
||||
// total.
|
||||
|
||||
if (p-tailLen == len-1) {
|
||||
int t = 0;
|
||||
v = ((tailLen > 0 ? tail[t++] : input[p++]) & 0xff) << 4;
|
||||
tailLen -= t;
|
||||
output[op++] = alphabet[(v >> 6) & 0x3f];
|
||||
output[op++] = alphabet[v & 0x3f];
|
||||
if (do_padding) {
|
||||
output[op++] = '=';
|
||||
output[op++] = '=';
|
||||
}
|
||||
if (do_newline) {
|
||||
if (do_cr) output[op++] = '\r';
|
||||
output[op++] = '\n';
|
||||
}
|
||||
} else if (p-tailLen == len-2) {
|
||||
int t = 0;
|
||||
v = (((tailLen > 1 ? tail[t++] : input[p++]) & 0xff) << 10) |
|
||||
(((tailLen > 0 ? tail[t++] : input[p++]) & 0xff) << 2);
|
||||
tailLen -= t;
|
||||
output[op++] = alphabet[(v >> 12) & 0x3f];
|
||||
output[op++] = alphabet[(v >> 6) & 0x3f];
|
||||
output[op++] = alphabet[v & 0x3f];
|
||||
if (do_padding) {
|
||||
output[op++] = '=';
|
||||
}
|
||||
if (do_newline) {
|
||||
if (do_cr) output[op++] = '\r';
|
||||
output[op++] = '\n';
|
||||
}
|
||||
} else if (do_newline && op > 0 && count != LINE_GROUPS) {
|
||||
if (do_cr) output[op++] = '\r';
|
||||
output[op++] = '\n';
|
||||
}
|
||||
|
||||
assert tailLen == 0;
|
||||
assert p == len;
|
||||
} else {
|
||||
// Save the leftovers in tail to be consumed on the next
|
||||
// call to encodeInternal.
|
||||
|
||||
if (p == len-1) {
|
||||
tail[tailLen++] = input[p];
|
||||
} else if (p == len-2) {
|
||||
tail[tailLen++] = input[p];
|
||||
tail[tailLen++] = input[p+1];
|
||||
}
|
||||
}
|
||||
|
||||
this.op = op;
|
||||
this.count = count;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private Base64() { } // don't instantiate
|
||||
}
|
|
@ -7,6 +7,7 @@ public class HttpClientAndroidLog {
|
|||
private String logTag;
|
||||
private boolean debugEnabled;
|
||||
private boolean errorEnabled;
|
||||
private boolean traceEnabled;
|
||||
private boolean warnEnabled;
|
||||
private boolean infoEnabled;
|
||||
|
||||
|
@ -14,6 +15,7 @@ public class HttpClientAndroidLog {
|
|||
logTag=tag.toString();
|
||||
debugEnabled=false;
|
||||
errorEnabled=false;
|
||||
traceEnabled=false;
|
||||
warnEnabled=false;
|
||||
infoEnabled=false;
|
||||
}
|
||||
|
@ -27,10 +29,12 @@ public class HttpClientAndroidLog {
|
|||
}
|
||||
|
||||
public void debug(Object message) {
|
||||
if(isDebugEnabled())
|
||||
Log.d(logTag, message.toString());
|
||||
}
|
||||
|
||||
public void debug(Object message, Throwable t) {
|
||||
if(isDebugEnabled())
|
||||
Log.d(logTag, message.toString(), t);
|
||||
}
|
||||
|
||||
|
@ -43,10 +47,12 @@ public class HttpClientAndroidLog {
|
|||
}
|
||||
|
||||
public void error(Object message) {
|
||||
if(isErrorEnabled())
|
||||
Log.e(logTag, message.toString());
|
||||
}
|
||||
|
||||
public void error(Object message, Throwable t) {
|
||||
if(isErrorEnabled())
|
||||
Log.e(logTag, message.toString(), t);
|
||||
}
|
||||
|
||||
|
@ -59,10 +65,12 @@ public class HttpClientAndroidLog {
|
|||
}
|
||||
|
||||
public void warn(Object message) {
|
||||
if(isWarnEnabled())
|
||||
Log.w(logTag, message.toString());
|
||||
}
|
||||
|
||||
public void warn(Object message, Throwable t) {
|
||||
if(isWarnEnabled())
|
||||
Log.w(logTag, message.toString(), t);
|
||||
}
|
||||
|
||||
|
@ -75,10 +83,30 @@ public class HttpClientAndroidLog {
|
|||
}
|
||||
|
||||
public void info(Object message) {
|
||||
if(isInfoEnabled())
|
||||
Log.i(logTag, message.toString());
|
||||
}
|
||||
|
||||
public void info(Object message, Throwable t) {
|
||||
if(isInfoEnabled())
|
||||
Log.i(logTag, message.toString(), t);
|
||||
}
|
||||
|
||||
public void enableTrace(boolean enable) {
|
||||
traceEnabled=enable;
|
||||
}
|
||||
|
||||
public boolean isTraceEnabled() {
|
||||
return traceEnabled;
|
||||
}
|
||||
|
||||
public void trace(Object message) {
|
||||
if(isTraceEnabled())
|
||||
Log.i(logTag, message.toString());
|
||||
}
|
||||
|
||||
public void trace(Object message, Throwable t) {
|
||||
if(isTraceEnabled())
|
||||
Log.i(logTag, message.toString(), t);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
|
34
mobile/android/thirdparty/ch/boye/httpclientandroidlib/annotation/package-info.java
поставляемый
Normal file
34
mobile/android/thirdparty/ch/boye/httpclientandroidlib/annotation/package-info.java
поставляемый
Normal file
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Thread-safety annotations based on JCIP-ANNOTATIONS
|
||||
* <br/>
|
||||
* Copyright (c) 2005 Brian Goetz and Tim Peierls.
|
||||
* See http://www.jcip.net
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.annotation;
|
63
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthOption.java
поставляемый
Normal file
63
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthOption.java
поставляемый
Normal file
|
@ -0,0 +1,63 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
*/
|
||||
@Immutable
|
||||
public final class AuthOption {
|
||||
|
||||
private final AuthScheme authScheme;
|
||||
private final Credentials creds;
|
||||
|
||||
public AuthOption(final AuthScheme authScheme, final Credentials creds) {
|
||||
super();
|
||||
Args.notNull(authScheme, "Auth scheme");
|
||||
Args.notNull(creds, "User credentials");
|
||||
this.authScheme = authScheme;
|
||||
this.creds = creds;
|
||||
}
|
||||
|
||||
public AuthScheme getAuthScheme() {
|
||||
return this.authScheme;
|
||||
}
|
||||
|
||||
public Credentials getCredentials() {
|
||||
return this.creds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.authScheme.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,3 @@
|
|||
<html>
|
||||
<head>
|
||||
<!--
|
||||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -27,10 +24,10 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
Additional HTTP entity implementations that depend on HttpClient
|
||||
specific features.
|
||||
</body>
|
||||
</html>
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
public enum AuthProtocolState {
|
||||
|
||||
UNCHALLENGED, CHALLENGED, HANDSHAKE, FAILURE, SUCCESS
|
||||
|
||||
}
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.Header;
|
||||
|
@ -121,7 +121,7 @@ public interface AuthScheme {
|
|||
*
|
||||
* @return the authorization string
|
||||
*
|
||||
* @deprecated Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, ch.boye.httpclientandroidlib.protocol.HttpContext)}
|
||||
* @deprecated (4.1) Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, ch.boye.httpclientandroidlib.protocol.HttpContext)}
|
||||
*/
|
||||
@Deprecated
|
||||
Header authenticate(Credentials credentials, HttpRequest request)
|
||||
|
|
|
@ -33,7 +33,10 @@ import ch.boye.httpclientandroidlib.params.HttpParams;
|
|||
* Factory for {@link AuthScheme} implementations.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.3) use {@link AuthSchemeProvider}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AuthSchemeFactory {
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
<html>
|
||||
<head>
|
||||
<!--
|
||||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -27,17 +24,23 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
A selection of HTTP message implementations.
|
||||
|
||||
There are basic implementations for HTTP requests
|
||||
{@link org.apache.http.message.BasicHttpEntityEnclosingRequest with}
|
||||
and {@link org.apache.http.message.BasicHttpRequest without}
|
||||
an entity, and for
|
||||
{@link org.apache.http.message.BasicHttpResponse responses}.
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
</body>
|
||||
</html>
|
||||
/**
|
||||
* Factory for {@link AuthScheme} implementations.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public interface AuthSchemeProvider {
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link AuthScheme}.
|
||||
*
|
||||
* @return auth scheme.
|
||||
*/
|
||||
AuthScheme create(HttpContext context);
|
||||
|
||||
}
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
@ -32,18 +32,25 @@ import java.util.Locale;
|
|||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpRequest;
|
||||
import ch.boye.httpclientandroidlib.annotation.ThreadSafe;
|
||||
|
||||
import ch.boye.httpclientandroidlib.config.Lookup;
|
||||
import ch.boye.httpclientandroidlib.params.HttpParams;
|
||||
import ch.boye.httpclientandroidlib.protocol.ExecutionContext;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* Authentication scheme registry that can be used to obtain the corresponding
|
||||
* authentication scheme implementation for a given type of authorization challenge.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.3) use {@link ch.boye.httpclientandroidlib.config.Registry}
|
||||
*/
|
||||
@ThreadSafe
|
||||
public final class AuthSchemeRegistry {
|
||||
@Deprecated
|
||||
public final class AuthSchemeRegistry implements Lookup<AuthSchemeProvider> {
|
||||
|
||||
private final ConcurrentHashMap<String,AuthSchemeFactory> registeredSchemes;
|
||||
|
||||
|
@ -70,12 +77,8 @@ public final class AuthSchemeRegistry {
|
|||
public void register(
|
||||
final String name,
|
||||
final AuthSchemeFactory factory) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Name may not be null");
|
||||
}
|
||||
if (factory == null) {
|
||||
throw new IllegalArgumentException("Authentication scheme factory may not be null");
|
||||
}
|
||||
Args.notNull(name, "Name");
|
||||
Args.notNull(factory, "Authentication scheme factory");
|
||||
registeredSchemes.put(name.toLowerCase(Locale.ENGLISH), factory);
|
||||
}
|
||||
|
||||
|
@ -86,9 +89,7 @@ public final class AuthSchemeRegistry {
|
|||
* @param name the identifier of the class to unregister
|
||||
*/
|
||||
public void unregister(final String name) {
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Name may not be null");
|
||||
}
|
||||
Args.notNull(name, "Name");
|
||||
registeredSchemes.remove(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
|
@ -106,10 +107,8 @@ public final class AuthSchemeRegistry {
|
|||
public AuthScheme getAuthScheme(final String name, final HttpParams params)
|
||||
throws IllegalStateException {
|
||||
|
||||
if (name == null) {
|
||||
throw new IllegalArgumentException("Name may not be null");
|
||||
}
|
||||
AuthSchemeFactory factory = registeredSchemes.get(name.toLowerCase(Locale.ENGLISH));
|
||||
Args.notNull(name, "Name");
|
||||
final AuthSchemeFactory factory = registeredSchemes.get(name.toLowerCase(Locale.ENGLISH));
|
||||
if (factory != null) {
|
||||
return factory.newInstance(params);
|
||||
} else {
|
||||
|
@ -141,4 +140,16 @@ public final class AuthSchemeRegistry {
|
|||
registeredSchemes.putAll(map);
|
||||
}
|
||||
|
||||
public AuthSchemeProvider lookup(final String name) {
|
||||
return new AuthSchemeProvider() {
|
||||
|
||||
public AuthScheme create(final HttpContext context) {
|
||||
final HttpRequest request = (HttpRequest) context.getAttribute(
|
||||
ExecutionContext.HTTP_REQUEST);
|
||||
return getAuthScheme(name, request.getParams());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,13 +24,13 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpHost;
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
import ch.boye.httpclientandroidlib.util.LangUtils;
|
||||
|
||||
/**
|
||||
|
@ -100,7 +101,7 @@ public class AuthScope {
|
|||
* May be set to <tt>null</tt> if credentials are applicable to
|
||||
* any authentication scheme.
|
||||
*/
|
||||
public AuthScope(final String host, int port,
|
||||
public AuthScope(final String host, final int port,
|
||||
final String realm, final String scheme)
|
||||
{
|
||||
this.host = (host == null) ? ANY_HOST: host.toLowerCase(Locale.ENGLISH);
|
||||
|
@ -109,6 +110,20 @@ public class AuthScope {
|
|||
this.scheme = (scheme == null) ? ANY_SCHEME: scheme.toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
*/
|
||||
public AuthScope(final HttpHost host, final String realm, final String schemeName) {
|
||||
this(host.getHostName(), host.getPort(), realm, schemeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
*/
|
||||
public AuthScope(final HttpHost host) {
|
||||
this(host, ANY_REALM, ANY_SCHEME);
|
||||
}
|
||||
|
||||
/** Creates a new credentials scope for the given
|
||||
* <tt>host</tt>, <tt>port</tt>, <tt>realm</tt>, and any
|
||||
* authentication scheme.
|
||||
|
@ -123,7 +138,7 @@ public class AuthScope {
|
|||
* to <tt>null</tt> if credentials are applicable to
|
||||
* any realm.
|
||||
*/
|
||||
public AuthScope(final String host, int port, final String realm) {
|
||||
public AuthScope(final String host, final int port, final String realm) {
|
||||
this(host, port, realm, ANY_SCHEME);
|
||||
}
|
||||
|
||||
|
@ -138,7 +153,7 @@ public class AuthScope {
|
|||
* to negative value if credentials are applicable to
|
||||
* any port.
|
||||
*/
|
||||
public AuthScope(final String host, int port) {
|
||||
public AuthScope(final String host, final int port) {
|
||||
this(host, port, ANY_REALM, ANY_SCHEME);
|
||||
}
|
||||
|
||||
|
@ -147,9 +162,7 @@ public class AuthScope {
|
|||
*/
|
||||
public AuthScope(final AuthScope authscope) {
|
||||
super();
|
||||
if (authscope == null) {
|
||||
throw new IllegalArgumentException("Scope may not be null");
|
||||
}
|
||||
Args.notNull(authscope, "Scope");
|
||||
this.host = authscope.getHost();
|
||||
this.port = authscope.getPort();
|
||||
this.realm = authscope.getRealm();
|
||||
|
@ -228,7 +241,7 @@ public class AuthScope {
|
|||
* @see java.lang.Object#equals(Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
public boolean equals(final Object o) {
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
|
@ -238,7 +251,7 @@ public class AuthScope {
|
|||
if (!(o instanceof AuthScope)) {
|
||||
return super.equals(o);
|
||||
}
|
||||
AuthScope that = (AuthScope) o;
|
||||
final AuthScope that = (AuthScope) o;
|
||||
return
|
||||
LangUtils.equals(this.host, that.host)
|
||||
&& this.port == that.port
|
||||
|
@ -251,7 +264,7 @@ public class AuthScope {
|
|||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
if (this.scheme != null) {
|
||||
buffer.append(this.scheme.toUpperCase(Locale.ENGLISH));
|
||||
buffer.append(' ');
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,22 +24,24 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.NotThreadSafe;
|
||||
import java.util.Queue;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.NotThreadSafe;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* This class provides detailed information about the state of the
|
||||
* authentication process.
|
||||
*
|
||||
* This class provides detailed information about the state of the authentication process.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class AuthState {
|
||||
|
||||
/** Actual state of authentication protocol */
|
||||
private AuthProtocolState state;
|
||||
|
||||
/** Actual authentication scheme */
|
||||
private AuthScheme authScheme;
|
||||
|
||||
|
@ -48,23 +51,118 @@ public class AuthState {
|
|||
/** Credentials selected for authentication */
|
||||
private Credentials credentials;
|
||||
|
||||
/**
|
||||
* Default constructor.
|
||||
*
|
||||
*/
|
||||
/** Available auth options */
|
||||
private Queue<AuthOption> authOptions;
|
||||
|
||||
public AuthState() {
|
||||
super();
|
||||
this.state = AuthProtocolState.UNCHALLENGED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates the authentication state by resetting its parameters.
|
||||
* Resets the auth state.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public void invalidate() {
|
||||
public void reset() {
|
||||
this.state = AuthProtocolState.UNCHALLENGED;
|
||||
this.authOptions = null;
|
||||
this.authScheme = null;
|
||||
this.authScope = null;
|
||||
this.credentials = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
*/
|
||||
public AuthProtocolState getState() {
|
||||
return this.state;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
*/
|
||||
public void setState(final AuthProtocolState state) {
|
||||
this.state = state != null ? state : AuthProtocolState.UNCHALLENGED;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns actual {@link AuthScheme}. May be null.
|
||||
*/
|
||||
public AuthScheme getAuthScheme() {
|
||||
return this.authScheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns actual {@link Credentials}. May be null.
|
||||
*/
|
||||
public Credentials getCredentials() {
|
||||
return this.credentials;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the auth state with {@link AuthScheme} and {@link Credentials}.
|
||||
*
|
||||
* @param authScheme auth scheme. May not be null.
|
||||
* @param credentials user crednetials. May not be null.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public void update(final AuthScheme authScheme, final Credentials credentials) {
|
||||
Args.notNull(authScheme, "Auth scheme");
|
||||
Args.notNull(credentials, "Credentials");
|
||||
this.authScheme = authScheme;
|
||||
this.credentials = credentials;
|
||||
this.authOptions = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns available {@link AuthOption}s. May be null.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public Queue<AuthOption> getAuthOptions() {
|
||||
return this.authOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if {@link AuthOption}s are available, <code>false</code>
|
||||
* 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 Queue<AuthOption> authOptions) {
|
||||
Args.notEmpty(authOptions, "Queue of auth options");
|
||||
this.authOptions = authOptions;
|
||||
this.authScheme = null;
|
||||
this.credentials = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates the authentication state by resetting its parameters.
|
||||
*
|
||||
* @deprecated (4.2) use {@link #reset()}
|
||||
*/
|
||||
@Deprecated
|
||||
public void invalidate() {
|
||||
reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isValid() {
|
||||
return this.authScheme != null;
|
||||
}
|
||||
|
@ -73,50 +171,38 @@ public class AuthState {
|
|||
* Assigns the given {@link AuthScheme authentication scheme}.
|
||||
*
|
||||
* @param authScheme the {@link AuthScheme authentication scheme}
|
||||
*
|
||||
* @deprecated (4.2) use {@link #update(AuthScheme, Credentials)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAuthScheme(final AuthScheme authScheme) {
|
||||
if (authScheme == null) {
|
||||
invalidate();
|
||||
reset();
|
||||
return;
|
||||
}
|
||||
this.authScheme = authScheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link AuthScheme authentication scheme}.
|
||||
*
|
||||
* @return {@link AuthScheme authentication scheme}
|
||||
*/
|
||||
public AuthScheme getAuthScheme() {
|
||||
return this.authScheme;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns user {@link Credentials} selected for authentication if available
|
||||
*
|
||||
* @return user credentials if available, <code>null</code otherwise
|
||||
*/
|
||||
public Credentials getCredentials() {
|
||||
return this.credentials;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets user {@link Credentials} to be used for authentication
|
||||
*
|
||||
* @param credentials User credentials
|
||||
*
|
||||
* @deprecated (4.2) use {@link #update(AuthScheme, Credentials)}
|
||||
*/
|
||||
@Deprecated
|
||||
public void setCredentials(final Credentials credentials) {
|
||||
this.credentials = credentials;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns actual {@link AuthScope} if available
|
||||
*
|
||||
* @return actual authentication scope if available, <code>null</code otherwise
|
||||
*
|
||||
* @deprecated (4.2) do not use.
|
||||
*/
|
||||
@Deprecated
|
||||
public AuthScope getAuthScope() {
|
||||
return this.authScope;
|
||||
}
|
||||
|
@ -125,20 +211,24 @@ public class AuthState {
|
|||
* Sets actual {@link AuthScope}.
|
||||
*
|
||||
* @param authScope Authentication scope
|
||||
*
|
||||
* @deprecated (4.2) do not use.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAuthScope(final AuthScope authScope) {
|
||||
this.authScope = authScope;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("auth scope [");
|
||||
buffer.append(this.authScope);
|
||||
buffer.append("]; credentials set [");
|
||||
buffer.append(this.credentials != null ? "true" : "false");
|
||||
buffer.append("]");
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("state:").append(this.state).append(";");
|
||||
if (this.authScheme != null) {
|
||||
buffer.append("auth scheme:").append(this.authScheme.getSchemeName()).append(";");
|
||||
}
|
||||
if (this.credentials != null) {
|
||||
buffer.append("credentials present");
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,12 +24,10 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
import ch.boye.httpclientandroidlib.ProtocolException;
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Signals a failure in authentication process
|
||||
|
@ -53,7 +52,7 @@ public class AuthenticationException extends ProtocolException {
|
|||
*
|
||||
* @param message the exception detail message
|
||||
*/
|
||||
public AuthenticationException(String message) {
|
||||
public AuthenticationException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
@ -64,7 +63,7 @@ public class AuthenticationException extends ProtocolException {
|
|||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public AuthenticationException(String message, Throwable cause) {
|
||||
public AuthenticationException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,14 +24,13 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.security.Principal;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
import ch.boye.httpclientandroidlib.util.LangUtils;
|
||||
|
||||
/**
|
||||
|
@ -47,9 +47,7 @@ public final class BasicUserPrincipal implements Principal, Serializable {
|
|||
|
||||
public BasicUserPrincipal(final String username) {
|
||||
super();
|
||||
if (username == null) {
|
||||
throw new IllegalArgumentException("User name may not be null");
|
||||
}
|
||||
Args.notNull(username, "User name");
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
|
@ -65,10 +63,12 @@ public final class BasicUserPrincipal implements Principal, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof BasicUserPrincipal) {
|
||||
BasicUserPrincipal that = (BasicUserPrincipal) o;
|
||||
final BasicUserPrincipal that = (BasicUserPrincipal) o;
|
||||
if (LangUtils.equals(this.username, that.username)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ public final class BasicUserPrincipal implements Principal, Serializable {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("[principal: ");
|
||||
buffer.append(this.username);
|
||||
buffer.append("]");
|
||||
|
|
38
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/ChallengeState.java
поставляемый
Normal file
38
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/ChallengeState.java
поставляемый
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
/**
|
||||
* Challenge mode (TARGET or PROXY)
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public enum ChallengeState {
|
||||
|
||||
TARGET, PROXY
|
||||
|
||||
}
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.Header;
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.security.Principal;
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
@ -52,7 +52,7 @@ public class InvalidCredentialsException extends AuthenticationException {
|
|||
*
|
||||
* @param message the exception detail message
|
||||
*/
|
||||
public InvalidCredentialsException(String message) {
|
||||
public InvalidCredentialsException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
@ -63,7 +63,7 @@ public class InvalidCredentialsException extends AuthenticationException {
|
|||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public InvalidCredentialsException(String message, Throwable cause) {
|
||||
public InvalidCredentialsException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,12 +24,10 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
import ch.boye.httpclientandroidlib.ProtocolException;
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Signals that authentication challenge is in some way invalid or
|
||||
|
@ -54,7 +53,7 @@ public class MalformedChallengeException extends ProtocolException {
|
|||
*
|
||||
* @param message the exception detail message
|
||||
*/
|
||||
public MalformedChallengeException(String message) {
|
||||
public MalformedChallengeException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
@ -65,7 +64,7 @@ public class MalformedChallengeException extends ProtocolException {
|
|||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public MalformedChallengeException(String message, Throwable cause) {
|
||||
public MalformedChallengeException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -31,7 +31,7 @@ import java.security.Principal;
|
|||
import java.util.Locale;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
import ch.boye.httpclientandroidlib.util.LangUtils;
|
||||
|
||||
/**
|
||||
|
@ -60,13 +60,11 @@ public class NTCredentials implements Credentials, Serializable {
|
|||
*
|
||||
* @param usernamePassword the domain/username:password formed string
|
||||
*/
|
||||
public NTCredentials(String usernamePassword) {
|
||||
public NTCredentials(final String usernamePassword) {
|
||||
super();
|
||||
if (usernamePassword == null) {
|
||||
throw new IllegalArgumentException("Username:password string may not be null");
|
||||
}
|
||||
String username;
|
||||
int atColon = usernamePassword.indexOf(':');
|
||||
Args.notNull(usernamePassword, "Username:password string");
|
||||
final String username;
|
||||
final int atColon = usernamePassword.indexOf(':');
|
||||
if (atColon >= 0) {
|
||||
username = usernamePassword.substring(0, atColon);
|
||||
this.password = usernamePassword.substring(atColon + 1);
|
||||
|
@ -74,7 +72,7 @@ public class NTCredentials implements Credentials, Serializable {
|
|||
username = usernamePassword;
|
||||
this.password = null;
|
||||
}
|
||||
int atSlash = username.indexOf('/');
|
||||
final int atSlash = username.indexOf('/');
|
||||
if (atSlash >= 0) {
|
||||
this.principal = new NTUserPrincipal(
|
||||
username.substring(0, atSlash).toUpperCase(Locale.ENGLISH),
|
||||
|
@ -102,9 +100,7 @@ public class NTCredentials implements Credentials, Serializable {
|
|||
final String workstation,
|
||||
final String domain) {
|
||||
super();
|
||||
if (userName == null) {
|
||||
throw new IllegalArgumentException("User name may not be null");
|
||||
}
|
||||
Args.notNull(userName, "User name");
|
||||
this.principal = new NTUserPrincipal(domain, userName);
|
||||
this.password = password;
|
||||
if (workstation != null) {
|
||||
|
@ -153,10 +149,12 @@ public class NTCredentials implements Credentials, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof NTCredentials) {
|
||||
NTCredentials that = (NTCredentials) o;
|
||||
final NTCredentials that = (NTCredentials) o;
|
||||
if (LangUtils.equals(this.principal, that.principal)
|
||||
&& LangUtils.equals(this.workstation, that.workstation)) {
|
||||
return true;
|
||||
|
@ -167,7 +165,7 @@ public class NTCredentials implements Credentials, Serializable {
|
|||
|
||||
@Override
|
||||
public String toString() {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("[principal: ");
|
||||
buffer.append(this.principal);
|
||||
buffer.append("][workstation: ");
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
@ -31,7 +31,7 @@ import java.security.Principal;
|
|||
import java.util.Locale;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
import ch.boye.httpclientandroidlib.util.LangUtils;
|
||||
|
||||
/**
|
||||
|
@ -52,9 +52,7 @@ public class NTUserPrincipal implements Principal, Serializable {
|
|||
final String domain,
|
||||
final String username) {
|
||||
super();
|
||||
if (username == null) {
|
||||
throw new IllegalArgumentException("User name may not be null");
|
||||
}
|
||||
Args.notNull(username, "User name");
|
||||
this.username = username;
|
||||
if (domain != null) {
|
||||
this.domain = domain.toUpperCase(Locale.ENGLISH);
|
||||
|
@ -62,9 +60,9 @@ public class NTUserPrincipal implements Principal, Serializable {
|
|||
this.domain = null;
|
||||
}
|
||||
if (this.domain != null && this.domain.length() > 0) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buffer.append(this.domain);
|
||||
buffer.append('/');
|
||||
buffer.append('\\');
|
||||
buffer.append(this.username);
|
||||
this.ntname = buffer.toString();
|
||||
} else {
|
||||
|
@ -93,10 +91,12 @@ public class NTUserPrincipal implements Principal, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof NTUserPrincipal) {
|
||||
NTUserPrincipal that = (NTUserPrincipal) o;
|
||||
final NTUserPrincipal that = (NTUserPrincipal) o;
|
||||
if (LangUtils.equals(this.username, that.username)
|
||||
&& LangUtils.equals(this.domain, that.domain)) {
|
||||
return true;
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,14 +24,13 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.security.Principal;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
import ch.boye.httpclientandroidlib.util.LangUtils;
|
||||
|
||||
/**
|
||||
|
@ -53,12 +53,10 @@ public class UsernamePasswordCredentials implements Credentials, Serializable {
|
|||
* @param usernamePassword the username:password formed string
|
||||
* @see #toString
|
||||
*/
|
||||
public UsernamePasswordCredentials(String usernamePassword) {
|
||||
public UsernamePasswordCredentials(final String usernamePassword) {
|
||||
super();
|
||||
if (usernamePassword == null) {
|
||||
throw new IllegalArgumentException("Username:password string may not be null");
|
||||
}
|
||||
int atColon = usernamePassword.indexOf(':');
|
||||
Args.notNull(usernamePassword, "Username:password string");
|
||||
final int atColon = usernamePassword.indexOf(':');
|
||||
if (atColon >= 0) {
|
||||
this.principal = new BasicUserPrincipal(usernamePassword.substring(0, atColon));
|
||||
this.password = usernamePassword.substring(atColon + 1);
|
||||
|
@ -75,11 +73,9 @@ public class UsernamePasswordCredentials implements Credentials, Serializable {
|
|||
* @param userName the user name
|
||||
* @param password the password
|
||||
*/
|
||||
public UsernamePasswordCredentials(String userName, String password) {
|
||||
public UsernamePasswordCredentials(final String userName, final String password) {
|
||||
super();
|
||||
if (userName == null) {
|
||||
throw new IllegalArgumentException("Username may not be null");
|
||||
}
|
||||
Args.notNull(userName, "Username");
|
||||
this.principal = new BasicUserPrincipal(userName);
|
||||
this.password = password;
|
||||
}
|
||||
|
@ -102,10 +98,12 @@ public class UsernamePasswordCredentials implements Credentials, Serializable {
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof UsernamePasswordCredentials) {
|
||||
UsernamePasswordCredentials that = (UsernamePasswordCredentials) o;
|
||||
final UsernamePasswordCredentials that = (UsernamePasswordCredentials) o;
|
||||
if (LangUtils.equals(this.principal, that.principal)) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
<html>
|
||||
<head>
|
||||
<!--
|
||||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -27,9 +24,8 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
A collection of HTTP connection utility classes.
|
||||
</body>
|
||||
</html>
|
||||
|
||||
/**
|
||||
* Client HTTP authentication APIs.
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
|
@ -1,35 +0,0 @@
|
|||
<html>
|
||||
<head>
|
||||
<!--
|
||||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
The API for client-side HTTP authentication against a server.
|
||||
</body>
|
||||
</html>
|
|
@ -27,13 +27,16 @@
|
|||
|
||||
package ch.boye.httpclientandroidlib.auth.params;
|
||||
|
||||
import ch.boye.httpclientandroidlib.auth.AuthScheme;
|
||||
|
||||
/**
|
||||
* Parameter names for HTTP authentication classes.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
*
|
||||
* @deprecated (4.3) use {@link ch.boye.httpclientandroidlib.client.config.RequestConfig}
|
||||
* and constructor parameters of
|
||||
* {@link ch.boye.httpclientandroidlib.auth.AuthSchemeProvider}s.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AuthPNames {
|
||||
|
||||
/**
|
||||
|
@ -45,24 +48,26 @@ public interface AuthPNames {
|
|||
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.
|
||||
* Defines the order of preference for supported
|
||||
* {@link ch.boye.httpclientandroidlib.auth.AuthScheme}s when authenticating with
|
||||
* the target host.
|
||||
* <p>
|
||||
* 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()}.
|
||||
* {@link ch.boye.httpclientandroidlib.auth.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.
|
||||
* Defines the order of preference for supported
|
||||
* {@link ch.boye.httpclientandroidlib.auth.AuthScheme}s when authenticating with the
|
||||
* proxy host.
|
||||
* <p>
|
||||
* 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()}.
|
||||
* {@link ch.boye.httpclientandroidlib.auth.AuthScheme#getSchemeName()}.
|
||||
*/
|
||||
public static final String PROXY_AUTH_PREF = "http.auth.proxy-scheme-pref";
|
||||
|
||||
|
|
|
@ -36,7 +36,12 @@ import ch.boye.httpclientandroidlib.params.HttpParams;
|
|||
* using Java Beans conventions.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.3) use {@link ch.boye.httpclientandroidlib.client.config.RequestConfig}
|
||||
* and constructor parameters of
|
||||
* {@link ch.boye.httpclientandroidlib.auth.AuthSchemeProvider}s.
|
||||
*/
|
||||
@Deprecated
|
||||
public class AuthParamBean extends HttpAbstractParamBean {
|
||||
|
||||
public AuthParamBean (final HttpParams params) {
|
||||
|
|
|
@ -28,9 +28,9 @@
|
|||
package ch.boye.httpclientandroidlib.auth.params;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
import ch.boye.httpclientandroidlib.params.HttpParams;
|
||||
import ch.boye.httpclientandroidlib.protocol.HTTP;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* An adaptor for manipulating HTTP authentication parameters
|
||||
|
@ -38,9 +38,12 @@ import ch.boye.httpclientandroidlib.protocol.HTTP;
|
|||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @see AuthPNames
|
||||
* @deprecated (4.3) use {@link ch.boye.httpclientandroidlib.client.config.RequestConfig}
|
||||
* and constructor parameters of
|
||||
* {@link ch.boye.httpclientandroidlib.auth.AuthSchemeProvider}s.
|
||||
*/
|
||||
@Immutable
|
||||
@Deprecated
|
||||
public final class AuthParams {
|
||||
|
||||
private AuthParams() {
|
||||
|
@ -55,13 +58,11 @@ public final class AuthParams {
|
|||
* @return The charset
|
||||
*/
|
||||
public static String getCredentialCharset(final HttpParams params) {
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException("HTTP parameters may not be null");
|
||||
}
|
||||
Args.notNull(params, "HTTP parameters");
|
||||
String charset = (String) params.getParameter
|
||||
(AuthPNames.CREDENTIAL_CHARSET);
|
||||
if (charset == null) {
|
||||
charset = HTTP.DEFAULT_PROTOCOL_CHARSET;
|
||||
charset = HTTP.DEF_PROTOCOL_CHARSET.name();
|
||||
}
|
||||
return charset;
|
||||
}
|
||||
|
@ -74,9 +75,7 @@ public final class AuthParams {
|
|||
* @param charset The charset
|
||||
*/
|
||||
public static void setCredentialCharset(final HttpParams params, final String charset) {
|
||||
if (params == null) {
|
||||
throw new IllegalArgumentException("HTTP parameters may not be null");
|
||||
}
|
||||
Args.notNull(params, "HTTP parameters");
|
||||
params.setParameter(AuthPNames.CREDENTIAL_CHARSET, charset);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,3 @@
|
|||
<html>
|
||||
<head>
|
||||
<!--
|
||||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -27,10 +24,9 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
Helpers and utility classes for <i>HttpClient</i>.
|
||||
|
||||
</body>
|
||||
</html>
|
||||
/**
|
||||
* Deprecated.
|
||||
* @deprecated (4.3).
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth.params;
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpHost;
|
||||
|
|
|
@ -47,7 +47,10 @@ import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
|||
* from multiple threads.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.2) use {@link AuthenticationStrategy}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AuthenticationHandler {
|
||||
|
||||
/**
|
||||
|
|
130
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/AuthenticationStrategy.java
поставляемый
Normal file
130
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/AuthenticationStrategy.java
поставляемый
Normal file
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
|
||||
import ch.boye.httpclientandroidlib.Header;
|
||||
import ch.boye.httpclientandroidlib.HttpHost;
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
import ch.boye.httpclientandroidlib.auth.AuthOption;
|
||||
import ch.boye.httpclientandroidlib.auth.AuthScheme;
|
||||
import ch.boye.httpclientandroidlib.auth.MalformedChallengeException;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
/**
|
||||
* A handler for determining if an HTTP response represents an authentication challenge that was
|
||||
* sent back to the client as a result of authentication failure.
|
||||
* <p>
|
||||
* 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 <code>true</code> if user authentication is required,
|
||||
* <code>false</code> 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.
|
||||
*/
|
||||
Map<String, Header> getChallenges(
|
||||
HttpHost authhost,
|
||||
HttpResponse response,
|
||||
HttpContext context) throws MalformedChallengeException;
|
||||
|
||||
/**
|
||||
* Selects one authentication challenge out of all available and
|
||||
* creates and generates {@link AuthOption} instance capable of
|
||||
* processing that challenge.
|
||||
*
|
||||
* @param challenges collection of challenges.
|
||||
* @param authhost authentication host.
|
||||
* @param response HTTP response.
|
||||
* @param context HTTP context.
|
||||
* @return authentication auth schemes that can be used for authentication. Can be empty.
|
||||
* @throws MalformedChallengeException if one of the authentication
|
||||
* challenges is not valid or malformed.
|
||||
*/
|
||||
Queue<AuthOption> select(
|
||||
Map<String, Header> challenges,
|
||||
HttpHost authhost,
|
||||
HttpResponse response,
|
||||
HttpContext context) throws MalformedChallengeException;
|
||||
|
||||
/**
|
||||
* Callback invoked in case of successful authentication.
|
||||
*
|
||||
* @param authhost authentication host.
|
||||
* @param authScheme authentication scheme used.
|
||||
* @param context HTTP context.
|
||||
*/
|
||||
void authSucceeded(
|
||||
HttpHost authhost,
|
||||
AuthScheme authScheme,
|
||||
HttpContext context);
|
||||
|
||||
/**
|
||||
* Callback invoked in case of unsuccessful authentication.
|
||||
*
|
||||
* @param authhost authentication host.
|
||||
* @param authScheme authentication scheme used.
|
||||
* @param context HTTP context.
|
||||
*/
|
||||
void authFailed(
|
||||
HttpHost authhost,
|
||||
AuthScheme authScheme,
|
||||
HttpContext context);
|
||||
|
||||
}
|
54
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/BackoffManager.java
поставляемый
Normal file
54
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/BackoffManager.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.conn.routing.HttpRoute;
|
||||
|
||||
/**
|
||||
* Represents a controller that dynamically adjusts the size
|
||||
* of an available connection pool based on feedback from
|
||||
* using the connections.
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
public interface BackoffManager {
|
||||
|
||||
/**
|
||||
* Called when we have decided that the result of
|
||||
* using a connection should be interpreted as a
|
||||
* backoff signal.
|
||||
*/
|
||||
public void backOff(HttpRoute route);
|
||||
|
||||
/**
|
||||
* Called when we have determined that the result of
|
||||
* using a connection has succeeded and that we may
|
||||
* probe for more connections.
|
||||
*/
|
||||
public void probe(HttpRoute route);
|
||||
}
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
@ -51,7 +51,7 @@ public class CircularRedirectException extends RedirectException {
|
|||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public CircularRedirectException(String message) {
|
||||
public CircularRedirectException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
@ -62,7 +62,7 @@ public class CircularRedirectException extends RedirectException {
|
|||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public CircularRedirectException(String message, Throwable cause) {
|
||||
public CircularRedirectException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -44,15 +44,15 @@ public class ClientProtocolException extends IOException {
|
|||
super();
|
||||
}
|
||||
|
||||
public ClientProtocolException(String s) {
|
||||
public ClientProtocolException(final String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public ClientProtocolException(Throwable cause) {
|
||||
public ClientProtocolException(final Throwable cause) {
|
||||
initCause(cause);
|
||||
}
|
||||
|
||||
public ClientProtocolException(String message, Throwable cause) {
|
||||
public ClientProtocolException(final String message, final Throwable cause) {
|
||||
super(message);
|
||||
initCause(cause);
|
||||
}
|
||||
|
|
64
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/ConnectionBackoffStrategy.java
поставляемый
Normal file
64
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/ConnectionBackoffStrategy.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
|
||||
/**
|
||||
* When managing a dynamic number of connections for a given route, this
|
||||
* strategy assesses whether a given request execution outcome should
|
||||
* result in a backoff signal or not, based on either examining the
|
||||
* <code>Throwable</code> 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 <code>Throwable</code> as
|
||||
* a result of request execution should result in a backoff
|
||||
* signal.
|
||||
* @param t the <code>Throwable</code> that happened
|
||||
* @return <code>true</code> 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 <code>HttpResponse</code> that was received
|
||||
* @return <code>true</code> if a backoff signal should be
|
||||
* given
|
||||
*/
|
||||
boolean shouldBackoff(HttpResponse resp);
|
||||
}
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import java.util.Date;
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.auth.AuthScope;
|
||||
|
|
|
@ -27,8 +27,6 @@
|
|||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpHost;
|
||||
import ch.boye.httpclientandroidlib.HttpRequest;
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
|
@ -37,71 +35,17 @@ import ch.boye.httpclientandroidlib.conn.ClientConnectionManager;
|
|||
import ch.boye.httpclientandroidlib.params.HttpParams;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* This interface represents only the most basic contract for HTTP request
|
||||
* execution. It imposes no restrictions or particular details on the request
|
||||
* execution process and leaves the specifics of state management,
|
||||
* authentication and redirect handling up to individual implementations.
|
||||
* This should make it easier to decorate the interface with additional
|
||||
* functionality such as response content caching.
|
||||
* <p/>
|
||||
* The usual execution flow can be demonstrated by the code snippet below:
|
||||
* <PRE>
|
||||
* 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();
|
||||
* }
|
||||
* </PRE>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface HttpClient {
|
||||
|
||||
|
||||
|
@ -112,18 +56,26 @@ public interface HttpClient {
|
|||
* dependent objects in this client.
|
||||
*
|
||||
* @return the default parameters
|
||||
*
|
||||
* @deprecated (4.3) use
|
||||
* {@link ch.boye.httpclientandroidlib.client.config.RequestConfig}.
|
||||
*/
|
||||
@Deprecated
|
||||
HttpParams getParams();
|
||||
|
||||
/**
|
||||
* Obtains the connection manager used by this client.
|
||||
*
|
||||
* @return the connection manager
|
||||
*
|
||||
* @deprecated (4.3) use
|
||||
* {@link ch.boye.httpclientandroidlib.impl.client.HttpClientBuilder}.
|
||||
*/
|
||||
@Deprecated
|
||||
ClientConnectionManager getConnectionManager();
|
||||
|
||||
/**
|
||||
* Executes a request using the default context.
|
||||
* Executes HTTP request using the default context.
|
||||
*
|
||||
* @param request the request to execute
|
||||
*
|
||||
|
@ -139,8 +91,7 @@ public interface HttpClient {
|
|||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes a request using the given context.
|
||||
* The route to the target will be determined by the HTTP client.
|
||||
* Executes HTTP request using the given context.
|
||||
*
|
||||
* @param request the request to execute
|
||||
* @param context the context to use for the execution, or
|
||||
|
@ -158,7 +109,7 @@ public interface HttpClient {
|
|||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes a request to the target using the default context.
|
||||
* Executes HTTP request using the default context.
|
||||
*
|
||||
* @param target the target host for the request.
|
||||
* Implementations may accept <code>null</code>
|
||||
|
@ -178,7 +129,7 @@ public interface HttpClient {
|
|||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes a request to the target using the given context.
|
||||
* Executes HTTP request using the given context.
|
||||
*
|
||||
* @param target the target host for the request.
|
||||
* Implementations may accept <code>null</code>
|
||||
|
@ -201,8 +152,14 @@ public interface HttpClient {
|
|||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes a request using the default context and processes the
|
||||
* Executes HTTP request using the default context and processes the
|
||||
* response using the given response handler.
|
||||
* <p/>
|
||||
* Implementing classes are required to ensure that the content entity
|
||||
* associated with the response is fully consumed and the underlying
|
||||
* connection is released back to the connection manager automatically
|
||||
* in all cases relieving individual {@link ResponseHandler}s from
|
||||
* having to manage resource deallocation internally.
|
||||
*
|
||||
* @param request the request to execute
|
||||
* @param responseHandler the response handler
|
||||
|
@ -217,11 +174,19 @@ public interface HttpClient {
|
|||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes a request using the given context and processes the
|
||||
* Executes HTTP request using the given context and processes the
|
||||
* response using the given response handler.
|
||||
* <p/>
|
||||
* Implementing classes are required to ensure that the content entity
|
||||
* associated with the response is fully consumed and the underlying
|
||||
* connection is released back to the connection manager automatically
|
||||
* in all cases relieving individual {@link ResponseHandler}s from
|
||||
* having to manage resource deallocation internally.
|
||||
*
|
||||
* @param request the request to execute
|
||||
* @param responseHandler the response handler
|
||||
* @param context the context to use for the execution, or
|
||||
* <code>null</code> 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
|
||||
|
@ -234,8 +199,14 @@ public interface HttpClient {
|
|||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes a request to the target using the default context and
|
||||
* Executes HTTP request to the target using the default context and
|
||||
* processes the response using the given response handler.
|
||||
* <p/>
|
||||
* Implementing classes are required to ensure that the content entity
|
||||
* associated with the response is fully consumed and the underlying
|
||||
* connection is released back to the connection manager automatically
|
||||
* in all cases relieving individual {@link ResponseHandler}s from
|
||||
* having to manage resource deallocation internally.
|
||||
*
|
||||
* @param target the target host for the request.
|
||||
* Implementations may accept <code>null</code>
|
||||
|
@ -255,8 +226,14 @@ public interface HttpClient {
|
|||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes a request to the target using the given context and
|
||||
* Executes HTTP request to the target using the given context and
|
||||
* processes the response using the given response handler.
|
||||
* <p/>
|
||||
* Implementing classes are required to ensure that the content entity
|
||||
* associated with the response is fully consumed and the underlying
|
||||
* connection is released back to the connection manager automatically
|
||||
* in all cases relieving individual {@link ResponseHandler}s from
|
||||
* having to manage resource deallocation internally.
|
||||
*
|
||||
* @param target the target host for the request.
|
||||
* Implementations may accept <code>null</code>
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
@ -40,7 +40,7 @@ public class HttpResponseException extends ClientProtocolException {
|
|||
|
||||
private final int statusCode;
|
||||
|
||||
public HttpResponseException(int statusCode, final String s) {
|
||||
public HttpResponseException(final int statusCode, final String s) {
|
||||
super(s);
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,12 +24,10 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
import ch.boye.httpclientandroidlib.ProtocolException;
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Signals failure to retry the request due to non-repeatable request
|
||||
|
@ -54,7 +53,7 @@ public class NonRepeatableRequestException extends ProtocolException {
|
|||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public NonRepeatableRequestException(String message) {
|
||||
public NonRepeatableRequestException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
@ -64,7 +63,7 @@ public class NonRepeatableRequestException extends ProtocolException {
|
|||
* @param message The exception detail message
|
||||
* @param cause the cause
|
||||
*/
|
||||
public NonRepeatableRequestException(String message, Throwable cause) {
|
||||
public NonRepeatableRequestException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,12 +24,10 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
import ch.boye.httpclientandroidlib.ProtocolException;
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Signals violation of HTTP specification caused by an invalid redirect
|
||||
|
@ -53,7 +52,7 @@ public class RedirectException extends ProtocolException {
|
|||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public RedirectException(String message) {
|
||||
public RedirectException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
|
@ -64,7 +63,7 @@ public class RedirectException extends ProtocolException {
|
|||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public RedirectException(String message, Throwable cause) {
|
||||
public RedirectException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
|||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated use {@link RedirectStrategy}
|
||||
* @deprecated (4.1) use {@link RedirectStrategy}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface RedirectHandler {
|
||||
|
|
|
@ -29,10 +29,10 @@ package ch.boye.httpclientandroidlib.client;
|
|||
|
||||
import java.io.IOException;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpException;
|
||||
import ch.boye.httpclientandroidlib.HttpHost;
|
||||
import ch.boye.httpclientandroidlib.HttpRequest;
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
import ch.boye.httpclientandroidlib.HttpException;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
|
@ -43,7 +43,10 @@ import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
|||
* send a sequence of requests in order to execute one initial request.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.3) No longer used
|
||||
*/
|
||||
@Deprecated
|
||||
public interface RequestDirector {
|
||||
|
||||
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,7 +24,6 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
|
60
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/ServiceUnavailableRetryStrategy.java
поставляемый
Normal file
60
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/ServiceUnavailableRetryStrategy.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* Strategy interface that allows API users to plug in their own logic to
|
||||
* control whether or not a retry should automatically be done, how many times
|
||||
* it should be retried and so on.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public interface ServiceUnavailableRetryStrategy {
|
||||
|
||||
/**
|
||||
* Determines if a method should be retried given the response from the target server.
|
||||
*
|
||||
* @param response the response from the target server
|
||||
* @param executionCount the number of times this method has been
|
||||
* unsuccessfully executed
|
||||
* @param context the context for the request execution
|
||||
|
||||
* @return <code>true</code> if the method should be retried, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
boolean retryRequest(HttpResponse response, int executionCount, HttpContext context);
|
||||
|
||||
/**
|
||||
* @return The interval between the subsequent auto-retries.
|
||||
*/
|
||||
long getRetryInterval();
|
||||
|
||||
}
|
55
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/CacheResponseStatus.java
поставляемый
Normal file
55
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/CacheResponseStatus.java
поставляемый
Normal file
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
/**
|
||||
* This enumeration represents the various ways a response can be generated
|
||||
* by the {@link ch.boye.httpclientandroidlib.impl.client.cache.CachingHttpClient};
|
||||
* if a request is executed with an {@link ch.boye.httpclientandroidlib.protocol.HttpContext}
|
||||
* then a parameter with one of these values will be registered in the
|
||||
* context under the key
|
||||
* {@link ch.boye.httpclientandroidlib.impl.client.cache.CachingHttpClient#CACHE_RESPONSE_STATUS}.
|
||||
*/
|
||||
public enum CacheResponseStatus {
|
||||
|
||||
/** The response was generated directly by the caching module. */
|
||||
CACHE_MODULE_RESPONSE,
|
||||
|
||||
/** A response was generated from the cache with no requests sent
|
||||
* upstream.
|
||||
*/
|
||||
CACHE_HIT,
|
||||
|
||||
/** The response came from an upstream server. */
|
||||
CACHE_MISS,
|
||||
|
||||
/** The response was generated from the cache after validating the
|
||||
* entry with the origin server.
|
||||
*/
|
||||
VALIDATED;
|
||||
|
||||
}
|
81
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HeaderConstants.java
поставляемый
Normal file
81
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HeaderConstants.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Records static constants for various HTTP header names.
|
||||
* @since 4.1
|
||||
*/
|
||||
@Immutable
|
||||
public class HeaderConstants {
|
||||
|
||||
public static final String GET_METHOD = "GET";
|
||||
public static final String HEAD_METHOD = "HEAD";
|
||||
public static final String OPTIONS_METHOD = "OPTIONS";
|
||||
public static final String PUT_METHOD = "PUT";
|
||||
public static final String DELETE_METHOD = "DELETE";
|
||||
public static final String TRACE_METHOD = "TRACE";
|
||||
|
||||
public static final String LAST_MODIFIED = "Last-Modified";
|
||||
public static final String IF_MATCH = "If-Match";
|
||||
public static final String IF_RANGE = "If-Range";
|
||||
public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since";
|
||||
public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
|
||||
public static final String IF_NONE_MATCH = "If-None-Match";
|
||||
|
||||
public static final String PRAGMA = "Pragma";
|
||||
public static final String MAX_FORWARDS = "Max-Forwards";
|
||||
public static final String ETAG = "ETag";
|
||||
public static final String EXPIRES = "Expires";
|
||||
public static final String AGE = "Age";
|
||||
public static final String VARY = "Vary";
|
||||
public static final String ALLOW = "Allow";
|
||||
public static final String VIA = "Via";
|
||||
public static final String PUBLIC = "public";
|
||||
public static final String PRIVATE = "private";
|
||||
|
||||
public static final String CACHE_CONTROL = "Cache-Control";
|
||||
public static final String CACHE_CONTROL_NO_STORE = "no-store";
|
||||
public static final String CACHE_CONTROL_NO_CACHE = "no-cache";
|
||||
public static final String CACHE_CONTROL_MAX_AGE = "max-age";
|
||||
public static final String CACHE_CONTROL_MAX_STALE = "max-stale";
|
||||
public static final String CACHE_CONTROL_MIN_FRESH = "min-fresh";
|
||||
public static final String CACHE_CONTROL_MUST_REVALIDATE = "must-revalidate";
|
||||
public static final String CACHE_CONTROL_PROXY_REVALIDATE = "proxy-revalidate";
|
||||
public static final String STALE_IF_ERROR = "stale-if-error";
|
||||
public static final String STALE_WHILE_REVALIDATE = "stale-while-revalidate";
|
||||
|
||||
public static final String WARNING = "Warning";
|
||||
public static final String RANGE = "Range";
|
||||
public static final String CONTENT_RANGE = "Content-Range";
|
||||
public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
|
||||
public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate";
|
||||
public static final String AUTHORIZATION = "Authorization";
|
||||
|
||||
}
|
71
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheContext.java
поставляемый
Normal file
71
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheContext.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.NotThreadSafe;
|
||||
import ch.boye.httpclientandroidlib.client.protocol.HttpClientContext;
|
||||
import ch.boye.httpclientandroidlib.protocol.BasicHttpContext;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* @since 4.3
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class HttpCacheContext extends HttpClientContext {
|
||||
|
||||
/**
|
||||
* This is the name under which the {@link CacheResponseStatus} of a request
|
||||
* (for example, whether it resulted in a cache hit) will be recorded if an
|
||||
* {@link HttpContext} is provided during execution.
|
||||
*/
|
||||
public static final String CACHE_RESPONSE_STATUS = "http.cache.response.status";
|
||||
|
||||
public static HttpCacheContext adapt(final HttpContext context) {
|
||||
if (context instanceof HttpCacheContext) {
|
||||
return (HttpCacheContext) context;
|
||||
} else {
|
||||
return new HttpCacheContext(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static HttpCacheContext create() {
|
||||
return new HttpCacheContext(new BasicHttpContext());
|
||||
}
|
||||
|
||||
public HttpCacheContext(final HttpContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public HttpCacheContext() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CacheResponseStatus getCacheResponseStatus() {
|
||||
return getAttribute(CACHE_RESPONSE_STATUS, CacheResponseStatus.class);
|
||||
}
|
||||
|
||||
}
|
263
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheEntry.java
поставляемый
Normal file
263
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheEntry.java
поставляемый
Normal file
|
@ -0,0 +1,263 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import ch.boye.httpclientandroidlib.Header;
|
||||
import ch.boye.httpclientandroidlib.ProtocolVersion;
|
||||
import ch.boye.httpclientandroidlib.StatusLine;
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.client.utils.DateUtils;
|
||||
import ch.boye.httpclientandroidlib.message.HeaderGroup;
|
||||
import ch.boye.httpclientandroidlib.protocol.HTTP;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* Structure used to store an {@link ch.boye.httpclientandroidlib.HttpResponse} in a cache.
|
||||
* Some entries can optionally depend on system resources that may require
|
||||
* explicit deallocation. In such a case {@link #getResource()} should return
|
||||
* a non null instance of {@link Resource} that must be deallocated by calling
|
||||
* {@link Resource#dispose()} method when no longer used.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
@Immutable
|
||||
public class HttpCacheEntry implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6300496422359477413L;
|
||||
|
||||
private final Date requestDate;
|
||||
private final Date responseDate;
|
||||
private final StatusLine statusLine;
|
||||
private final HeaderGroup responseHeaders;
|
||||
private final Resource resource;
|
||||
private final Map<String,String> variantMap;
|
||||
private final Date date;
|
||||
|
||||
/**
|
||||
* Create a new {@link HttpCacheEntry} with variants.
|
||||
* @param requestDate
|
||||
* Date/time when the request was made (Used for age
|
||||
* calculations)
|
||||
* @param responseDate
|
||||
* Date/time that the response came back (Used for age
|
||||
* calculations)
|
||||
* @param statusLine
|
||||
* HTTP status line from origin response
|
||||
* @param responseHeaders
|
||||
* Header[] from original HTTP Response
|
||||
* @param resource representing origin response body
|
||||
* @param variantMap describing cache entries that are variants
|
||||
* of this parent entry; this maps a "variant key" (derived
|
||||
* from the varying request headers) to a "cache key" (where
|
||||
* in the cache storage the particular variant is located)
|
||||
*/
|
||||
public HttpCacheEntry(
|
||||
final Date requestDate,
|
||||
final Date responseDate,
|
||||
final StatusLine statusLine,
|
||||
final Header[] responseHeaders,
|
||||
final Resource resource,
|
||||
final Map<String,String> variantMap) {
|
||||
super();
|
||||
Args.notNull(requestDate, "Request date");
|
||||
Args.notNull(responseDate, "Response date");
|
||||
Args.notNull(statusLine, "Status line");
|
||||
Args.notNull(responseHeaders, "Response headers");
|
||||
this.requestDate = requestDate;
|
||||
this.responseDate = responseDate;
|
||||
this.statusLine = statusLine;
|
||||
this.responseHeaders = new HeaderGroup();
|
||||
this.responseHeaders.setHeaders(responseHeaders);
|
||||
this.resource = resource;
|
||||
this.variantMap = variantMap != null
|
||||
? new HashMap<String,String>(variantMap)
|
||||
: null;
|
||||
this.date = parseDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link HttpCacheEntry}.
|
||||
*
|
||||
* @param requestDate
|
||||
* Date/time when the request was made (Used for age
|
||||
* calculations)
|
||||
* @param responseDate
|
||||
* Date/time that the response came back (Used for age
|
||||
* calculations)
|
||||
* @param statusLine
|
||||
* HTTP status line from origin response
|
||||
* @param responseHeaders
|
||||
* Header[] from original HTTP Response
|
||||
* @param resource representing origin response body
|
||||
*/
|
||||
public HttpCacheEntry(final Date requestDate, final Date responseDate, final StatusLine statusLine,
|
||||
final Header[] responseHeaders, final Resource resource) {
|
||||
this(requestDate, responseDate, statusLine, responseHeaders, resource,
|
||||
new HashMap<String,String>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the "Date" response header and parse it into a java.util.Date
|
||||
* @return the Date value of the header or null if the header is not present
|
||||
*/
|
||||
private Date parseDate() {
|
||||
final Header dateHdr = getFirstHeader(HTTP.DATE_HEADER);
|
||||
if (dateHdr == null) {
|
||||
return null;
|
||||
}
|
||||
return DateUtils.parseDate(dateHdr.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link StatusLine} from the origin
|
||||
* {@link ch.boye.httpclientandroidlib.HttpResponse}.
|
||||
*/
|
||||
public StatusLine getStatusLine() {
|
||||
return this.statusLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link ProtocolVersion} from the origin
|
||||
* {@link ch.boye.httpclientandroidlib.HttpResponse}.
|
||||
*/
|
||||
public ProtocolVersion getProtocolVersion() {
|
||||
return this.statusLine.getProtocolVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the reason phrase from the origin
|
||||
* {@link ch.boye.httpclientandroidlib.HttpResponse}, for example, "Not Modified".
|
||||
*/
|
||||
public String getReasonPhrase() {
|
||||
return this.statusLine.getReasonPhrase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTTP response code from the origin
|
||||
* {@link ch.boye.httpclientandroidlib.HttpResponse}.
|
||||
*/
|
||||
public int getStatusCode() {
|
||||
return this.statusLine.getStatusCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time the associated origin request was initiated by the
|
||||
* caching module.
|
||||
* @return {@link Date}
|
||||
*/
|
||||
public Date getRequestDate() {
|
||||
return requestDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time the origin response was received by the caching module.
|
||||
* @return {@link Date}
|
||||
*/
|
||||
public Date getResponseDate() {
|
||||
return responseDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the headers that were on the origin response.
|
||||
*/
|
||||
public Header[] getAllHeaders() {
|
||||
return responseHeaders.getAllHeaders();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first header from the origin response with the given
|
||||
* name.
|
||||
*/
|
||||
public Header getFirstHeader(final String name) {
|
||||
return responseHeaders.getFirstHeader(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the headers with the given name that were on the origin
|
||||
* response.
|
||||
*/
|
||||
public Header[] getHeaders(final String name) {
|
||||
return responseHeaders.getHeaders(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Date value of the "Date" header or null if the header is missing or cannot be
|
||||
* parsed.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Resource} containing the origin response body.
|
||||
*/
|
||||
public Resource getResource() {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the origin response indicated the associated
|
||||
* resource had variants (i.e. that the Vary header was set on the
|
||||
* origin response).
|
||||
* @return {@code true} if this cached response was a variant
|
||||
*/
|
||||
public boolean hasVariants() {
|
||||
return getFirstHeader(HeaderConstants.VARY) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an index about where in the cache different variants for
|
||||
* a given resource are stored. This maps "variant keys" to "cache keys",
|
||||
* where the variant key is derived from the varying request headers,
|
||||
* and the cache key is the location in the
|
||||
* {@link ch.boye.httpclientandroidlib.client.cache.HttpCacheStorage} where that
|
||||
* particular variant is stored. The first variant returned is used as
|
||||
* the "parent" entry to hold this index of the other variants.
|
||||
*/
|
||||
public Map<String, String> getVariantMap() {
|
||||
return Collections.unmodifiableMap(variantMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a string representation of this instance suitable for
|
||||
* human consumption.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[request date=" + this.requestDate + "; response date=" + this.responseDate
|
||||
+ "; statusLine=" + this.statusLine + "]";
|
||||
}
|
||||
|
||||
}
|
48
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheEntrySerializationException.java
поставляемый
Normal file
48
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheEntrySerializationException.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Thrown if serialization or deserialization of an {@link HttpCacheEntry}
|
||||
* fails.
|
||||
*/
|
||||
public class HttpCacheEntrySerializationException extends IOException {
|
||||
|
||||
private static final long serialVersionUID = 9219188365878433519L;
|
||||
|
||||
public HttpCacheEntrySerializationException(final String message) {
|
||||
super();
|
||||
}
|
||||
|
||||
public HttpCacheEntrySerializationException(final String message, final Throwable cause) {
|
||||
super(message);
|
||||
initCause(cause);
|
||||
}
|
||||
|
||||
}
|
54
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheEntrySerializer.java
поставляемый
Normal file
54
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheEntrySerializer.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* Used by some {@link HttpCacheStorage} implementations to serialize
|
||||
* {@link HttpCacheEntry} instances to a byte representation before
|
||||
* storage.
|
||||
*/
|
||||
public interface HttpCacheEntrySerializer {
|
||||
|
||||
/**
|
||||
* Serializes the given entry to a byte representation on the
|
||||
* given {@link OutputStream}.
|
||||
* @throws IOException
|
||||
*/
|
||||
void writeTo(HttpCacheEntry entry, OutputStream os) throws IOException;
|
||||
|
||||
/**
|
||||
* Deserializes a byte representation of a cache entry by reading
|
||||
* from the given {@link InputStream}.
|
||||
* @throws IOException
|
||||
*/
|
||||
HttpCacheEntry readFrom(InputStream is) throws IOException;
|
||||
|
||||
}
|
58
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheInvalidator.java
поставляемый
Normal file
58
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheInvalidator.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpHost;
|
||||
import ch.boye.httpclientandroidlib.HttpRequest;
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
|
||||
/**
|
||||
* Given a particular HttpRequest, flush any cache entries that this request
|
||||
* would invalidate.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public interface HttpCacheInvalidator {
|
||||
|
||||
/**
|
||||
* Remove cache entries from the cache that are no longer fresh or have been
|
||||
* invalidated in some way.
|
||||
*
|
||||
* @param host
|
||||
* The backend host we are talking to
|
||||
* @param req
|
||||
* The HttpRequest to that host
|
||||
*/
|
||||
void flushInvalidatedCacheEntries(HttpHost host, HttpRequest req);
|
||||
|
||||
/**
|
||||
* Flushes entries that were invalidated by the given response received for
|
||||
* the given host/request pair.
|
||||
*/
|
||||
void flushInvalidatedCacheEntries(HttpHost host, HttpRequest request, HttpResponse response);
|
||||
|
||||
}
|
81
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheStorage.java
поставляемый
Normal file
81
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheStorage.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* New storage backends should implement this {@link HttpCacheStorage}
|
||||
* interface. They can then be plugged into the existing
|
||||
* {@link ch.boye.httpclientandroidlib.impl.client.cache.CachingHttpClient}
|
||||
* implementation.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface HttpCacheStorage {
|
||||
|
||||
/**
|
||||
* Store a given cache entry under the given key.
|
||||
* @param key where in the cache to store the entry
|
||||
* @param entry cached response to store
|
||||
* @throws IOException
|
||||
*/
|
||||
void putEntry(String key, HttpCacheEntry entry) throws IOException;
|
||||
|
||||
/**
|
||||
* Retrieves the cache entry stored under the given key
|
||||
* or null if no entry exists under that key.
|
||||
* @param key cache key
|
||||
* @return an {@link HttpCacheEntry} or {@code null} if no
|
||||
* entry exists
|
||||
* @throws IOException
|
||||
*/
|
||||
HttpCacheEntry getEntry(String key) throws IOException;
|
||||
|
||||
/**
|
||||
* Deletes/invalidates/removes any cache entries currently
|
||||
* stored under the given key.
|
||||
* @param key
|
||||
* @throws IOException
|
||||
*/
|
||||
void removeEntry(String key) throws IOException;
|
||||
|
||||
/**
|
||||
* Atomically applies the given callback to update an existing cache
|
||||
* entry under a given key.
|
||||
* @param key indicates which entry to modify
|
||||
* @param callback performs the update; see
|
||||
* {@link HttpCacheUpdateCallback} for details, but roughly the
|
||||
* callback expects to be handed the current entry and will return
|
||||
* the new value for the entry.
|
||||
* @throws IOException
|
||||
* @throws HttpCacheUpdateException
|
||||
*/
|
||||
void updateEntry(
|
||||
String key, HttpCacheUpdateCallback callback) throws IOException, HttpCacheUpdateException;
|
||||
|
||||
}
|
52
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheUpdateCallback.java
поставляемый
Normal file
52
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheUpdateCallback.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Used for atomically updating entries in a {@link HttpCacheStorage}
|
||||
* implementation. The current entry (if any) is fed into an implementation
|
||||
* of this interface, and the new, possibly updated entry (if any)
|
||||
* should be returned.
|
||||
*/
|
||||
public interface HttpCacheUpdateCallback {
|
||||
|
||||
/**
|
||||
* Returns the new cache entry that should replace an existing one.
|
||||
*
|
||||
* @param existing
|
||||
* the cache entry currently in-place in the cache, possibly
|
||||
* <code>null</code> if nonexistent
|
||||
* @return the cache entry that should replace it, again,
|
||||
* possibly <code>null</code> if the entry should be deleted
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
HttpCacheEntry update(HttpCacheEntry existing) throws IOException;
|
||||
|
||||
}
|
48
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheUpdateException.java
поставляемый
Normal file
48
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheUpdateException.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
/**
|
||||
* Signals that {@link HttpCacheStorage} encountered an error performing an
|
||||
* update operation.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public class HttpCacheUpdateException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 823573584868632876L;
|
||||
|
||||
public HttpCacheUpdateException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
public HttpCacheUpdateException(final String message, final Throwable cause) {
|
||||
super(message);
|
||||
initCause(cause);
|
||||
}
|
||||
|
||||
}
|
76
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/InputLimit.java
поставляемый
Normal file
76
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/InputLimit.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.NotThreadSafe;
|
||||
|
||||
/**
|
||||
* Used to limiting the size of an incoming response body of
|
||||
* unknown size that is optimistically being read in anticipation
|
||||
* of caching it.
|
||||
* @since 4.1
|
||||
*/
|
||||
@NotThreadSafe // reached
|
||||
public class InputLimit {
|
||||
|
||||
private final long value;
|
||||
private boolean reached;
|
||||
|
||||
/**
|
||||
* Create a limit for how many bytes of a response body to
|
||||
* read.
|
||||
* @param value maximum length in bytes
|
||||
*/
|
||||
public InputLimit(final long value) {
|
||||
super();
|
||||
this.value = value;
|
||||
this.reached = false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current maximum limit that was set on
|
||||
* creation.
|
||||
*/
|
||||
public long getValue() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to report that the limit has been reached.
|
||||
*/
|
||||
public void reached() {
|
||||
this.reached = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@code true} if the input limit has been reached.
|
||||
*/
|
||||
public boolean isReached() {
|
||||
return this.reached;
|
||||
}
|
||||
|
||||
}
|
60
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/Resource.java
поставляемый
Normal file
60
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/Resource.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Represents a disposable system resource used for handling
|
||||
* cached response bodies.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface Resource extends Serializable {
|
||||
|
||||
/**
|
||||
* Returns an {@link InputStream} from which the response
|
||||
* body can be read.
|
||||
* @throws IOException
|
||||
*/
|
||||
InputStream getInputStream() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns the length in bytes of the response body.
|
||||
*/
|
||||
long length();
|
||||
|
||||
/**
|
||||
* Indicates the system no longer needs to keep this
|
||||
* response body and any system resources associated with
|
||||
* it may be reclaimed.
|
||||
*/
|
||||
void dispose();
|
||||
|
||||
}
|
67
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/ResourceFactory.java
поставляемый
Normal file
67
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/ResourceFactory.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Generates {@link Resource} instances for handling cached
|
||||
* HTTP response bodies.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public interface ResourceFactory {
|
||||
|
||||
/**
|
||||
* Creates a {@link Resource} from a given response body.
|
||||
* @param requestId a unique identifier for this particular
|
||||
* response body
|
||||
* @param instream the original {@link InputStream}
|
||||
* containing the response body of the origin HTTP response.
|
||||
* @param limit maximum number of bytes to consume of the
|
||||
* response body; if this limit is reached before the
|
||||
* response body is fully consumed, mark the limit has
|
||||
* having been reached and return a {@code Resource}
|
||||
* containing the data read to that point.
|
||||
* @return a {@code Resource} containing however much of
|
||||
* the response body was successfully read.
|
||||
* @throws IOException
|
||||
*/
|
||||
Resource generate(String requestId, InputStream instream, InputLimit limit) throws IOException;
|
||||
|
||||
/**
|
||||
* Clones an existing {@link Resource}.
|
||||
* @param requestId unique identifier provided to associate
|
||||
* with the cloned response body.
|
||||
* @param resource the original response body to clone.
|
||||
* @return the {@code Resource} copy
|
||||
* @throws IOException
|
||||
*/
|
||||
Resource copy(String requestId, Resource resource) throws IOException;
|
||||
|
||||
}
|
78
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/package.html
поставляемый
Normal file
78
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/package.html
поставляемый
Normal file
|
@ -0,0 +1,78 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
|
||||
<html>
|
||||
<head>
|
||||
<!--
|
||||
====================================================================
|
||||
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
|
||||
<http://www.apache.org/>.
|
||||
-->
|
||||
</head>
|
||||
<body bgcolor="white">
|
||||
|
||||
<p>
|
||||
This package consists largely of constants and interfaces that are
|
||||
necessary for building new storage backends for the
|
||||
{@link org.apache.http.impl.client.cache.CachingHttpClient} or for
|
||||
those clients wanting to get a little more behavioral information
|
||||
out of the cache module (for example, whether a particular response
|
||||
was a cache hit or not). Developers that simply want to instantiate
|
||||
and make use of the caching module will be better off looking at
|
||||
the {@code CachingHttpClient} documentation itself.
|
||||
</p>
|
||||
<p>
|
||||
The classes in this package can be divided into two main groups:
|
||||
reference constants and interfaces needed for storage backends. In
|
||||
the former group,
|
||||
{@link org.apache.http.client.cache.HeaderConstants} contains a list
|
||||
of HTTP header names encoded as static fields, and the
|
||||
{@link org.apache.http.client.cache.CacheResponseStatus} enumeration
|
||||
values are set in an {@link org.apache.http.protocol.HttpContext} by
|
||||
the {@code CachingHttpClient} to indicate how the request was
|
||||
processed by the caching module itself.
|
||||
</p>
|
||||
<p>
|
||||
New storage backends will need to implement the
|
||||
{@link org.apache.http.client.cache.HttpCacheStorage}
|
||||
interface; they can then be passed to one of the {@code CachingHttpClient}
|
||||
constructors, which will happily make use of the new storage mechanism.
|
||||
The {@link org.apache.http.client.cache.HttpCacheEntry} class shows the
|
||||
datastructure for a cache entry that must be stored by the
|
||||
{@code HttpCacheStorage}.
|
||||
There is, in addition, the notion of a
|
||||
{@link org.apache.http.client.cache.Resource} and an associated
|
||||
{@link org.apache.http.client.cache.ResourceFactory}, which are used for
|
||||
managing the handling of cached response bodies. The default implementation
|
||||
used by the {@code CachingHttpClient} stores response bodies in memory;
|
||||
alternative implementations might involve storing these in a filesystem. A new
|
||||
{@code ResourceFactory} can be provided along with a {@code HttpCacheStorage}
|
||||
in one of the constructors to the {@code CachingHttpClient}. Finally, some
|
||||
of the additional storage backends we provide, like the
|
||||
{@link org.apache.http.impl.client.cache.ehcache.EhcacheHttpCacheStorage} and
|
||||
{@link org.apache.http.impl.client.cache.memcached.MemcachedHttpCacheStorage},
|
||||
can be provided with different serializers for the cache entry metadata;
|
||||
developers wanting to experiment with different serialization techniques
|
||||
should implement the
|
||||
{@link org.apache.http.client.cache.HttpCacheEntrySerializer} interface.
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
71
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/config/AuthSchemes.java
поставляемый
Normal file
71
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/config/AuthSchemes.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client.config;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Standard authentication schemes supported by HttpClient.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
@Immutable
|
||||
public final class AuthSchemes {
|
||||
|
||||
/**
|
||||
* Basic authentication scheme as defined in RFC2617 (considered inherently
|
||||
* insecure, but most widely supported)
|
||||
*/
|
||||
public static final String BASIC = "Basic";
|
||||
|
||||
/**
|
||||
* Digest authentication scheme as defined in RFC2617.
|
||||
*/
|
||||
public static final String DIGEST = "Digest";
|
||||
|
||||
/**
|
||||
* The NTLM scheme is a proprietary Microsoft Windows Authentication
|
||||
* protocol (considered to be the most secure among currently supported
|
||||
* authentication schemes).
|
||||
*/
|
||||
public static final String NTLM = "NTLM";
|
||||
|
||||
/**
|
||||
* SPNEGO Authentication scheme.
|
||||
*/
|
||||
public static final String SPNEGO = "negotiate";
|
||||
|
||||
/**
|
||||
* Kerberos Authentication scheme.
|
||||
*/
|
||||
public static final String KERBEROS = "Kerberos";
|
||||
|
||||
private AuthSchemes() {
|
||||
}
|
||||
|
||||
}
|
69
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/config/CookieSpecs.java
поставляемый
Normal file
69
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/config/CookieSpecs.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client.config;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Standard cookie specifications supported by HttpClient.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
@Immutable
|
||||
public final class CookieSpecs {
|
||||
|
||||
/**
|
||||
* The policy that provides high degree of compatibility
|
||||
* with common cookie management of popular HTTP agents.
|
||||
*/
|
||||
public static final String BROWSER_COMPATIBILITY = "compatibility";
|
||||
|
||||
/**
|
||||
* The Netscape cookie draft compliant policy.
|
||||
*/
|
||||
public static final String NETSCAPE = "netscape";
|
||||
|
||||
/**
|
||||
* The RFC 2965 compliant policy (standard).
|
||||
*/
|
||||
public static final String STANDARD = "standard";
|
||||
|
||||
/**
|
||||
* The default 'best match' policy.
|
||||
*/
|
||||
public static final String BEST_MATCH = "best-match";
|
||||
|
||||
/**
|
||||
* The policy that ignores cookies.
|
||||
*/
|
||||
public static final String IGNORE_COOKIES = "ignoreCookies";
|
||||
|
||||
private CookieSpecs() {
|
||||
}
|
||||
|
||||
}
|
442
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/config/RequestConfig.java
поставляемый
Normal file
442
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/config/RequestConfig.java
поставляемый
Normal file
|
@ -0,0 +1,442 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client.config;
|
||||
|
||||
import java.net.InetAddress;
|
||||
import java.util.Collection;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpHost;
|
||||
|
||||
public class RequestConfig implements Cloneable {
|
||||
|
||||
public static final RequestConfig DEFAULT = new Builder().build();
|
||||
|
||||
private final boolean expectContinueEnabled;
|
||||
private final HttpHost proxy;
|
||||
private final InetAddress localAddress;
|
||||
private final boolean staleConnectionCheckEnabled;
|
||||
private final String cookieSpec;
|
||||
private final boolean redirectsEnabled;
|
||||
private final boolean relativeRedirectsAllowed;
|
||||
private final boolean circularRedirectsAllowed;
|
||||
private final int maxRedirects;
|
||||
private final boolean authenticationEnabled;
|
||||
private final Collection<String> targetPreferredAuthSchemes;
|
||||
private final Collection<String> proxyPreferredAuthSchemes;
|
||||
private final int connectionRequestTimeout;
|
||||
private final int connectTimeout;
|
||||
private final int socketTimeout;
|
||||
|
||||
RequestConfig(
|
||||
final boolean expectContinueEnabled,
|
||||
final HttpHost proxy,
|
||||
final InetAddress localAddress,
|
||||
final boolean staleConnectionCheckEnabled,
|
||||
final String cookieSpec,
|
||||
final boolean redirectsEnabled,
|
||||
final boolean relativeRedirectsAllowed,
|
||||
final boolean circularRedirectsAllowed,
|
||||
final int maxRedirects,
|
||||
final boolean authenticationEnabled,
|
||||
final Collection<String> targetPreferredAuthSchemes,
|
||||
final Collection<String> proxyPreferredAuthSchemes,
|
||||
final int connectionRequestTimeout,
|
||||
final int connectTimeout,
|
||||
final int socketTimeout) {
|
||||
super();
|
||||
this.expectContinueEnabled = expectContinueEnabled;
|
||||
this.proxy = proxy;
|
||||
this.localAddress = localAddress;
|
||||
this.staleConnectionCheckEnabled = staleConnectionCheckEnabled;
|
||||
this.cookieSpec = cookieSpec;
|
||||
this.redirectsEnabled = redirectsEnabled;
|
||||
this.relativeRedirectsAllowed = relativeRedirectsAllowed;
|
||||
this.circularRedirectsAllowed = circularRedirectsAllowed;
|
||||
this.maxRedirects = maxRedirects;
|
||||
this.authenticationEnabled = authenticationEnabled;
|
||||
this.targetPreferredAuthSchemes = targetPreferredAuthSchemes;
|
||||
this.proxyPreferredAuthSchemes = proxyPreferredAuthSchemes;
|
||||
this.connectionRequestTimeout = connectionRequestTimeout;
|
||||
this.connectTimeout = connectTimeout;
|
||||
this.socketTimeout = socketTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether the 'Expect: 100-Continue' handshake is enabled
|
||||
* for entity enclosing methods. The purpose of the 'Expect: 100-Continue'
|
||||
* handshake is to allow a client that is sending a request message with
|
||||
* a request body to determine if the origin server is willing to
|
||||
* accept the request (based on the request headers) before the client
|
||||
* sends the request body.
|
||||
* <p/>
|
||||
* The use of the 'Expect: 100-continue' handshake can result in
|
||||
* a noticeable performance improvement for entity enclosing requests
|
||||
* (such as POST and PUT) that require the target server's
|
||||
* authentication.
|
||||
* <p/>
|
||||
* 'Expect: 100-continue' handshake should be used with caution, as it
|
||||
* may cause problems with HTTP servers and proxies that do not support
|
||||
* HTTP/1.1 protocol.
|
||||
* <p/>
|
||||
* Default: <code>false</code>
|
||||
*/
|
||||
public boolean isExpectContinueEnabled() {
|
||||
return expectContinueEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns HTTP proxy to be used for request execution.
|
||||
* <p/>
|
||||
* Default: <code>null</code>
|
||||
*/
|
||||
public HttpHost getProxy() {
|
||||
return proxy;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns local address to be used for request execution.
|
||||
* <p/>
|
||||
* On machines with multiple network interfaces, this parameter
|
||||
* can be used to select the network interface from which the
|
||||
* connection originates.
|
||||
* <p/>
|
||||
* Default: <code>null</code>
|
||||
*/
|
||||
public InetAddress getLocalAddress() {
|
||||
return localAddress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether stale connection check is to be used. The stale
|
||||
* connection check can cause up to 30 millisecond overhead per request and
|
||||
* should be used only when appropriate. For performance critical
|
||||
* operations this check should be disabled.
|
||||
* <p/>
|
||||
* Default: <code>true</code>
|
||||
*/
|
||||
public boolean isStaleConnectionCheckEnabled() {
|
||||
return staleConnectionCheckEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the name of the cookie specification to be used for HTTP state
|
||||
* management.
|
||||
* <p/>
|
||||
* Default: <code>null</code>
|
||||
*/
|
||||
public String getCookieSpec() {
|
||||
return cookieSpec;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether redirects should be handled automatically.
|
||||
* <p/>
|
||||
* Default: <code>true</code>
|
||||
*/
|
||||
public boolean isRedirectsEnabled() {
|
||||
return redirectsEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether relative redirects should be rejected. HTTP specification
|
||||
* requires the location value be an absolute URI.
|
||||
* <p/>
|
||||
* Default: <code>true</code>
|
||||
*/
|
||||
public boolean isRelativeRedirectsAllowed() {
|
||||
return relativeRedirectsAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines 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
|
||||
* <p/>
|
||||
* Default: <code>false</code>
|
||||
*/
|
||||
public boolean isCircularRedirectsAllowed() {
|
||||
return circularRedirectsAllowed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the maximum number of redirects to be followed. The limit on number
|
||||
* of redirects is intended to prevent infinite loops.
|
||||
* <p/>
|
||||
* Default: <code>50</code>
|
||||
*/
|
||||
public int getMaxRedirects() {
|
||||
return maxRedirects;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines whether authentication should be handled automatically.
|
||||
* <p/>
|
||||
* Default: <code>true</code>
|
||||
*/
|
||||
public boolean isAuthenticationEnabled() {
|
||||
return authenticationEnabled;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the order of preference for supported authentication schemes
|
||||
* when authenticating with the target host.
|
||||
* <p/>
|
||||
* Default: <code>null</code>
|
||||
*/
|
||||
public Collection<String> getTargetPreferredAuthSchemes() {
|
||||
return targetPreferredAuthSchemes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the order of preference for supported authentication schemes
|
||||
* when authenticating with the proxy host.
|
||||
* <p/>
|
||||
* Default: <code>null</code>
|
||||
*/
|
||||
public Collection<String> getProxyPreferredAuthSchemes() {
|
||||
return proxyPreferredAuthSchemes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the timeout in milliseconds used when requesting a connection
|
||||
* from the connection manager. A timeout value of zero is interpreted
|
||||
* as an infinite timeout.
|
||||
* <p/>
|
||||
* A timeout value of zero is interpreted as an infinite timeout.
|
||||
* A negative value is interpreted as undefined (system default).
|
||||
* <p/>
|
||||
* Default: <code>-1</code>
|
||||
*/
|
||||
public int getConnectionRequestTimeout() {
|
||||
return connectionRequestTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines the timeout in milliseconds until a connection is established.
|
||||
* A timeout value of zero is interpreted as an infinite timeout.
|
||||
* <p/>
|
||||
* A timeout value of zero is interpreted as an infinite timeout.
|
||||
* A negative value is interpreted as undefined (system default).
|
||||
* <p/>
|
||||
* Default: <code>-1</code>
|
||||
*/
|
||||
public int getConnectTimeout() {
|
||||
return connectTimeout;
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines the socket timeout (<code>SO_TIMEOUT</code>) in milliseconds,
|
||||
* which is the timeout for waiting for data or, put differently,
|
||||
* a maximum period inactivity between two consecutive data packets).
|
||||
* <p/>
|
||||
* A timeout value of zero is interpreted as an infinite timeout.
|
||||
* A negative value is interpreted as undefined (system default).
|
||||
* <p/>
|
||||
* Default: <code>-1</code>
|
||||
*/
|
||||
public int getSocketTimeout() {
|
||||
return socketTimeout;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected RequestConfig clone() throws CloneNotSupportedException {
|
||||
return (RequestConfig) super.clone();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append(", expectContinueEnabled=").append(expectContinueEnabled);
|
||||
builder.append(", proxy=").append(proxy);
|
||||
builder.append(", localAddress=").append(localAddress);
|
||||
builder.append(", staleConnectionCheckEnabled=").append(staleConnectionCheckEnabled);
|
||||
builder.append(", cookieSpec=").append(cookieSpec);
|
||||
builder.append(", redirectsEnabled=").append(redirectsEnabled);
|
||||
builder.append(", relativeRedirectsAllowed=").append(relativeRedirectsAllowed);
|
||||
builder.append(", maxRedirects=").append(maxRedirects);
|
||||
builder.append(", circularRedirectsAllowed=").append(circularRedirectsAllowed);
|
||||
builder.append(", authenticationEnabled=").append(authenticationEnabled);
|
||||
builder.append(", targetPreferredAuthSchemes=").append(targetPreferredAuthSchemes);
|
||||
builder.append(", proxyPreferredAuthSchemes=").append(proxyPreferredAuthSchemes);
|
||||
builder.append(", connectionRequestTimeout=").append(connectionRequestTimeout);
|
||||
builder.append(", connectTimeout=").append(connectTimeout);
|
||||
builder.append(", socketTimeout=").append(socketTimeout);
|
||||
builder.append("]");
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public static RequestConfig.Builder custom() {
|
||||
return new Builder();
|
||||
}
|
||||
|
||||
public static RequestConfig.Builder copy(final RequestConfig config) {
|
||||
return new Builder()
|
||||
.setExpectContinueEnabled(config.isExpectContinueEnabled())
|
||||
.setProxy(config.getProxy())
|
||||
.setLocalAddress(config.getLocalAddress())
|
||||
.setStaleConnectionCheckEnabled(config.isStaleConnectionCheckEnabled())
|
||||
.setCookieSpec(config.getCookieSpec())
|
||||
.setRedirectsEnabled(config.isRedirectsEnabled())
|
||||
.setRelativeRedirectsAllowed(config.isRelativeRedirectsAllowed())
|
||||
.setCircularRedirectsAllowed(config.isCircularRedirectsAllowed())
|
||||
.setMaxRedirects(config.getMaxRedirects())
|
||||
.setAuthenticationEnabled(config.isAuthenticationEnabled())
|
||||
.setTargetPreferredAuthSchemes(config.getTargetPreferredAuthSchemes())
|
||||
.setProxyPreferredAuthSchemes(config.getProxyPreferredAuthSchemes())
|
||||
.setConnectionRequestTimeout(config.getConnectionRequestTimeout())
|
||||
.setConnectTimeout(config.getConnectTimeout())
|
||||
.setSocketTimeout(config.getSocketTimeout());
|
||||
}
|
||||
|
||||
public static class Builder {
|
||||
|
||||
private boolean expectContinueEnabled;
|
||||
private HttpHost proxy;
|
||||
private InetAddress localAddress;
|
||||
private boolean staleConnectionCheckEnabled;
|
||||
private String cookieSpec;
|
||||
private boolean redirectsEnabled;
|
||||
private boolean relativeRedirectsAllowed;
|
||||
private boolean circularRedirectsAllowed;
|
||||
private int maxRedirects;
|
||||
private boolean authenticationEnabled;
|
||||
private Collection<String> targetPreferredAuthSchemes;
|
||||
private Collection<String> proxyPreferredAuthSchemes;
|
||||
private int connectionRequestTimeout;
|
||||
private int connectTimeout;
|
||||
private int socketTimeout;
|
||||
|
||||
Builder() {
|
||||
super();
|
||||
this.staleConnectionCheckEnabled = true;
|
||||
this.redirectsEnabled = true;
|
||||
this.maxRedirects = 50;
|
||||
this.relativeRedirectsAllowed = true;
|
||||
this.authenticationEnabled = true;
|
||||
this.connectionRequestTimeout = -1;
|
||||
this.connectTimeout = -1;
|
||||
this.socketTimeout = -1;
|
||||
}
|
||||
|
||||
public Builder setExpectContinueEnabled(final boolean expectContinueEnabled) {
|
||||
this.expectContinueEnabled = expectContinueEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setProxy(final HttpHost proxy) {
|
||||
this.proxy = proxy;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setLocalAddress(final InetAddress localAddress) {
|
||||
this.localAddress = localAddress;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setStaleConnectionCheckEnabled(final boolean staleConnectionCheckEnabled) {
|
||||
this.staleConnectionCheckEnabled = staleConnectionCheckEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCookieSpec(final String cookieSpec) {
|
||||
this.cookieSpec = cookieSpec;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setRedirectsEnabled(final boolean redirectsEnabled) {
|
||||
this.redirectsEnabled = redirectsEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setRelativeRedirectsAllowed(final boolean relativeRedirectsAllowed) {
|
||||
this.relativeRedirectsAllowed = relativeRedirectsAllowed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setCircularRedirectsAllowed(final boolean circularRedirectsAllowed) {
|
||||
this.circularRedirectsAllowed = circularRedirectsAllowed;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setMaxRedirects(final int maxRedirects) {
|
||||
this.maxRedirects = maxRedirects;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setAuthenticationEnabled(final boolean authenticationEnabled) {
|
||||
this.authenticationEnabled = authenticationEnabled;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setTargetPreferredAuthSchemes(final Collection<String> targetPreferredAuthSchemes) {
|
||||
this.targetPreferredAuthSchemes = targetPreferredAuthSchemes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setProxyPreferredAuthSchemes(final Collection<String> proxyPreferredAuthSchemes) {
|
||||
this.proxyPreferredAuthSchemes = proxyPreferredAuthSchemes;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setConnectionRequestTimeout(final int connectionRequestTimeout) {
|
||||
this.connectionRequestTimeout = connectionRequestTimeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setConnectTimeout(final int connectTimeout) {
|
||||
this.connectTimeout = connectTimeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
public Builder setSocketTimeout(final int socketTimeout) {
|
||||
this.socketTimeout = socketTimeout;
|
||||
return this;
|
||||
}
|
||||
|
||||
public RequestConfig build() {
|
||||
return new RequestConfig(
|
||||
expectContinueEnabled,
|
||||
proxy,
|
||||
localAddress,
|
||||
staleConnectionCheckEnabled,
|
||||
cookieSpec,
|
||||
redirectsEnabled,
|
||||
relativeRedirectsAllowed,
|
||||
circularRedirectsAllowed,
|
||||
maxRedirects,
|
||||
authenticationEnabled,
|
||||
targetPreferredAuthSchemes,
|
||||
proxyPreferredAuthSchemes,
|
||||
connectionRequestTimeout,
|
||||
connectTimeout,
|
||||
socketTimeout);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -1,6 +1,3 @@
|
|||
<html>
|
||||
<head>
|
||||
<!--
|
||||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
|
@ -27,9 +24,8 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
-->
|
||||
</head>
|
||||
<body>
|
||||
The API for client-side state management via cookies.
|
||||
</body>
|
||||
</html>
|
||||
|
||||
/**
|
||||
* Client configuration APIs.
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.config;
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -31,6 +32,7 @@ import java.io.OutputStream;
|
|||
|
||||
import ch.boye.httpclientandroidlib.HttpEntity;
|
||||
import ch.boye.httpclientandroidlib.entity.HttpEntityWrapper;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* Common base class for decompressing {@link HttpEntity} implementations.
|
||||
|
@ -45,8 +47,8 @@ abstract class DecompressingEntity extends HttpEntityWrapper {
|
|||
private static final int BUFFER_SIZE = 1024 * 2;
|
||||
|
||||
/**
|
||||
* DecompressingEntities are not repeatable, so they will return the same
|
||||
* InputStream instance when {@link #getContent()} is called.
|
||||
* {@link #getContent()} method must return the same {@link InputStream}
|
||||
* instance when DecompressingEntity is wrapping a streaming entity.
|
||||
*/
|
||||
private InputStream content;
|
||||
|
||||
|
@ -60,7 +62,12 @@ abstract class DecompressingEntity extends HttpEntityWrapper {
|
|||
super(wrapped);
|
||||
}
|
||||
|
||||
abstract InputStream getDecompressingInputStream(final InputStream wrapped) throws IOException;
|
||||
abstract InputStream decorate(final InputStream wrapped) throws IOException;
|
||||
|
||||
private InputStream getDecompressingStream() throws IOException {
|
||||
final InputStream in = wrappedEntity.getContent();
|
||||
return new LazyDecompressingInputStream(in, this);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
|
@ -69,11 +76,11 @@ abstract class DecompressingEntity extends HttpEntityWrapper {
|
|||
public InputStream getContent() throws IOException {
|
||||
if (wrappedEntity.isStreaming()) {
|
||||
if (content == null) {
|
||||
content = getDecompressingInputStream(wrappedEntity.getContent());
|
||||
content = getDecompressingStream();
|
||||
}
|
||||
return content;
|
||||
} else {
|
||||
return getDecompressingInputStream(wrappedEntity.getContent());
|
||||
return getDecompressingStream();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -81,16 +88,12 @@ abstract class DecompressingEntity extends HttpEntityWrapper {
|
|||
* {@inheritDoc}
|
||||
*/
|
||||
@Override
|
||||
public void writeTo(OutputStream outstream) throws IOException {
|
||||
if (outstream == null) {
|
||||
throw new IllegalArgumentException("Output stream may not be null");
|
||||
}
|
||||
InputStream instream = getContent();
|
||||
public void writeTo(final OutputStream outstream) throws IOException {
|
||||
Args.notNull(outstream, "Output stream");
|
||||
final InputStream instream = getContent();
|
||||
try {
|
||||
byte[] buffer = new byte[BUFFER_SIZE];
|
||||
|
||||
final byte[] buffer = new byte[BUFFER_SIZE];
|
||||
int l;
|
||||
|
||||
while ((l = instream.read(buffer)) != -1) {
|
||||
outstream.write(buffer, 0, l);
|
||||
}
|
||||
|
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -22,28 +23,26 @@
|
|||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.entity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PushbackInputStream;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
import ch.boye.httpclientandroidlib.Header;
|
||||
import ch.boye.httpclientandroidlib.HttpEntity;
|
||||
import ch.boye.httpclientandroidlib.entity.HttpEntityWrapper;
|
||||
|
||||
/**
|
||||
* {@link HttpEntityWrapper} responsible for handling deflate Content Coded responses. In RFC2616
|
||||
* terms, <code>deflate</code> means a <code>zlib</code> stream as defined in RFC1950. Some server
|
||||
* implementations have misinterpreted RFC2616 to mean that a <code>deflate</code> stream as
|
||||
* defined in RFC1951 should be used (or maybe they did that since that's how IE behaves?). It's
|
||||
* confusing that <code>deflate</code> in HTTP 1.1 means <code>zlib</code> streams rather than
|
||||
* <code>deflate</code> streams. We handle both types in here, since that's what is seen on the
|
||||
* internet. Moral - prefer <code>gzip</code>!
|
||||
* {@link ch.boye.httpclientandroidlib.entity.HttpEntityWrapper} responsible for handling
|
||||
* deflate Content Coded responses. In RFC2616 terms, <code>deflate</code>
|
||||
* means a <code>zlib</code> stream as defined in RFC1950. Some server
|
||||
* implementations have misinterpreted RFC2616 to mean that a
|
||||
* <code>deflate</code> stream as defined in RFC1951 should be used
|
||||
* (or maybe they did that since that's how IE behaves?). It's confusing
|
||||
* that <code>deflate</code> in HTTP 1.1 means <code>zlib</code> streams
|
||||
* rather than <code>deflate</code> streams. We handle both types in here,
|
||||
* since that's what is seen on the internet. Moral - prefer
|
||||
* <code>gzip</code>!
|
||||
*
|
||||
* @see GzipDecompressingEntity
|
||||
*
|
||||
|
@ -70,85 +69,8 @@ public class DeflateDecompressingEntity extends DecompressingEntity {
|
|||
* @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));
|
||||
}
|
||||
InputStream decorate(final InputStream wrapped) throws IOException {
|
||||
return new DeflateInputStream(wrapped);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
229
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/entity/DeflateInputStream.java
поставляемый
Normal file
229
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/entity/DeflateInputStream.java
поставляемый
Normal file
|
@ -0,0 +1,229 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.entity;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.PushbackInputStream;
|
||||
import java.util.zip.DataFormatException;
|
||||
import java.util.zip.Inflater;
|
||||
import java.util.zip.InflaterInputStream;
|
||||
|
||||
/** Deflate input stream. This class includes logic needed for various Rfc's in order
|
||||
* to reasonably implement the "deflate" compression style.
|
||||
*/
|
||||
public class DeflateInputStream extends InputStream
|
||||
{
|
||||
private InputStream sourceStream;
|
||||
|
||||
public DeflateInputStream(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. */
|
||||
final byte[] peeked = new byte[6];
|
||||
|
||||
final PushbackInputStream pushback = new PushbackInputStream(wrapped, peeked.length);
|
||||
|
||||
final int headerLength = pushback.read(peeked);
|
||||
|
||||
if (headerLength == -1) {
|
||||
throw new IOException("Unable to read the response");
|
||||
}
|
||||
|
||||
/* We try to read the first uncompressed byte. */
|
||||
final byte[] dummy = new byte[1];
|
||||
|
||||
final 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);
|
||||
sourceStream = new DeflateStream(pushback, new Inflater());
|
||||
} catch (final DataFormatException e) {
|
||||
|
||||
/* Presume that it's an RFC1951 deflate stream rather than RFC1950 zlib stream and try
|
||||
* again. */
|
||||
pushback.unread(peeked, 0, headerLength);
|
||||
sourceStream = new DeflateStream(pushback, new Inflater(true));
|
||||
} finally {
|
||||
inf.end();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/** Read a byte.
|
||||
*/
|
||||
@Override
|
||||
public int read()
|
||||
throws IOException
|
||||
{
|
||||
return sourceStream.read();
|
||||
}
|
||||
|
||||
/** Read lots of bytes.
|
||||
*/
|
||||
@Override
|
||||
public int read(final byte[] b)
|
||||
throws IOException
|
||||
{
|
||||
return sourceStream.read(b);
|
||||
}
|
||||
|
||||
/** Read lots of specific bytes.
|
||||
*/
|
||||
@Override
|
||||
public int read(final byte[] b, final int off, final int len)
|
||||
throws IOException
|
||||
{
|
||||
return sourceStream.read(b,off,len);
|
||||
}
|
||||
|
||||
/** Skip
|
||||
*/
|
||||
@Override
|
||||
public long skip(final long n)
|
||||
throws IOException
|
||||
{
|
||||
return sourceStream.skip(n);
|
||||
}
|
||||
|
||||
/** Get available.
|
||||
*/
|
||||
@Override
|
||||
public int available()
|
||||
throws IOException
|
||||
{
|
||||
return sourceStream.available();
|
||||
}
|
||||
|
||||
/** Mark.
|
||||
*/
|
||||
@Override
|
||||
public void mark(final int readLimit)
|
||||
{
|
||||
sourceStream.mark(readLimit);
|
||||
}
|
||||
|
||||
/** Reset.
|
||||
*/
|
||||
@Override
|
||||
public void reset()
|
||||
throws IOException
|
||||
{
|
||||
sourceStream.reset();
|
||||
}
|
||||
|
||||
/** Check if mark is supported.
|
||||
*/
|
||||
@Override
|
||||
public boolean markSupported()
|
||||
{
|
||||
return sourceStream.markSupported();
|
||||
}
|
||||
|
||||
/** Close.
|
||||
*/
|
||||
@Override
|
||||
public void close()
|
||||
throws IOException
|
||||
{
|
||||
sourceStream.close();
|
||||
}
|
||||
|
||||
static class DeflateStream extends InflaterInputStream {
|
||||
|
||||
private boolean closed = false;
|
||||
|
||||
public DeflateStream(final InputStream in, final Inflater inflater) {
|
||||
super(in, inflater);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if (closed) {
|
||||
return;
|
||||
}
|
||||
closed = true;
|
||||
inf.end();
|
||||
super.close();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
342
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/entity/EntityBuilder.java
поставляемый
Normal file
342
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/entity/EntityBuilder.java
поставляемый
Normal file
|
@ -0,0 +1,342 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client.entity;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpEntity;
|
||||
import ch.boye.httpclientandroidlib.NameValuePair;
|
||||
import ch.boye.httpclientandroidlib.annotation.NotThreadSafe;
|
||||
import ch.boye.httpclientandroidlib.entity.AbstractHttpEntity;
|
||||
import ch.boye.httpclientandroidlib.entity.BasicHttpEntity;
|
||||
import ch.boye.httpclientandroidlib.entity.ByteArrayEntity;
|
||||
import ch.boye.httpclientandroidlib.entity.ContentType;
|
||||
import ch.boye.httpclientandroidlib.entity.FileEntity;
|
||||
import ch.boye.httpclientandroidlib.entity.InputStreamEntity;
|
||||
import ch.boye.httpclientandroidlib.entity.SerializableEntity;
|
||||
import ch.boye.httpclientandroidlib.entity.StringEntity;
|
||||
|
||||
/**
|
||||
* Builder for {@link HttpEntity} instances.
|
||||
* <p/>
|
||||
* Several setter methods of this builder are mutually exclusive. In case of multiple invocations
|
||||
* of the following methods only the last one will have effect:
|
||||
* <ul>
|
||||
* <li>{@link #setText(String)}</li>
|
||||
* <li>{@link #setBinary(byte[])}</li>
|
||||
* <li>{@link #setStream(java.io.InputStream)}</li>
|
||||
* <li>{@link #setSerializable(java.io.Serializable)}</li>
|
||||
* <li>{@link #setParameters(java.util.List)}</li>
|
||||
* <li>{@link #setParameters(ch.boye.httpclientandroidlib.NameValuePair...)}</li>
|
||||
* <li>{@link #setFile(java.io.File)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class EntityBuilder {
|
||||
|
||||
private String text;
|
||||
private byte[] binary;
|
||||
private InputStream stream;
|
||||
private List<NameValuePair> parameters;
|
||||
private Serializable serializable;
|
||||
private File file;
|
||||
private ContentType contentType;
|
||||
private String contentEncoding;
|
||||
private boolean chunked;
|
||||
private boolean gzipCompress;
|
||||
|
||||
EntityBuilder() {
|
||||
super();
|
||||
}
|
||||
|
||||
public static EntityBuilder create() {
|
||||
return new EntityBuilder();
|
||||
}
|
||||
|
||||
private void clearContent() {
|
||||
this.text = null;
|
||||
this.binary = null;
|
||||
this.stream = null;
|
||||
this.parameters = null;
|
||||
this.serializable = null;
|
||||
this.file = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns entity content as a string if set using {@link #setText(String)} method.
|
||||
*/
|
||||
public String getText() {
|
||||
return text;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets entity content as a string. This method is mutually exclusive with
|
||||
* {@link #setBinary(byte[])},
|
||||
* {@link #setStream(java.io.InputStream)} ,
|
||||
* {@link #setSerializable(java.io.Serializable)} ,
|
||||
* {@link #setParameters(java.util.List)},
|
||||
* {@link #setParameters(ch.boye.httpclientandroidlib.NameValuePair...)}
|
||||
* {@link #setFile(java.io.File)} methods.
|
||||
*/
|
||||
public EntityBuilder setText(final String text) {
|
||||
clearContent();
|
||||
this.text = text;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns entity content as a byte array if set using
|
||||
* {@link #setBinary(byte[])} method.
|
||||
*/
|
||||
public byte[] getBinary() {
|
||||
return binary;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets entity content as a byte array. This method is mutually exclusive with
|
||||
* {@link #setText(String)},
|
||||
* {@link #setStream(java.io.InputStream)} ,
|
||||
* {@link #setSerializable(java.io.Serializable)} ,
|
||||
* {@link #setParameters(java.util.List)},
|
||||
* {@link #setParameters(ch.boye.httpclientandroidlib.NameValuePair...)}
|
||||
* {@link #setFile(java.io.File)} methods.
|
||||
*/
|
||||
public EntityBuilder setBinary(final byte[] binary) {
|
||||
clearContent();
|
||||
this.binary = binary;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns entity content as a {@link InputStream} if set using
|
||||
* {@link #setStream(java.io.InputStream)} method.
|
||||
*/
|
||||
public InputStream getStream() {
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets entity content as a {@link InputStream}. This method is mutually exclusive with
|
||||
* {@link #setText(String)},
|
||||
* {@link #setBinary(byte[])},
|
||||
* {@link #setSerializable(java.io.Serializable)} ,
|
||||
* {@link #setParameters(java.util.List)},
|
||||
* {@link #setParameters(ch.boye.httpclientandroidlib.NameValuePair...)}
|
||||
* {@link #setFile(java.io.File)} methods.
|
||||
*/
|
||||
public EntityBuilder setStream(final InputStream stream) {
|
||||
clearContent();
|
||||
this.stream = stream;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns entity content as a parameter list if set using
|
||||
* {@link #setParameters(java.util.List)} or
|
||||
* {@link #setParameters(ch.boye.httpclientandroidlib.NameValuePair...)} methods.
|
||||
*/
|
||||
public List<NameValuePair> getParameters() {
|
||||
return parameters;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets entity content as a parameter list. This method is mutually exclusive with
|
||||
* {@link #setText(String)},
|
||||
* {@link #setBinary(byte[])},
|
||||
* {@link #setStream(java.io.InputStream)} ,
|
||||
* {@link #setSerializable(java.io.Serializable)} ,
|
||||
* {@link #setFile(java.io.File)} methods.
|
||||
*/
|
||||
public EntityBuilder setParameters(final List<NameValuePair> parameters) {
|
||||
clearContent();
|
||||
this.parameters = parameters;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets entity content as a parameter list. This method is mutually exclusive with
|
||||
* {@link #setText(String)},
|
||||
* {@link #setBinary(byte[])},
|
||||
* {@link #setStream(java.io.InputStream)} ,
|
||||
* {@link #setSerializable(java.io.Serializable)} ,
|
||||
* {@link #setFile(java.io.File)} methods.
|
||||
*/
|
||||
public EntityBuilder setParameters(final NameValuePair... parameters) {
|
||||
return setParameters(Arrays.asList(parameters));
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns entity content as a {@link Serializable} if set using
|
||||
* {@link #setSerializable(java.io.Serializable)} method.
|
||||
*/
|
||||
public Serializable getSerializable() {
|
||||
return serializable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets entity content as a {@link Serializable}. This method is mutually exclusive with
|
||||
* {@link #setText(String)},
|
||||
* {@link #setBinary(byte[])},
|
||||
* {@link #setStream(java.io.InputStream)} ,
|
||||
* {@link #setParameters(java.util.List)},
|
||||
* {@link #setParameters(ch.boye.httpclientandroidlib.NameValuePair...)}
|
||||
* {@link #setFile(java.io.File)} methods.
|
||||
*/
|
||||
public EntityBuilder setSerializable(final Serializable serializable) {
|
||||
clearContent();
|
||||
this.serializable = serializable;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns entity content as a {@link File} if set using
|
||||
* {@link #setFile(java.io.File)} method.
|
||||
*/
|
||||
public File getFile() {
|
||||
return file;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets entity content as a {@link File}. This method is mutually exclusive with
|
||||
* {@link #setText(String)},
|
||||
* {@link #setBinary(byte[])},
|
||||
* {@link #setStream(java.io.InputStream)} ,
|
||||
* {@link #setParameters(java.util.List)},
|
||||
* {@link #setParameters(ch.boye.httpclientandroidlib.NameValuePair...)}
|
||||
* {@link #setSerializable(java.io.Serializable)} methods.
|
||||
*/
|
||||
public EntityBuilder setFile(final File file) {
|
||||
clearContent();
|
||||
this.file = file;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns {@link ContentType} of the entity, if set.
|
||||
*/
|
||||
public ContentType getContentType() {
|
||||
return contentType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets {@link ContentType} of the entity.
|
||||
*/
|
||||
public EntityBuilder setContentType(final ContentType contentType) {
|
||||
this.contentType = contentType;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns content encoding of the entity, if set.
|
||||
*/
|
||||
public String getContentEncoding() {
|
||||
return contentEncoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets content encoding of the entity.
|
||||
*/
|
||||
public EntityBuilder setContentEncoding(final String contentEncoding) {
|
||||
this.contentEncoding = contentEncoding;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if entity is to be chunk coded, <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean isChunked() {
|
||||
return chunked;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes entity chunk coded.
|
||||
*/
|
||||
public EntityBuilder chunked() {
|
||||
this.chunked = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if entity is to be GZIP compressed, <code>false</code> otherwise.
|
||||
*/
|
||||
public boolean isGzipCompress() {
|
||||
return gzipCompress;
|
||||
}
|
||||
|
||||
/**
|
||||
* Makes entity GZIP compressed.
|
||||
*/
|
||||
public EntityBuilder gzipCompress() {
|
||||
this.gzipCompress = true;
|
||||
return this;
|
||||
}
|
||||
|
||||
private ContentType getContentOrDefault(final ContentType def) {
|
||||
return this.contentType != null ? this.contentType : def;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates new instance of {@link HttpEntity} based on the current state.
|
||||
*/
|
||||
public HttpEntity build() {
|
||||
final AbstractHttpEntity e;
|
||||
if (this.text != null) {
|
||||
e = new StringEntity(this.text, getContentOrDefault(ContentType.DEFAULT_TEXT));
|
||||
} else if (this.binary != null) {
|
||||
e = new ByteArrayEntity(this.binary, getContentOrDefault(ContentType.DEFAULT_BINARY));
|
||||
} else if (this.stream != null) {
|
||||
e = new InputStreamEntity(this.stream, 1, getContentOrDefault(ContentType.DEFAULT_BINARY));
|
||||
} else if (this.parameters != null) {
|
||||
e = new UrlEncodedFormEntity(this.parameters,
|
||||
this.contentType != null ? this.contentType.getCharset() : null);
|
||||
} else if (this.serializable != null) {
|
||||
e = new SerializableEntity(this.serializable);
|
||||
e.setContentType(ContentType.DEFAULT_BINARY.toString());
|
||||
} else if (this.file != null) {
|
||||
e = new FileEntity(this.file, getContentOrDefault(ContentType.DEFAULT_BINARY));
|
||||
} else {
|
||||
e = new BasicHttpEntity();
|
||||
}
|
||||
if (e.getContentType() != null && this.contentType != null) {
|
||||
e.setContentType(this.contentType.toString());
|
||||
}
|
||||
e.setContentEncoding(this.contentEncoding);
|
||||
e.setChunked(this.chunked);
|
||||
if (this.gzipCompress) {
|
||||
return new GzipCompressingEntity(e);
|
||||
}
|
||||
return e;
|
||||
}
|
||||
|
||||
}
|
113
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/entity/GzipCompressingEntity.java
поставляемый
Normal file
113
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/entity/GzipCompressingEntity.java
поставляемый
Normal file
|
@ -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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.entity;
|
||||
|
||||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.zip.GZIPOutputStream;
|
||||
|
||||
import ch.boye.httpclientandroidlib.Header;
|
||||
import ch.boye.httpclientandroidlib.HttpEntity;
|
||||
import ch.boye.httpclientandroidlib.entity.HttpEntityWrapper;
|
||||
import ch.boye.httpclientandroidlib.message.BasicHeader;
|
||||
import ch.boye.httpclientandroidlib.protocol.HTTP;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* Wrapping entity that compresses content when {@link #writeTo writing}.
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class GzipCompressingEntity extends HttpEntityWrapper {
|
||||
|
||||
private static final String GZIP_CODEC = "gzip";
|
||||
|
||||
public GzipCompressingEntity(final HttpEntity entity) {
|
||||
super(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Header getContentEncoding() {
|
||||
return new BasicHeader(HTTP.CONTENT_ENCODING, GZIP_CODEC);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getContentLength() {
|
||||
return -1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isChunked() {
|
||||
// force content chunking
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getContent() throws IOException {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void writeTo(final OutputStream outstream) throws IOException {
|
||||
Args.notNull(outstream, "Output stream");
|
||||
final GZIPOutputStream gzip = new GZIPOutputStream(outstream);
|
||||
wrappedEntity.writeTo(gzip);
|
||||
// Only close output stream if the wrapped entity has been
|
||||
// successfully written out
|
||||
gzip.close();
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -31,10 +32,10 @@ import java.util.zip.GZIPInputStream;
|
|||
|
||||
import ch.boye.httpclientandroidlib.Header;
|
||||
import ch.boye.httpclientandroidlib.HttpEntity;
|
||||
import ch.boye.httpclientandroidlib.entity.HttpEntityWrapper;
|
||||
|
||||
/**
|
||||
* {@link HttpEntityWrapper} for handling gzip Content Coded responses.
|
||||
* {@link ch.boye.httpclientandroidlib.entity.HttpEntityWrapper} for handling gzip
|
||||
* Content Coded responses.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
|
@ -52,7 +53,7 @@ public class GzipDecompressingEntity extends DecompressingEntity {
|
|||
}
|
||||
|
||||
@Override
|
||||
InputStream getDecompressingInputStream(final InputStream wrapped) throws IOException {
|
||||
InputStream decorate(final InputStream wrapped) throws IOException {
|
||||
return new GZIPInputStream(wrapped);
|
||||
}
|
||||
|
||||
|
|
105
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/entity/LazyDecompressingInputStream.java
поставляемый
Normal file
105
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/entity/LazyDecompressingInputStream.java
поставляемый
Normal file
|
@ -0,0 +1,105 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.entity;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.NotThreadSafe;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
/**
|
||||
* Lazy init InputStream wrapper.
|
||||
*/
|
||||
@NotThreadSafe
|
||||
class LazyDecompressingInputStream extends InputStream {
|
||||
|
||||
private final InputStream wrappedStream;
|
||||
|
||||
private final DecompressingEntity decompressingEntity;
|
||||
|
||||
private InputStream wrapperStream;
|
||||
|
||||
public LazyDecompressingInputStream(
|
||||
final InputStream wrappedStream,
|
||||
final DecompressingEntity decompressingEntity) {
|
||||
this.wrappedStream = wrappedStream;
|
||||
this.decompressingEntity = decompressingEntity;
|
||||
}
|
||||
|
||||
private void initWrapper() throws IOException {
|
||||
if (wrapperStream == null) {
|
||||
wrapperStream = decompressingEntity.decorate(wrappedStream);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read() throws IOException {
|
||||
initWrapper();
|
||||
return wrapperStream.read();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(final byte[] b) throws IOException {
|
||||
initWrapper();
|
||||
return wrapperStream.read(b);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int read(final byte[] b, final int off, final int len) throws IOException {
|
||||
initWrapper();
|
||||
return wrapperStream.read(b, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long skip(final long n) throws IOException {
|
||||
initWrapper();
|
||||
return wrapperStream.skip(n);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean markSupported() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int available() throws IOException {
|
||||
initWrapper();
|
||||
return wrapperStream.available();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
try {
|
||||
if (wrapperStream != null) {
|
||||
wrapperStream.close();
|
||||
}
|
||||
} finally {
|
||||
wrappedStream.close();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,20 +1,21 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
*
|
||||
* 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
|
||||
* 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.
|
||||
* 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
|
||||
|
@ -23,16 +24,16 @@
|
|||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client.entity;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.charset.Charset;
|
||||
import java.util.List;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.NotThreadSafe;
|
||||
|
||||
import ch.boye.httpclientandroidlib.NameValuePair;
|
||||
import ch.boye.httpclientandroidlib.annotation.NotThreadSafe;
|
||||
import ch.boye.httpclientandroidlib.client.utils.URLEncodedUtils;
|
||||
import ch.boye.httpclientandroidlib.entity.ContentType;
|
||||
import ch.boye.httpclientandroidlib.entity.StringEntity;
|
||||
import ch.boye.httpclientandroidlib.protocol.HTTP;
|
||||
|
||||
|
@ -50,15 +51,32 @@ public class UrlEncodedFormEntity extends StringEntity {
|
|||
* of parameters in the specified encoding.
|
||||
*
|
||||
* @param parameters list of name/value pairs
|
||||
* @param encoding encoding the name/value pairs be encoded with
|
||||
* @param charset encoding the name/value pairs be encoded with
|
||||
* @throws UnsupportedEncodingException if the encoding isn't supported
|
||||
*/
|
||||
public UrlEncodedFormEntity (
|
||||
final List <? extends NameValuePair> parameters,
|
||||
final String encoding) throws UnsupportedEncodingException {
|
||||
super(URLEncodedUtils.format(parameters, encoding), encoding);
|
||||
setContentType(URLEncodedUtils.CONTENT_TYPE + HTTP.CHARSET_PARAM +
|
||||
(encoding != null ? encoding : HTTP.DEFAULT_CONTENT_CHARSET));
|
||||
final String charset) throws UnsupportedEncodingException {
|
||||
super(URLEncodedUtils.format(parameters,
|
||||
charset != null ? charset : HTTP.DEF_CONTENT_CHARSET.name()),
|
||||
ContentType.create(URLEncodedUtils.CONTENT_TYPE, charset));
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link UrlEncodedFormEntity} with the list
|
||||
* of parameters in the specified encoding.
|
||||
*
|
||||
* @param parameters iterable collection of name/value pairs
|
||||
* @param charset encoding the name/value pairs be encoded with
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public UrlEncodedFormEntity (
|
||||
final Iterable <? extends NameValuePair> parameters,
|
||||
final Charset charset) {
|
||||
super(URLEncodedUtils.format(parameters,
|
||||
charset != null ? charset : HTTP.DEF_CONTENT_CHARSET),
|
||||
ContentType.create(URLEncodedUtils.CONTENT_TYPE, charset));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -70,7 +88,20 @@ public class UrlEncodedFormEntity extends StringEntity {
|
|||
*/
|
||||
public UrlEncodedFormEntity (
|
||||
final List <? extends NameValuePair> parameters) throws UnsupportedEncodingException {
|
||||
this(parameters, HTTP.DEFAULT_CONTENT_CHARSET);
|
||||
this(parameters, (Charset) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructs a new {@link UrlEncodedFormEntity} with the list
|
||||
* of parameters with the default encoding of {@link HTTP#DEFAULT_CONTENT_CHARSET}
|
||||
*
|
||||
* @param parameters iterable collection of name/value pairs
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public UrlEncodedFormEntity (
|
||||
final Iterable <? extends NameValuePair> parameters) {
|
||||
this(parameters, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
31
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/entity/package-info.java
поставляемый
Normal file
31
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/entity/package-info.java
поставляемый
Normal file
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Client specific HTTP entity implementations.
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.entity;
|
|
@ -27,39 +27,37 @@
|
|||
|
||||
package ch.boye.httpclientandroidlib.client.methods;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ch.boye.httpclientandroidlib.client.HttpClient;
|
||||
import ch.boye.httpclientandroidlib.conn.ClientConnectionManager;
|
||||
import ch.boye.httpclientandroidlib.conn.ClientConnectionRequest;
|
||||
import ch.boye.httpclientandroidlib.conn.ConnectionReleaseTrigger;
|
||||
import ch.boye.httpclientandroidlib.conn.ManagedClientConnection;
|
||||
import ch.boye.httpclientandroidlib.impl.conn.tsccm.ThreadSafeClientConnManager;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
/**
|
||||
* Interface representing an HTTP request that can be aborted by shutting
|
||||
* down the underlying HTTP connection.
|
||||
*
|
||||
*
|
||||
* <!-- empty lines to avoid svn diff problems -->
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.3) use {@link HttpExecutionAware}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AbortableHttpRequest {
|
||||
|
||||
/**
|
||||
* Sets the {@link ClientConnectionRequest} callback that can be
|
||||
* used to abort a long-lived request for a connection.
|
||||
* Sets the {@link ch.boye.httpclientandroidlib.conn.ClientConnectionRequest}
|
||||
* callback that can be used to abort a long-lived request for a connection.
|
||||
* If the request is already aborted, throws an {@link IOException}.
|
||||
*
|
||||
* @see ClientConnectionManager
|
||||
* @see ThreadSafeClientConnManager
|
||||
* @see ch.boye.httpclientandroidlib.conn.ClientConnectionManager
|
||||
*/
|
||||
void setConnectionRequest(ClientConnectionRequest connRequest) throws IOException;
|
||||
|
||||
/**
|
||||
* Sets the {@link ConnectionReleaseTrigger} callback that can
|
||||
* be used to abort an active connection.
|
||||
* Typically, this will be the {@link ManagedClientConnection} itself.
|
||||
* Typically, this will be the
|
||||
* {@link ch.boye.httpclientandroidlib.conn.ManagedClientConnection} itself.
|
||||
* If the request is already aborted, throws an {@link IOException}.
|
||||
*/
|
||||
void setReleaseTrigger(ConnectionReleaseTrigger releaseTrigger) throws IOException;
|
||||
|
@ -70,12 +68,12 @@ public interface AbortableHttpRequest {
|
|||
* the next execution. Aborting this request will cause all subsequent
|
||||
* executions with this request to fail.
|
||||
*
|
||||
* @see HttpClient#execute(HttpUriRequest)
|
||||
* @see HttpClient#execute(ch.boye.httpclientandroidlib.HttpHost,
|
||||
* @see ch.boye.httpclientandroidlib.client.HttpClient#execute(HttpUriRequest)
|
||||
* @see ch.boye.httpclientandroidlib.client.HttpClient#execute(ch.boye.httpclientandroidlib.HttpHost,
|
||||
* ch.boye.httpclientandroidlib.HttpRequest)
|
||||
* @see HttpClient#execute(HttpUriRequest,
|
||||
* @see ch.boye.httpclientandroidlib.client.HttpClient#execute(HttpUriRequest,
|
||||
* ch.boye.httpclientandroidlib.protocol.HttpContext)
|
||||
* @see HttpClient#execute(ch.boye.httpclientandroidlib.HttpHost,
|
||||
* @see ch.boye.httpclientandroidlib.client.HttpClient#execute(ch.boye.httpclientandroidlib.HttpHost,
|
||||
* ch.boye.httpclientandroidlib.HttpRequest, ch.boye.httpclientandroidlib.protocol.HttpContext)
|
||||
*/
|
||||
void abort();
|
||||
|
|
131
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/methods/AbstractExecutionAwareRequest.java
поставляемый
Normal file
131
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/methods/AbstractExecutionAwareRequest.java
поставляемый
Normal file
|
@ -0,0 +1,131 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* 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
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.methods;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.atomic.AtomicBoolean;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpRequest;
|
||||
import ch.boye.httpclientandroidlib.client.utils.CloneUtils;
|
||||
import ch.boye.httpclientandroidlib.concurrent.Cancellable;
|
||||
import ch.boye.httpclientandroidlib.conn.ClientConnectionRequest;
|
||||
import ch.boye.httpclientandroidlib.conn.ConnectionReleaseTrigger;
|
||||
import ch.boye.httpclientandroidlib.message.AbstractHttpMessage;
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public abstract class AbstractExecutionAwareRequest extends AbstractHttpMessage implements
|
||||
HttpExecutionAware, AbortableHttpRequest, Cloneable, HttpRequest {
|
||||
|
||||
private final AtomicBoolean aborted;
|
||||
private final AtomicReference<Cancellable> cancellableRef;
|
||||
|
||||
protected AbstractExecutionAwareRequest() {
|
||||
super();
|
||||
this.aborted = new AtomicBoolean(false);
|
||||
this.cancellableRef = new AtomicReference<Cancellable>(null);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setConnectionRequest(final ClientConnectionRequest connRequest) {
|
||||
setCancellable(new Cancellable() {
|
||||
|
||||
public boolean cancel() {
|
||||
connRequest.abortRequest();
|
||||
return true;
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setReleaseTrigger(final ConnectionReleaseTrigger releaseTrigger) {
|
||||
setCancellable(new Cancellable() {
|
||||
|
||||
public boolean cancel() {
|
||||
try {
|
||||
releaseTrigger.abortConnection();
|
||||
return true;
|
||||
} catch (final IOException ex) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
public void abort() {
|
||||
if (this.aborted.compareAndSet(false, true)) {
|
||||
final Cancellable cancellable = this.cancellableRef.getAndSet(null);
|
||||
if (cancellable != null) {
|
||||
cancellable.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isAborted() {
|
||||
return this.aborted.get();
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
*/
|
||||
public void setCancellable(final Cancellable cancellable) {
|
||||
if (!this.aborted.get()) {
|
||||
this.cancellableRef.set(cancellable);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
final AbstractExecutionAwareRequest clone = (AbstractExecutionAwareRequest) super.clone();
|
||||
clone.headergroup = CloneUtils.cloneObject(this.headergroup);
|
||||
clone.params = CloneUtils.cloneObject(this.params);
|
||||
return clone;
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
*/
|
||||
public void completed() {
|
||||
this.cancellableRef.set(null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resets internal state of the request making it reusable.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public void reset() {
|
||||
final Cancellable cancellable = this.cancellableRef.getAndSet(null);
|
||||
if (cancellable != null) {
|
||||
cancellable.cancel();
|
||||
}
|
||||
this.aborted.set(false);
|
||||
}
|
||||
|
||||
}
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче