- * this : The intrinsic lock of the object in whose class the field is defined.
- *
- *
- * class-name.this : For inner classes, it may be necessary to disambiguate 'this';
- * the class-name.this designation allows you to specify which 'this' reference is intended
- *
- *
- * itself : For reference fields only; the object to which the field refers.
- *
- *
- * field-name : The lock object is referenced by the (instance or static) field
- * specified by field-name.
- *
- *
- * class-name.field-name : The lock object is reference by the static field specified
- * by class-name.field-name.
- *
- *
- * method-name() : The lock object is returned by calling the named nil-ary method.
- *
- *
- * class-name.class : The Class object for the specified class should be used as the lock object.
- *
- *
- * Based on code developed by Brian Goetz and Tim Peierls and concepts
- * published in 'Java Concurrency in Practice' by Brian Goetz, Tim Peierls,
- * Joshua Bloch, Joseph Bowbeer, David Holmes and Doug Lea.
- */
-@Documented
-@Target({ElementType.FIELD, ElementType.METHOD})
-@Retention(RetentionPolicy.CLASS) // The original version used RUNTIME
-public @interface GuardedBy {
- String value();
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/annotation/Immutable.java b/lib/httpclient-android/src/main/java/org/apache/http/annotation/Immutable.java
deleted file mode 100644
index ad08d413..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/annotation/Immutable.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * The class to which this annotation is applied is immutable. This means that
- * its state cannot be seen to change by callers, which implies that
- *
- *
all public fields are final,
- *
all public final reference fields refer to other immutable objects, and
- *
constructors and methods do not publish references to any internal state
- * which is potentially mutable by the implementation.
- *
- * Immutable objects may still have internal mutable state for purposes of performance
- * optimization; some state variables may be lazily computed, so long as they are computed
- * from immutable state and that callers cannot tell the difference.
- *
- * Immutable objects are inherently thread-safe; they may be passed between threads or
- * published without synchronization.
- *
- * Based on code developed by Brian Goetz and Tim Peierls and concepts
- * published in 'Java Concurrency in Practice' by Brian Goetz, Tim Peierls,
- * Joshua Bloch, Joseph Bowbeer, David Holmes and Doug Lea.
- */
-@Documented
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS) // The original version used RUNTIME
-public @interface Immutable {
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/annotation/NotThreadSafe.java b/lib/httpclient-android/src/main/java/org/apache/http/annotation/NotThreadSafe.java
deleted file mode 100644
index d453d656..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/annotation/NotThreadSafe.java
+++ /dev/null
@@ -1,50 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * The class to which this annotation is applied is not thread-safe.
- * This annotation primarily exists for clarifying the non-thread-safety of a class
- * that might otherwise be assumed to be thread-safe, despite the fact that it is a bad
- * idea to assume a class is thread-safe without good reason.
- * @see ThreadSafe
- *
- * Based on code developed by Brian Goetz and Tim Peierls and concepts
- * published in 'Java Concurrency in Practice' by Brian Goetz, Tim Peierls,
- * Joshua Bloch, Joseph Bowbeer, David Holmes and Doug Lea.
- */
-@Documented
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS) // The original version used RUNTIME
-public @interface NotThreadSafe {
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/annotation/ThreadSafe.java b/lib/httpclient-android/src/main/java/org/apache/http/annotation/ThreadSafe.java
deleted file mode 100644
index 809b99e6..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/annotation/ThreadSafe.java
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.annotation;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * The class to which this annotation is applied is thread-safe. This means that
- * no sequences of accesses (reads and writes to public fields, calls to public methods)
- * may put the object into an invalid state, regardless of the interleaving of those actions
- * by the runtime, and without requiring any additional synchronization or coordination on the
- * part of the caller.
- * @see NotThreadSafe
- *
- * Based on code developed by Brian Goetz and Tim Peierls and concepts
- * published in 'Java Concurrency in Practice' by Brian Goetz, Tim Peierls,
- * Joshua Bloch, Joseph Bowbeer, David Holmes and Doug Lea.
- */
-@Documented
-@Target(ElementType.TYPE)
-@Retention(RetentionPolicy.CLASS) // The original version used RUNTIME
-public @interface ThreadSafe {
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/annotation/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/annotation/package-info.java
deleted file mode 100644
index a0d5c861..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/annotation/package-info.java
+++ /dev/null
@@ -1,34 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Thread-safety annotations based on JCIP-ANNOTATIONS
- *
- * Copyright (c) 2005 Brian Goetz and Tim Peierls.
- * See http://www.jcip.net
- */
-package org.apache.http.annotation;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/auth/AuthOption.java b/lib/httpclient-android/src/main/java/org/apache/http/auth/AuthOption.java
deleted file mode 100644
index 21f0bc96..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/auth/AuthOption.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.auth;
-
-import org.apache.http.annotation.Immutable;
-import org.apache.http.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();
- }
-
-}
-
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/auth/AuthProtocolState.java b/lib/httpclient-android/src/main/java/org/apache/http/auth/AuthProtocolState.java
deleted file mode 100644
index fba320c6..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/auth/AuthProtocolState.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.auth;
-
-public enum AuthProtocolState {
-
- UNCHALLENGED, CHALLENGED, HANDSHAKE, FAILURE, SUCCESS
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/auth/AuthSchemeProvider.java b/lib/httpclient-android/src/main/java/org/apache/http/auth/AuthSchemeProvider.java
deleted file mode 100644
index 572a8dd4..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/auth/AuthSchemeProvider.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.auth;
-
-import org.apache.http.protocol.HttpContext;
-
-/**
- * Factory for {@link AuthScheme} implementations.
- *
- * @since 4.3
- */
-public interface AuthSchemeProvider {
-
- /**
- * Creates an instance of {@link AuthScheme}.
- *
- * @return auth scheme.
- */
- AuthScheme create(HttpContext context);
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/auth/AuthStateHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/auth/AuthStateHC4.java
deleted file mode 100644
index caef2e2c..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/auth/AuthStateHC4.java
+++ /dev/null
@@ -1,235 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.auth;
-
-import java.util.Queue;
-
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.Args;
-
-/**
- * This class provides detailed information about the state of the authentication process.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class AuthStateHC4 {
-
- /** Actual state of authentication protocol */
- private AuthProtocolState state;
-
- /** Actual authentication scheme */
- private AuthScheme authScheme;
-
- /** Actual authentication scope */
- private AuthScope authScope;
-
- /** Credentials selected for authentication */
- private Credentials credentials;
-
- /** Available auth options */
- private Queue authOptions;
-
- public AuthStateHC4() {
- super();
- this.state = AuthProtocolState.UNCHALLENGED;
- }
-
- /**
- * Resets the auth state.
- *
- * @since 4.2
- */
- 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 getAuthOptions() {
- return this.authOptions;
- }
-
- /**
- * Returns true if {@link AuthOption}s are available, false
- * otherwise.
- *
- * @since 4.2
- */
- public boolean hasAuthOptions() {
- return this.authOptions != null && !this.authOptions.isEmpty();
- }
-
- /**
- * Updates the auth state with a queue of {@link AuthOption}s.
- *
- * @param authOptions a queue of auth options. May not be null or empty.
- *
- * @since 4.2
- */
- public void update(final Queue 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;
- }
-
- /**
- * 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) {
- reset();
- return;
- }
- this.authScheme = authScheme;
- }
-
- /**
- * 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, null.
- *
- */
-package org.apache.http.auth;
-
-/**
- * Challenge mode (TARGET or PROXY)
- *
- * @since 4.2
- */
-public enum ChallengeState {
-
- TARGET, PROXY
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/auth/ContextAwareAuthScheme.java b/lib/httpclient-android/src/main/java/org/apache/http/auth/ContextAwareAuthScheme.java
deleted file mode 100644
index 0571fcf5..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/auth/ContextAwareAuthScheme.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.auth;
-
-import org.apache.http.Header;
-import org.apache.http.HttpRequest;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * This interface represents an extended authentication scheme
- * that requires access to {@link HttpContext} in order to
- * generate an authorization string.
- *
- * TODO: Fix AuthScheme interface in the next major version
- *
- * @since 4.1
- */
-
-public interface ContextAwareAuthScheme extends AuthScheme {
-
- /**
- * Produces an authorization string for the given set of
- * {@link Credentials}.
- *
- * @param credentials The set of credentials to be used for athentication
- * @param request The request being authenticated
- * @param context HTTP context
- * @throws AuthenticationException if authorization string cannot
- * be generated due to an authentication failure
- *
- * @return the authorization string
- */
- Header authenticate(
- Credentials credentials,
- HttpRequest request,
- HttpContext context) throws AuthenticationException;
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/auth/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/auth/package-info.java
deleted file mode 100644
index 801f9324..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/auth/package-info.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Client HTTP authentication APIs.
- */
-package org.apache.http.auth;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/auth/params/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/auth/params/package-info.java
deleted file mode 100644
index 73399dc4..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/auth/params/package-info.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Deprecated.
- * @deprecated (4.3).
- */
-package org.apache.http.auth.params;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/AuthCache.java b/lib/httpclient-android/src/main/java/org/apache/http/client/AuthCache.java
deleted file mode 100644
index 26c0b88c..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/AuthCache.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client;
-
-import org.apache.http.HttpHost;
-import org.apache.http.auth.AuthScheme;
-
-/**
- * Abstract {@link AuthScheme} cache. Initialized {@link AuthScheme} objects
- * from this cache can be used to preemptively authenticate against known
- * hosts.
- *
- * @since 4.1
- */
-public interface AuthCache {
-
- void put(HttpHost host, AuthScheme authScheme);
-
- AuthScheme get(HttpHost host);
-
- void remove(HttpHost host);
-
- void clear();
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/AuthenticationStrategy.java b/lib/httpclient-android/src/main/java/org/apache/http/client/AuthenticationStrategy.java
deleted file mode 100644
index 4f4ef969..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/AuthenticationStrategy.java
+++ /dev/null
@@ -1,130 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client;
-
-import java.util.Map;
-import java.util.Queue;
-
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.auth.AuthOption;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.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.
- *
- * 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 true if user authentication is required,
- * false otherwise.
- */
- boolean isAuthenticationRequested(
- HttpHost authhost,
- HttpResponse response,
- HttpContext context);
-
- /**
- * Extracts from the given HTTP response a collection of authentication
- * challenges, each of which represents an authentication scheme supported
- * by the authentication host.
- *
- * @param authhost authentication host.
- * @param response HTTP response.
- * @param context HTTP context.
- * @return a collection of challenges keyed by names of corresponding
- * authentication schemes.
- * @throws MalformedChallengeException if one of the authentication
- * challenges is not valid or malformed.
- */
- Map 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 select(
- Map 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);
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/BackoffManager.java b/lib/httpclient-android/src/main/java/org/apache/http/client/BackoffManager.java
deleted file mode 100644
index d79b9fb5..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/BackoffManager.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client;
-
-import org.apache.http.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);
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/ConnectionBackoffStrategy.java b/lib/httpclient-android/src/main/java/org/apache/http/client/ConnectionBackoffStrategy.java
deleted file mode 100644
index b71068b9..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/ConnectionBackoffStrategy.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client;
-
-import org.apache.http.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
- * Throwable that resulted or by examining the resulting
- * response (e.g. for its status code).
- *
- * @since 4.2
- *
- */
-public interface ConnectionBackoffStrategy {
-
- /**
- * Determines whether seeing the given Throwable as
- * a result of request execution should result in a backoff
- * signal.
- * @param t the Throwable that happened
- * @return true if a backoff signal should be
- * given
- */
- boolean shouldBackoff(Throwable t);
-
- /**
- * Determines whether receiving the given {@link HttpResponse} as
- * a result of request execution should result in a backoff
- * signal. Implementations MUST restrict themselves to examining
- * the response header and MUST NOT consume any of the response
- * body, if any.
- * @param resp the HttpResponse that was received
- * @return true if a backoff signal should be
- * given
- */
- boolean shouldBackoff(HttpResponse resp);
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/RedirectStrategy.java b/lib/httpclient-android/src/main/java/org/apache/http/client/RedirectStrategy.java
deleted file mode 100644
index 9a824697..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/RedirectStrategy.java
+++ /dev/null
@@ -1,81 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client;
-
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.ProtocolException;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * A strategy for determining if an HTTP request should be redirected to
- * a new location in response to an HTTP response received from the target
- * server.
- *
- * Implementations of this interface must be thread-safe. Access to shared
- * data must be synchronized as methods of this interface may be executed
- * from multiple threads.
- *
- * @since 4.1
- */
-public interface RedirectStrategy {
-
- /**
- * Determines if a request should be redirected to a new location
- * given the response from the target server.
- *
- * @param request the executed request
- * @param response the response received from the target server
- * @param context the context for the request execution
- *
- * @return true if the request should be redirected, false
- * otherwise
- */
- boolean isRedirected(
- HttpRequest request,
- HttpResponse response,
- HttpContext context) throws ProtocolException;
-
- /**
- * Determines the redirect location given the response from the target
- * server and the current request execution context and generates a new
- * request to be sent to the location.
- *
- * @param request the executed request
- * @param response the response received from the target server
- * @param context the context for the request execution
- *
- * @return redirected request
- */
- HttpUriRequest getRedirect(
- HttpRequest request,
- HttpResponse response,
- HttpContext context) throws ProtocolException;
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/ServiceUnavailableRetryStrategy.java b/lib/httpclient-android/src/main/java/org/apache/http/client/ServiceUnavailableRetryStrategy.java
deleted file mode 100644
index 69c449ff..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/ServiceUnavailableRetryStrategy.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.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 true if the method should be retried, false
- * otherwise
- */
- boolean retryRequest(HttpResponse response, int executionCount, HttpContext context);
-
- /**
- * @return The interval between the subsequent auto-retries.
- */
- long getRetryInterval();
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/config/AuthSchemes.java b/lib/httpclient-android/src/main/java/org/apache/http/client/config/AuthSchemes.java
deleted file mode 100644
index 3b6d803f..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/config/AuthSchemes.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.config;
-
-import org.apache.http.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() {
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/config/CookieSpecs.java b/lib/httpclient-android/src/main/java/org/apache/http/client/config/CookieSpecs.java
deleted file mode 100644
index 4ab3ddd1..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/config/CookieSpecs.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.config;
-
-import org.apache.http.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() {
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/config/RequestConfig.java b/lib/httpclient-android/src/main/java/org/apache/http/client/config/RequestConfig.java
deleted file mode 100644
index 9bb457d4..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/config/RequestConfig.java
+++ /dev/null
@@ -1,442 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.config;
-
-import java.net.InetAddress;
-import java.util.Collection;
-
-import org.apache.http.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 targetPreferredAuthSchemes;
- private final Collection 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 targetPreferredAuthSchemes,
- final Collection 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.
- *
- * 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.
- *
- * '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.
- *
- * Default: false
- */
- public boolean isExpectContinueEnabled() {
- return expectContinueEnabled;
- }
-
- /**
- * Returns HTTP proxy to be used for request execution.
- *
- * Default: null
- */
- public HttpHost getProxy() {
- return proxy;
- }
-
- /**
- * Returns local address to be used for request execution.
- *
- * On machines with multiple network interfaces, this parameter
- * can be used to select the network interface from which the
- * connection originates.
- *
- * Default: null
- */
- 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.
- *
- * Default: true
- */
- public boolean isStaleConnectionCheckEnabled() {
- return staleConnectionCheckEnabled;
- }
-
- /**
- * Determines the name of the cookie specification to be used for HTTP state
- * management.
- *
- * Default: null
- */
- public String getCookieSpec() {
- return cookieSpec;
- }
-
- /**
- * Determines whether redirects should be handled automatically.
- *
- * Default: true
- */
- public boolean isRedirectsEnabled() {
- return redirectsEnabled;
- }
-
- /**
- * Determines whether relative redirects should be rejected. HTTP specification
- * requires the location value be an absolute URI.
- *
- * Default: true
- */
- 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
- *
- * Default: false
- */
- 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.
- *
- * Default: 50
- */
- public int getMaxRedirects() {
- return maxRedirects;
- }
-
- /**
- * Determines whether authentication should be handled automatically.
- *
- * Default: true
- */
- public boolean isAuthenticationEnabled() {
- return authenticationEnabled;
- }
-
- /**
- * Determines the order of preference for supported authentication schemes
- * when authenticating with the target host.
- *
- * Default: null
- */
- public Collection getTargetPreferredAuthSchemes() {
- return targetPreferredAuthSchemes;
- }
-
- /**
- * Determines the order of preference for supported authentication schemes
- * when authenticating with the proxy host.
- *
- * Default: null
- */
- public Collection 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.
- *
- * A timeout value of zero is interpreted as an infinite timeout.
- * A negative value is interpreted as undefined (system default).
- *
- * Default: -1
- */
- 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.
- *
- * A timeout value of zero is interpreted as an infinite timeout.
- * A negative value is interpreted as undefined (system default).
- *
- * Default: -1
- */
- public int getConnectTimeout() {
- return connectTimeout;
- }
-
- /**
- * Defines the socket timeout (SO_TIMEOUT) in milliseconds,
- * which is the timeout for waiting for data or, put differently,
- * a maximum period inactivity between two consecutive data packets).
- *
- * A timeout value of zero is interpreted as an infinite timeout.
- * A negative value is interpreted as undefined (system default).
- *
- * Default: -1
- */
- 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 targetPreferredAuthSchemes;
- private Collection 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 targetPreferredAuthSchemes) {
- this.targetPreferredAuthSchemes = targetPreferredAuthSchemes;
- return this;
- }
-
- public Builder setProxyPreferredAuthSchemes(final Collection 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);
- }
-
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/config/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/client/config/package-info.java
deleted file mode 100644
index 78bd81b4..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/config/package-info.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Client configuration APIs.
- */
-package org.apache.http.client.config;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/DecompressingEntity.java b/lib/httpclient-android/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
deleted file mode 100644
index 90b37287..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/DecompressingEntity.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client.entity;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.entity.HttpEntityWrapperHC4;
-import org.apache.http.util.Args;
-
-/**
- * Common base class for decompressing {@link HttpEntity} implementations.
- *
- * @since 4.1
- */
-abstract class DecompressingEntity extends HttpEntityWrapperHC4 {
-
- /**
- * Default buffer size.
- */
- private static final int BUFFER_SIZE = 1024 * 2;
-
- /**
- * {@link #getContent()} method must return the same {@link InputStream}
- * instance when DecompressingEntity is wrapping a streaming entity.
- */
- private InputStream content;
-
- /**
- * Creates a new {@link DecompressingEntity}.
- *
- * @param wrapped
- * the non-null {@link HttpEntity} to be wrapped
- */
- public DecompressingEntity(final HttpEntity wrapped) {
- super(wrapped);
- }
-
- abstract InputStream decorate(final InputStream wrapped) throws IOException;
-
- private InputStream getDecompressingStream() throws IOException {
- final InputStream in = wrappedEntity.getContent();
- return new LazyDecompressingInputStream(in, this);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public InputStream getContent() throws IOException {
- if (wrappedEntity.isStreaming()) {
- if (content == null) {
- content = getDecompressingStream();
- }
- return content;
- } else {
- return getDecompressingStream();
- }
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = getContent();
- try {
- final byte[] buffer = new byte[BUFFER_SIZE];
- int l;
- while ((l = instream.read(buffer)) != -1) {
- outstream.write(buffer, 0, l);
- }
- } finally {
- instream.close();
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java b/lib/httpclient-android/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java
deleted file mode 100644
index 5b0136f5..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/DeflateDecompressingEntity.java
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client.entity;
-
-import java.io.IOException;
-import java.io.InputStream;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-
-/**
- * {@link org.apache.http.entity.HttpEntityWrapper} responsible for handling
- * deflate Content Coded responses. In RFC2616 terms, deflate
- * means a zlib stream as defined in RFC1950. Some server
- * implementations have misinterpreted RFC2616 to mean that a
- * deflate stream as defined in RFC1951 should be used
- * (or maybe they did that since that's how IE behaves?). It's confusing
- * that deflate in HTTP 1.1 means zlib streams
- * rather than deflate streams. We handle both types in here,
- * since that's what is seen on the internet. Moral - prefer
- * gzip!
- *
- * @see GzipDecompressingEntity
- *
- * @since 4.1
- */
-public class DeflateDecompressingEntity extends DecompressingEntity {
-
- /**
- * Creates a new {@link DeflateDecompressingEntity} which will wrap the specified
- * {@link HttpEntity}.
- *
- * @param entity
- * a non-null {@link HttpEntity} to be wrapped
- */
- public DeflateDecompressingEntity(final HttpEntity entity) {
- super(entity);
- }
-
- /**
- * Returns the non-null InputStream that should be returned to by all requests to
- * {@link #getContent()}.
- *
- * @return a non-null InputStream
- * @throws IOException if there was a problem
- */
- @Override
- InputStream decorate(final InputStream wrapped) throws IOException {
- return new DeflateInputStream(wrapped);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Header getContentEncoding() {
-
- /* This HttpEntityWrapperHC4 has dealt with the Content-Encoding. */
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long getContentLength() {
-
- /* Length of inflated content is unknown. */
- return -1;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/DeflateInputStream.java b/lib/httpclient-android/src/main/java/org/apache/http/client/entity/DeflateInputStream.java
deleted file mode 100644
index dfd8f4be..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/DeflateInputStream.java
+++ /dev/null
@@ -1,229 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client.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();
- }
-
- }
-
-}
-
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/EntityBuilder.java b/lib/httpclient-android/src/main/java/org/apache/http/client/entity/EntityBuilder.java
deleted file mode 100644
index a9b2098f..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/EntityBuilder.java
+++ /dev/null
@@ -1,342 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.entity;
-
-import java.io.File;
-import java.io.InputStream;
-import java.io.Serializable;
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.NameValuePair;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.entity.AbstractHttpEntityHC4;
-import org.apache.http.entity.BasicHttpEntityHC4;
-import org.apache.http.entity.ByteArrayEntityHC4;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.FileEntityHC4;
-import org.apache.http.entity.InputStreamEntityHC4;
-import org.apache.http.entity.SerializableEntityHC4;
-import org.apache.http.entity.StringEntityHC4;
-
-/**
- * Builder for {@link HttpEntity} instances.
- *
- * 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:
- *
- *
- * @since 4.3
- */
-@NotThreadSafe
-public class EntityBuilder {
-
- private String text;
- private byte[] binary;
- private InputStream stream;
- private List 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(org.apache.http.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(org.apache.http.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(org.apache.http.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(org.apache.http.NameValuePair...)} methods.
- */
- public List 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 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(org.apache.http.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(org.apache.http.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 true if entity is to be chunk coded, false otherwise.
- */
- public boolean isChunked() {
- return chunked;
- }
-
- /**
- * Makes entity chunk coded.
- */
- public EntityBuilder chunked() {
- this.chunked = true;
- return this;
- }
-
- /**
- * Returns true if entity is to be GZIP compressed, false 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 AbstractHttpEntityHC4 e;
- if (this.text != null) {
- e = new StringEntityHC4(this.text, getContentOrDefault(ContentType.DEFAULT_TEXT));
- } else if (this.binary != null) {
- e = new ByteArrayEntityHC4(this.binary, getContentOrDefault(ContentType.DEFAULT_BINARY));
- } else if (this.stream != null) {
- e = new InputStreamEntityHC4(this.stream, 1, getContentOrDefault(ContentType.DEFAULT_BINARY));
- } else if (this.parameters != null) {
- e = new UrlEncodedFormEntityHC4(this.parameters,
- this.contentType != null ? this.contentType.getCharset() : null);
- } else if (this.serializable != null) {
- e = new SerializableEntityHC4(this.serializable);
- e.setContentType(ContentType.DEFAULT_BINARY.toString());
- } else if (this.file != null) {
- e = new FileEntityHC4(this.file, getContentOrDefault(ContentType.DEFAULT_BINARY));
- } else {
- e = new BasicHttpEntityHC4();
- }
- 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;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/GzipCompressingEntity.java b/lib/httpclient-android/src/main/java/org/apache/http/client/entity/GzipCompressingEntity.java
deleted file mode 100644
index c98a382d..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/GzipCompressingEntity.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client.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
- * .
- *
- */
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.util.zip.GZIPOutputStream;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.entity.HttpEntityWrapperHC4;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.Args;
-
-/**
- * Wrapping entity that compresses content when {@link #writeTo writing}.
- *
- *
- * @since 4.0
- */
-public class GzipCompressingEntity extends HttpEntityWrapperHC4 {
-
- 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();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/GzipDecompressingEntity.java b/lib/httpclient-android/src/main/java/org/apache/http/client/entity/GzipDecompressingEntity.java
deleted file mode 100644
index 68925096..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/GzipDecompressingEntity.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client.entity;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.zip.GZIPInputStream;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-
-/**
- * {@link org.apache.http.entity.HttpEntityWrapper} for handling gzip
- * Content Coded responses.
- *
- * @since 4.1
- */
-public class GzipDecompressingEntity extends DecompressingEntity {
-
- /**
- * Creates a new {@link GzipDecompressingEntity} which will wrap the specified
- * {@link HttpEntity}.
- *
- * @param entity
- * the non-null {@link HttpEntity} to be wrapped
- */
- public GzipDecompressingEntity(final HttpEntity entity) {
- super(entity);
- }
-
- @Override
- InputStream decorate(final InputStream wrapped) throws IOException {
- return new GZIPInputStream(wrapped);
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public Header getContentEncoding() {
-
- /* This HttpEntityWrapperHC4 has dealt with the Content-Encoding. */
- return null;
- }
-
- /**
- * {@inheritDoc}
- */
- @Override
- public long getContentLength() {
-
- /* length of ungzipped content is not known */
- return -1;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java b/lib/httpclient-android/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java
deleted file mode 100644
index fb0e43b1..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/LazyDecompressingInputStream.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client.entity;
-
-import org.apache.http.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();
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntityHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntityHC4.java
deleted file mode 100644
index 44077aa6..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/UrlEncodedFormEntityHC4.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client.entity;
-
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-import java.util.List;
-
-import org.apache.http.NameValuePair;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.client.utils.URLEncodedUtilsHC4;
-import org.apache.http.entity.ContentType;
-import org.apache.http.entity.StringEntityHC4;
-import org.apache.http.protocol.HTTP;
-
-/**
- * An entity composed of a list of url-encoded pairs.
- * This is typically useful while sending an HTTP POST request.
- *
- * @since 4.0
- */
-@NotThreadSafe // AbstractHttpEntityHC4 is not thread-safe
-public class UrlEncodedFormEntityHC4 extends StringEntityHC4 {
-
- /**
- * Constructs a new {@link UrlEncodedFormEntity} with the list
- * of parameters in the specified encoding.
- *
- * @param parameters list of name/value pairs
- * @param charset encoding the name/value pairs be encoded with
- * @throws UnsupportedEncodingException if the encoding isn't supported
- */
- public UrlEncodedFormEntityHC4 (
- final List extends NameValuePair> parameters,
- final String charset) throws UnsupportedEncodingException {
- super(URLEncodedUtilsHC4.format(parameters,
- charset != null ? charset : Charset.forName(HTTP.DEFAULT_CONTENT_CHARSET).name()),
- ContentType.create(URLEncodedUtilsHC4.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 UrlEncodedFormEntityHC4 (
- final Iterable extends NameValuePair> parameters,
- final Charset charset) {
- super(URLEncodedUtilsHC4.format(parameters,
- charset != null ? charset : Charset.forName(HTTP.DEFAULT_CONTENT_CHARSET)),
- ContentType.create(URLEncodedUtilsHC4.CONTENT_TYPE, charset));
- }
-
- /**
- * Constructs a new {@link UrlEncodedFormEntity} with the list
- * of parameters with the default encoding of {@link HTTP#DEFAULT_CONTENT_CHARSET}
- *
- * @param parameters list of name/value pairs
- * @throws UnsupportedEncodingException if the default encoding isn't supported
- */
- public UrlEncodedFormEntityHC4 (
- final List extends NameValuePair> parameters) throws UnsupportedEncodingException {
- 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 UrlEncodedFormEntityHC4 (
- final Iterable extends NameValuePair> parameters) {
- this(parameters, null);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/client/entity/package-info.java
deleted file mode 100644
index 72390f4d..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/entity/package-info.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Client specific HTTP entity implementations.
- */
-package org.apache.http.client.entity;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/AbstractExecutionAwareRequest.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/AbstractExecutionAwareRequest.java
deleted file mode 100644
index 9eedf3bc..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/AbstractExecutionAwareRequest.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client.methods;
-
-import java.io.IOException;
-import java.util.concurrent.atomic.AtomicBoolean;
-import java.util.concurrent.atomic.AtomicReference;
-
-import org.apache.http.HttpRequest;
-import org.apache.http.client.utils.CloneUtilsHC4;
-import org.apache.http.concurrent.Cancellable;
-import org.apache.http.conn.ClientConnectionRequest;
-import org.apache.http.conn.ConnectionReleaseTrigger;
-import org.apache.http.message.AbstractHttpMessage;
-
-@SuppressWarnings("deprecation")
-public abstract class AbstractExecutionAwareRequest extends AbstractHttpMessage implements
- HttpExecutionAware, AbortableHttpRequest, Cloneable, HttpRequest {
-
- private final AtomicBoolean aborted;
- private final AtomicReference cancellableRef;
-
- protected AbstractExecutionAwareRequest() {
- super();
- this.aborted = new AtomicBoolean(false);
- this.cancellableRef = new AtomicReference(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 = CloneUtilsHC4.cloneObject(this.headergroup);
- clone.params = CloneUtilsHC4.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);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/CloseableHttpResponse.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/CloseableHttpResponse.java
deleted file mode 100644
index d0391daa..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/CloseableHttpResponse.java
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.io.Closeable;
-
-import org.apache.http.HttpResponse;
-
-/**
- * Extended version of the {@link HttpResponse} interface that also extends {@link Closeable}.
- *
- * @since 4.3
- */
-public interface CloseableHttpResponse extends HttpResponse, Closeable {
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/Configurable.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/Configurable.java
deleted file mode 100644
index 42f098ec..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/Configurable.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import org.apache.http.client.config.RequestConfig;
-
-/**
- * Configuration interface for HTTP requests.
- *
- * @since 4.3
- */
-public interface Configurable {
-
- /**
- * Returns actual request configuration.
- */
- RequestConfig getConfig();
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpDeleteHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpDeleteHC4.java
deleted file mode 100644
index 9a5fae15..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpDeleteHC4.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-import org.apache.http.annotation.NotThreadSafe;
-
-/**
- * HTTP DELETE method
- *
- * The HTTP DELETE method is defined in section 9.7 of
- * RFC2616:
- *
- * The DELETE method requests that the origin server delete the resource
- * identified by the Request-URI. [...] The client cannot
- * be guaranteed that the operation has been carried out, even if the
- * status code returned from the origin server indicates that the action
- * has been completed successfully.
- *
- *
- * @since 4.0
- */
-@NotThreadSafe // HttpRequestBaseHC4 is @NotThreadSafe
-public class HttpDeleteHC4 extends HttpRequestBaseHC4 {
-
- public final static String METHOD_NAME = "DELETE";
-
-
- public HttpDeleteHC4() {
- super();
- }
-
- public HttpDeleteHC4(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpDeleteHC4(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBaseHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBaseHC4.java
deleted file mode 100644
index 299b9e1b..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpEntityEnclosingRequestBaseHC4.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.client.utils.CloneUtilsHC4;
-import org.apache.http.protocol.HTTP;
-
-/**
- * Basic implementation of an entity enclosing HTTP request
- * that can be modified
- *
- * @since 4.0
- */
-@NotThreadSafe // HttpRequestBaseHC4 is @NotThreadSafe
-public abstract class HttpEntityEnclosingRequestBaseHC4
- extends HttpRequestBaseHC4 implements HttpEntityEnclosingRequest {
-
- private HttpEntity entity;
-
- public HttpEntityEnclosingRequestBaseHC4() {
- super();
- }
-
- public HttpEntity getEntity() {
- return this.entity;
- }
-
- public void setEntity(final HttpEntity entity) {
- this.entity = entity;
- }
-
- public boolean expectContinue() {
- final Header expect = getFirstHeader(HTTP.EXPECT_DIRECTIVE);
- return expect != null && HTTP.EXPECT_CONTINUE.equalsIgnoreCase(expect.getValue());
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- final HttpEntityEnclosingRequestBaseHC4 clone =
- (HttpEntityEnclosingRequestBaseHC4) super.clone();
- if (this.entity != null) {
- clone.entity = CloneUtilsHC4.cloneObject(this.entity);
- }
- return clone;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpExecutionAware.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpExecutionAware.java
deleted file mode 100644
index 0a52376b..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpExecutionAware.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import org.apache.http.concurrent.Cancellable;
-
-/**
- * Interface to be implemented by any object that wishes to be notified of
- * blocking I/O operations that could be cancelled.
- *
- * @since 4.3
- */
-public interface HttpExecutionAware {
-
- boolean isAborted();
-
- /**
- * Sets {@link Cancellable} for the ongoing operation.
- */
- void setCancellable(Cancellable cancellable);
-
-}
-
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpGetHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpGetHC4.java
deleted file mode 100644
index e4fa5c9f..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpGetHC4.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-import org.apache.http.annotation.NotThreadSafe;
-
-/**
- * HTTP GET method.
- *
- * The HTTP GET method is defined in section 9.3 of
- * RFC2616:
- *
- * The GET method means retrieve whatever information (in the form of an
- * entity) is identified by the Request-URI. If the Request-URI refers
- * to a data-producing process, it is the produced data which shall be
- * returned as the entity in the response and not the source text of the
- * process, unless that text happens to be the output of the process.
- *
- *
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class HttpGetHC4 extends HttpRequestBaseHC4 {
-
- public final static String METHOD_NAME = "GET";
-
- public HttpGetHC4() {
- super();
- }
-
- public HttpGetHC4(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpGetHC4(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpHeadHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpHeadHC4.java
deleted file mode 100644
index d596d9bb..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpHeadHC4.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-import org.apache.http.annotation.NotThreadSafe;
-
-/**
- * HTTP HEAD method.
- *
- * The HTTP HEAD method is defined in section 9.4 of
- * RFC2616:
- *
- * The HEAD method is identical to GET except that the server MUST NOT
- * return a message-body in the response. The metainformation contained
- * in the HTTP headers in response to a HEAD request SHOULD be identical
- * to the information sent in response to a GET request. This method can
- * be used for obtaining metainformation about the entity implied by the
- * request without transferring the entity-body itself. This method is
- * often used for testing hypertext links for validity, accessibility,
- * and recent modification.
- *
- *
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class HttpHeadHC4 extends HttpRequestBaseHC4 {
-
- public final static String METHOD_NAME = "HEAD";
-
- public HttpHeadHC4() {
- super();
- }
-
- public HttpHeadHC4(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpHeadHC4(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpOptionsHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpOptionsHC4.java
deleted file mode 100644
index 9e045635..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpOptionsHC4.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-import java.util.HashSet;
-import java.util.Set;
-
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HeaderIterator;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.Args;
-
-/**
- * HTTP OPTIONS method.
- *
- * The HTTP OPTIONS method is defined in section 9.2 of
- * RFC2616:
- *
- * The OPTIONS method represents a request for information about the
- * communication options available on the request/response chain
- * identified by the Request-URI. This method allows the client to
- * determine the options and/or requirements associated with a resource,
- * or the capabilities of a server, without implying a resource action
- * or initiating a resource retrieval.
- *
- *
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class HttpOptionsHC4 extends HttpRequestBaseHC4 {
-
- public final static String METHOD_NAME = "OPTIONS";
-
- public HttpOptionsHC4() {
- super();
- }
-
- public HttpOptionsHC4(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpOptionsHC4(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
- public Set getAllowedMethods(final HttpResponse response) {
- Args.notNull(response, "HTTP response");
-
- final HeaderIterator it = response.headerIterator("Allow");
- final Set methods = new HashSet();
- while (it.hasNext()) {
- final Header header = it.nextHeader();
- final HeaderElement[] elements = header.getElements();
- for (final HeaderElement element : elements) {
- methods.add(element.getName());
- }
- }
- return methods;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpPatch.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpPatch.java
deleted file mode 100644
index fa7ffb69..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpPatch.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-import org.apache.http.annotation.NotThreadSafe;
-
-/**
- * HTTP PATCH method.
- *
The PATCH
- * method requests that a set of changes described in the request entity be
- * applied to the resource identified by the Request- URI. Differs from the PUT
- * method in the way the server processes the enclosed entity to modify the
- * resource identified by the Request-URI. In a PUT request, the enclosed entity
- * origin server, and the client is requesting that the stored version be
- * replaced. With PATCH, however, the enclosed entity contains a set of
- * instructions describing how a resource currently residing on the origin
- * server should be modified to produce a new version.
- *
- *
- * @since 4.2
- */
-@NotThreadSafe
-public class HttpPatch extends HttpEntityEnclosingRequestBaseHC4 {
-
- public final static String METHOD_NAME = "PATCH";
-
- public HttpPatch() {
- super();
- }
-
- public HttpPatch(final URI uri) {
- super();
- setURI(uri);
- }
-
- public HttpPatch(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpPostHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpPostHC4.java
deleted file mode 100644
index 08116c6d..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpPostHC4.java
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-import org.apache.http.annotation.NotThreadSafe;
-
-/**
- * HTTP POST method.
- *
- * The HTTP POST method is defined in section 9.5 of
- * RFC2616:
- *
- * The POST method is used to request that the origin server accept the entity
- * enclosed in the request as a new subordinate of the resource identified by
- * the Request-URI in the Request-Line. POST is designed to allow a uniform
- * method to cover the following functions:
- *
- *
Annotation of existing resources
- *
Posting a message to a bulletin board, newsgroup, mailing list, or
- * similar group of articles
- *
Providing a block of data, such as the result of submitting a form,
- * to a data-handling process
- *
Extending a database through an append operation
- *
- *
- *
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class HttpPostHC4 extends HttpEntityEnclosingRequestBaseHC4 {
-
- public final static String METHOD_NAME = "POST";
-
- public HttpPostHC4() {
- super();
- }
-
- public HttpPostHC4(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpPostHC4(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpPutHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpPutHC4.java
deleted file mode 100644
index cadc0b98..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpPutHC4.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-import org.apache.http.annotation.NotThreadSafe;
-
-/**
- * HTTP PUT method.
- *
- * The HTTP PUT method is defined in section 9.6 of
- * RFC2616:
- *
- * The PUT method requests that the enclosed entity be stored under the
- * supplied Request-URI. If the Request-URI refers to an already
- * existing resource, the enclosed entity SHOULD be considered as a
- * modified version of the one residing on the origin server.
- *
- *
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class HttpPutHC4 extends HttpEntityEnclosingRequestBaseHC4 {
-
- public final static String METHOD_NAME = "PUT";
-
- public HttpPutHC4() {
- super();
- }
-
- public HttpPutHC4(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpPutHC4(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpRequestBaseHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpRequestBaseHC4.java
deleted file mode 100644
index 2c9f3bd4..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpRequestBaseHC4.java
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-import org.apache.http.ProtocolVersion;
-import org.apache.http.RequestLine;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.message.BasicRequestLine;
-import org.apache.http.params.HttpProtocolParams;
-
-/**
- * Base implementation of {@link HttpUriRequest}.
- *
- * @since 4.0
- */
-@SuppressWarnings("deprecation")
-@NotThreadSafe
-public abstract class HttpRequestBaseHC4 extends AbstractExecutionAwareRequest
- implements HttpUriRequest, Configurable {
-
- private ProtocolVersion version;
- private URI uri;
- private RequestConfig config;
-
- public abstract String getMethod();
-
- /**
- * @since 4.3
- */
- public void setProtocolVersion(final ProtocolVersion version) {
- this.version = version;
- }
-
- public ProtocolVersion getProtocolVersion() {
- return version != null ? version : HttpProtocolParams.getVersion(getParams());
- }
-
- /**
- * Returns the original request URI.
- *
- * Please note URI remains unchanged in the course of request execution and
- * is not updated if the request is redirected to another location.
- */
- public URI getURI() {
- return this.uri;
- }
-
- public RequestLine getRequestLine() {
- final String method = getMethod();
- final ProtocolVersion ver = getProtocolVersion();
- final URI uri = getURI();
- String uritext = null;
- if (uri != null) {
- uritext = uri.toASCIIString();
- }
- if (uritext == null || uritext.length() == 0) {
- uritext = "/";
- }
- return new BasicRequestLine(method, uritext, ver);
- }
-
-
- public RequestConfig getConfig() {
- return config;
- }
-
- public void setConfig(final RequestConfig config) {
- this.config = config;
- }
-
- public void setURI(final URI uri) {
- this.uri = uri;
- }
-
- /**
- * @since 4.2
- */
- public void started() {
- }
-
- /**
- * A convenience method to simplify migration from HttpClient 3.1 API. This method is
- * equivalent to {@link #reset()}.
- *
- * @since 4.2
- */
- public void releaseConnection() {
- reset();
- }
-
- @Override
- public String toString() {
- return getMethod() + " " + getURI() + " " + getProtocolVersion();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java
deleted file mode 100644
index 771185f5..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpRequestWrapper.java
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpRequest;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.RequestLine;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.message.AbstractHttpMessage;
-import org.apache.http.message.BasicRequestLine;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HTTP;
-
-/**
- * A wrapper class for {@link HttpRequest} that can be used to change properties of the current
- * request without modifying the original object.
- *
- * @since 4.3
- */
-@SuppressWarnings("deprecation")
-@NotThreadSafe
-public class HttpRequestWrapper extends AbstractHttpMessage implements HttpUriRequest {
-
- private final HttpRequest original;
- private final String method;
- private ProtocolVersion version;
- private URI uri;
-
- private HttpRequestWrapper(final HttpRequest request) {
- super();
- this.original = request;
- this.version = this.original.getRequestLine().getProtocolVersion();
- this.method = this.original.getRequestLine().getMethod();
- if (request instanceof HttpUriRequest) {
- this.uri = ((HttpUriRequest) request).getURI();
- } else {
- this.uri = null;
- }
- setHeaders(request.getAllHeaders());
- }
-
- public ProtocolVersion getProtocolVersion() {
- return this.version != null ? this.version : this.original.getProtocolVersion();
- }
-
- public void setProtocolVersion(final ProtocolVersion version) {
- this.version = version;
- }
-
- public URI getURI() {
- return this.uri;
- }
-
- public void setURI(final URI uri) {
- this.uri = uri;
- }
-
- public String getMethod() {
- return method;
- }
-
- public void abort() throws UnsupportedOperationException {
- throw new UnsupportedOperationException();
- }
-
- public boolean isAborted() {
- return false;
- }
-
- public RequestLine getRequestLine() {
- String requestUri = null;
- if (this.uri != null) {
- requestUri = this.uri.toASCIIString();
- } else {
- requestUri = this.original.getRequestLine().getUri();
- }
- if (requestUri == null || requestUri.length() == 0) {
- requestUri = "/";
- }
- return new BasicRequestLine(this.method, requestUri, getProtocolVersion());
- }
-
- public HttpRequest getOriginal() {
- return this.original;
- }
-
- @Override
- public String toString() {
- return getRequestLine() + " " + this.headergroup;
- }
-
- static class HttpEntityEnclosingRequestWrapper extends HttpRequestWrapper
- implements HttpEntityEnclosingRequest {
-
- private HttpEntity entity;
-
- public HttpEntityEnclosingRequestWrapper(final HttpEntityEnclosingRequest request) {
- super(request);
- this.entity = request.getEntity();
- }
-
- public HttpEntity getEntity() {
- return this.entity;
- }
-
- public void setEntity(final HttpEntity entity) {
- this.entity = entity;
- }
-
- public boolean expectContinue() {
- final Header expect = getFirstHeader(HTTP.EXPECT_DIRECTIVE);
- return expect != null && HTTP.EXPECT_CONTINUE.equalsIgnoreCase(expect.getValue());
- }
-
- }
-
- public static HttpRequestWrapper wrap(final HttpRequest request) {
- if (request == null) {
- return null;
- }
- if (request instanceof HttpEntityEnclosingRequest) {
- return new HttpEntityEnclosingRequestWrapper((HttpEntityEnclosingRequest) request);
- } else {
- return new HttpRequestWrapper(request);
- }
- }
-
- /**
- * @deprecated (4.3) use
- * {@link org.apache.http.client.config.RequestConfig}.
- */
- @Override
- @Deprecated
- public HttpParams getParams() {
- if (this.params == null) {
- this.params = original.getParams().copy();
- }
- return this.params;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpTraceHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpTraceHC4.java
deleted file mode 100644
index 687549c6..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/HttpTraceHC4.java
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-
-import org.apache.http.annotation.NotThreadSafe;
-
-/**
- * HTTP TRACE method.
- *
- * The HTTP TRACE method is defined in section 9.6 of
- * RFC2616:
- *
- * The TRACE method is used to invoke a remote, application-layer loop-
- * back of the request message. The final recipient of the request
- * SHOULD reflect the message received back to the client as the
- * entity-body of a 200 (OK) response. The final recipient is either the
- * origin server or the first proxy or gateway to receive a Max-Forwards
- * value of zero (0) in the request (see section 14.31). A TRACE request
- * MUST NOT include an entity.
- *
- *
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class HttpTraceHC4 extends HttpRequestBaseHC4 {
-
- public final static String METHOD_NAME = "TRACE";
-
- public HttpTraceHC4() {
- super();
- }
-
- public HttpTraceHC4(final URI uri) {
- super();
- setURI(uri);
- }
-
- /**
- * @throws IllegalArgumentException if the uri is invalid.
- */
- public HttpTraceHC4(final String uri) {
- super();
- setURI(URI.create(uri));
- }
-
- @Override
- public String getMethod() {
- return METHOD_NAME;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/RequestBuilder.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/RequestBuilder.java
deleted file mode 100644
index 6de352a4..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/RequestBuilder.java
+++ /dev/null
@@ -1,352 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.methods;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.nio.charset.Charset;
-import java.util.ArrayList;
-import java.util.LinkedList;
-import java.util.List;
-
-import org.apache.http.Header;
-import org.apache.http.HeaderIterator;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpRequest;
-import org.apache.http.NameValuePair;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.entity.UrlEncodedFormEntityHC4;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.message.HeaderGroup;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.Args;
-
-/**
- * Builder for {@link HttpUriRequest} instances.
- *
- * Please note that this class treats parameters differently depending on composition
- * of the request: if the request has a content entity explicitly set with
- * {@link #setEntity(org.apache.http.HttpEntity)} or it is not an entity enclosing method
- * (such as POST or PUT), parameters will be added to the query component of the request URI.
- * Otherwise, parameters will be added as a URL encoded {@link UrlEncodedFormEntityHC4 entity}.
- *
- * @since 4.3
- */
-@NotThreadSafe
-public class RequestBuilder {
-
- private String method;
- private ProtocolVersion version;
- private URI uri;
- private HeaderGroup headergroup;
- private HttpEntity entity;
- private LinkedList parameters;
- private RequestConfig config;
-
- RequestBuilder(final String method) {
- super();
- this.method = method;
- }
-
- RequestBuilder() {
- this(null);
- }
-
- public static RequestBuilder create(final String method) {
- Args.notBlank(method, "HTTP method");
- return new RequestBuilder(method);
- }
-
- public static RequestBuilder get() {
- return new RequestBuilder(HttpGetHC4.METHOD_NAME);
- }
-
- public static RequestBuilder head() {
- return new RequestBuilder(HttpHeadHC4.METHOD_NAME);
- }
-
- public static RequestBuilder post() {
- return new RequestBuilder(HttpPostHC4.METHOD_NAME);
- }
-
- public static RequestBuilder put() {
- return new RequestBuilder(HttpPutHC4.METHOD_NAME);
- }
-
- public static RequestBuilder delete() {
- return new RequestBuilder(HttpDeleteHC4.METHOD_NAME);
- }
-
- public static RequestBuilder trace() {
- return new RequestBuilder(HttpTraceHC4.METHOD_NAME);
- }
-
- public static RequestBuilder options() {
- return new RequestBuilder(HttpOptionsHC4.METHOD_NAME);
- }
-
- public static RequestBuilder copy(final HttpRequest request) {
- Args.notNull(request, "HTTP request");
- return new RequestBuilder().doCopy(request);
- }
-
- private RequestBuilder doCopy(final HttpRequest request) {
- if (request == null) {
- return this;
- }
- method = request.getRequestLine().getMethod();
- version = request.getRequestLine().getProtocolVersion();
- if (request instanceof HttpUriRequest) {
- uri = ((HttpUriRequest) request).getURI();
- } else {
- uri = URI.create(request.getRequestLine().getUri());
- }
- if (headergroup == null) {
- headergroup = new HeaderGroup();
- }
- headergroup.clear();
- headergroup.setHeaders(request.getAllHeaders());
- if (request instanceof HttpEntityEnclosingRequest) {
- entity = ((HttpEntityEnclosingRequest) request).getEntity();
- } else {
- entity = null;
- }
- if (request instanceof Configurable) {
- this.config = ((Configurable) request).getConfig();
- } else {
- this.config = null;
- }
- this.parameters = null;
- return this;
- }
-
- public String getMethod() {
- return method;
- }
-
- public ProtocolVersion getVersion() {
- return version;
- }
-
- public RequestBuilder setVersion(final ProtocolVersion version) {
- this.version = version;
- return this;
- }
-
- public URI getUri() {
- return uri;
- }
-
- public RequestBuilder setUri(final URI uri) {
- this.uri = uri;
- return this;
- }
-
- public RequestBuilder setUri(final String uri) {
- this.uri = uri != null ? URI.create(uri) : null;
- return this;
- }
-
- public Header getFirstHeader(final String name) {
- return headergroup != null ? headergroup.getFirstHeader(name) : null;
- }
-
- public Header getLastHeader(final String name) {
- return headergroup != null ? headergroup.getLastHeader(name) : null;
- }
-
- public Header[] getHeaders(final String name) {
- return headergroup != null ? headergroup.getHeaders(name) : null;
- }
-
- public RequestBuilder addHeader(final Header header) {
- if (headergroup == null) {
- headergroup = new HeaderGroup();
- }
- headergroup.addHeader(header);
- return this;
- }
-
- public RequestBuilder addHeader(final String name, final String value) {
- if (headergroup == null) {
- headergroup = new HeaderGroup();
- }
- this.headergroup.addHeader(new BasicHeader(name, value));
- return this;
- }
-
- public RequestBuilder removeHeader(final Header header) {
- if (headergroup == null) {
- headergroup = new HeaderGroup();
- }
- headergroup.removeHeader(header);
- return this;
- }
-
- public RequestBuilder removeHeaders(final String name) {
- if (name == null || headergroup == null) {
- return this;
- }
- for (final HeaderIterator i = headergroup.iterator(); i.hasNext(); ) {
- final Header header = i.nextHeader();
- if (name.equalsIgnoreCase(header.getName())) {
- i.remove();
- }
- }
- return this;
- }
-
- public RequestBuilder setHeader(final Header header) {
- if (headergroup == null) {
- headergroup = new HeaderGroup();
- }
- this.headergroup.updateHeader(header);
- return this;
- }
-
- public RequestBuilder setHeader(final String name, final String value) {
- if (headergroup == null) {
- headergroup = new HeaderGroup();
- }
- this.headergroup.updateHeader(new BasicHeader(name, value));
- return this;
- }
-
- public HttpEntity getEntity() {
- return entity;
- }
-
- public RequestBuilder setEntity(final HttpEntity entity) {
- this.entity = entity;
- return this;
- }
-
- public List getParameters() {
- return parameters != null ? new ArrayList(parameters) :
- new ArrayList();
- }
-
- public RequestBuilder addParameter(final NameValuePair nvp) {
- Args.notNull(nvp, "Name value pair");
- if (parameters == null) {
- parameters = new LinkedList();
- }
- parameters.add(nvp);
- return this;
- }
-
- public RequestBuilder addParameter(final String name, final String value) {
- return addParameter(new BasicNameValuePair(name, value));
- }
-
- public RequestBuilder addParameters(final NameValuePair... nvps) {
- for (final NameValuePair nvp: nvps) {
- addParameter(nvp);
- }
- return this;
- }
-
- public RequestConfig getConfig() {
- return config;
- }
-
- public RequestBuilder setConfig(final RequestConfig config) {
- this.config = config;
- return this;
- }
-
- public HttpUriRequest build() {
- final HttpRequestBaseHC4 result;
- URI uri = this.uri != null ? this.uri : URI.create("/");
- HttpEntity entity = this.entity;
- if (parameters != null && !parameters.isEmpty()) {
- if (entity == null && (HttpPostHC4.METHOD_NAME.equalsIgnoreCase(method)
- || HttpPutHC4.METHOD_NAME.equalsIgnoreCase(method))) {
- entity = new UrlEncodedFormEntityHC4(parameters, Charset.forName(HTTP.DEFAULT_CONTENT_CHARSET));
- } else {
- try {
- uri = new URIBuilder(uri).addParameters(parameters).build();
- } catch (final URISyntaxException ex) {
- // should never happen
- }
- }
- }
- if (entity == null) {
- result = new InternalRequest(method);
- } else {
- final InternalEntityEclosingRequest request = new InternalEntityEclosingRequest(method);
- request.setEntity(entity);
- result = request;
- }
- result.setProtocolVersion(this.version);
- result.setURI(uri);
- if (this.headergroup != null) {
- result.setHeaders(this.headergroup.getAllHeaders());
- }
- result.setConfig(this.config);
- return result;
- }
-
- static class InternalRequest extends HttpRequestBaseHC4 {
-
- private final String method;
-
- InternalRequest(final String method) {
- super();
- this.method = method;
- }
-
- @Override
- public String getMethod() {
- return this.method;
- }
-
- }
-
- static class InternalEntityEclosingRequest extends HttpEntityEnclosingRequestBaseHC4 {
-
- private final String method;
-
- InternalEntityEclosingRequest(final String method) {
- super();
- this.method = method;
- }
-
- @Override
- public String getMethod() {
- return this.method;
- }
-
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/client/methods/package-info.java
deleted file mode 100644
index 20fa1723..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/methods/package-info.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Standard HTTP method implementations.
- */
-package org.apache.http.client.methods;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/client/package-info.java
deleted file mode 100644
index 3b181d71..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/package-info.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Client HTTP communication APIs.
- */
-package org.apache.http.client;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/params/HttpClientParamConfig.java b/lib/httpclient-android/src/main/java/org/apache/http/client/params/HttpClientParamConfig.java
deleted file mode 100644
index 5b93015a..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/params/HttpClientParamConfig.java
+++ /dev/null
@@ -1,95 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.params;
-
-import java.lang.reflect.Field;
-import java.lang.reflect.Method;
-import java.net.InetAddress;
-import java.util.Map;
-
-import org.apache.http.HttpHost;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.conn.params.ConnRoutePNames;
-import org.apache.http.params.CoreConnectionPNames;
-import org.apache.http.params.CoreProtocolPNames;
-import org.apache.http.params.HttpParams;
-
-/**
- * @deprecated (4.3) provided for compatibility with {@link HttpParams}. Do not use.
- *
- * @since 4.3
- */
-@Deprecated
-public final class HttpClientParamConfig {
-
- private HttpClientParamConfig() {
- }
-
- @SuppressWarnings("unchecked")
- public static RequestConfig getRequestConfig(final HttpParams params) {
- if (params == null) {
- return null;
- }
- try {
- final Field f = params.getClass().getDeclaredField("parameters");
- f.setAccessible(true);
- final Map, ?> map = (Map, ?>) f.get(params);
- if (map == null || map.isEmpty()) {
- return null;
- }
- } catch (Exception ignore) {
- }
- return RequestConfig.custom()
- .setSocketTimeout(params.getIntParameter(
- CoreConnectionPNames.SO_TIMEOUT, 0))
- .setStaleConnectionCheckEnabled(params.getBooleanParameter(
- CoreConnectionPNames.STALE_CONNECTION_CHECK, true))
- .setConnectTimeout(params.getIntParameter(
- CoreConnectionPNames.CONNECTION_TIMEOUT, 0))
- .setExpectContinueEnabled(params.getBooleanParameter(
- CoreProtocolPNames.USE_EXPECT_CONTINUE, false))
- .setProxy((HttpHost) params.getParameter(
- ConnRoutePNames.DEFAULT_PROXY))
- .setLocalAddress((InetAddress) params.getParameter(
- ConnRoutePNames.LOCAL_ADDRESS))
- .setAuthenticationEnabled(params.getBooleanParameter(
- ClientPNames.HANDLE_AUTHENTICATION, true))
- .setCircularRedirectsAllowed(params.getBooleanParameter(
- ClientPNames.ALLOW_CIRCULAR_REDIRECTS, false))
- .setCookieSpec((String) params.getParameter(
- ClientPNames.COOKIE_POLICY))
- .setMaxRedirects(params.getIntParameter(
- ClientPNames.MAX_REDIRECTS, 50))
- .setRedirectsEnabled(params.getBooleanParameter(
- ClientPNames.HANDLE_REDIRECTS, true))
- .setRelativeRedirectsAllowed(!params.getBooleanParameter(
- ClientPNames.REJECT_RELATIVE_REDIRECT, false))
- .build();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/params/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/client/params/package-info.java
deleted file mode 100644
index 69fb42a8..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/params/package-info.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Deprecated.
- * @deprecated (4.3).
- */
-package org.apache.http.client.params;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/HttpClientContext.java b/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/HttpClientContext.java
deleted file mode 100644
index fa9396d9..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/HttpClientContext.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-import java.net.URI;
-import java.util.List;
-
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.auth.AuthStateHC4;
-import org.apache.http.client.AuthCache;
-import org.apache.http.client.CookieStore;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.config.Lookup;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.routing.RouteInfo;
-import org.apache.http.cookie.CookieOrigin;
-import org.apache.http.cookie.CookieSpec;
-import org.apache.http.cookie.CookieSpecProvider;
-import org.apache.http.protocol.BasicHttpContextHC4;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpCoreContext;
-
-/**
- * Adaptor class that provides convenience type safe setters and getters
- * for common {@link HttpContext} attributes used in the course
- * of HTTP request execution.
- *
- * @since 4.3
- */
-@NotThreadSafe
-public class HttpClientContext extends HttpCoreContext {
-
- /**
- * Attribute name of a {@link org.apache.http.conn.routing.RouteInfo}
- * object that represents the actual connection route.
- */
- public static final String HTTP_ROUTE = "http.route";
-
- /**
- * Attribute name of a {@link List} object that represents a collection of all
- * redirect locations received in the process of request execution.
- */
- public static final String REDIRECT_LOCATIONS = "http.protocol.redirect-locations";
-
- /**
- * Attribute name of a {@link org.apache.http.config.Lookup} object that represents
- * the actual {@link CookieSpecProvider} registry.
- */
- public static final String COOKIESPEC_REGISTRY = "http.cookiespec-registry";
-
- /**
- * Attribute name of a {@link org.apache.http.cookie.CookieSpec}
- * object that represents the actual cookie specification.
- */
- public static final String COOKIE_SPEC = "http.cookie-spec";
-
- /**
- * Attribute name of a {@link org.apache.http.cookie.CookieOrigin}
- * object that represents the actual details of the origin server.
- */
- public static final String COOKIE_ORIGIN = "http.cookie-origin";
-
- /**
- * Attribute name of a {@link org.apache.http.client.CookieStore}
- * object that represents the actual cookie store.
- */
- public static final String COOKIE_STORE = "http.cookie-store";
-
- /**
- * Attribute name of a {@link org.apache.http.client.CredentialsProvider}
- * object that represents the actual credentials provider.
- */
- public static final String CREDS_PROVIDER = "http.auth.credentials-provider";
-
- /**
- * Attribute name of a {@link org.apache.http.client.AuthCache} object
- * that represents the auth scheme cache.
- */
- public static final String AUTH_CACHE = "http.auth.auth-cache";
-
- /**
- * Attribute name of a {@link org.apache.http.auth.AuthState}
- * object that represents the actual target authentication state.
- */
- public static final String TARGET_AUTH_STATE = "http.auth.target-scope";
-
- /**
- * Attribute name of a {@link org.apache.http.auth.AuthState}
- * object that represents the actual proxy authentication state.
- */
- public static final String PROXY_AUTH_STATE = "http.auth.proxy-scope";
-
- /**
- * Attribute name of a {@link java.lang.Object} object that represents
- * the actual user identity such as user {@link java.security.Principal}.
- */
- public static final String USER_TOKEN = "http.user-token";
-
- /**
- * Attribute name of a {@link org.apache.http.config.Lookup} object that represents
- * the actual {@link AuthSchemeProvider} registry.
- */
- public static final String AUTHSCHEME_REGISTRY = "http.authscheme-registry";
-
- /**
- * Attribute name of a {@link org.apache.http.client.config.RequestConfig} object that
- * represents the actual request configuration.
- */
- public static final String REQUEST_CONFIG = "http.request-config";
-
- public static HttpClientContext adapt(final HttpContext context) {
- if (context instanceof HttpClientContext) {
- return (HttpClientContext) context;
- } else {
- return new HttpClientContext(context);
- }
- }
-
- public static HttpClientContext create() {
- return new HttpClientContext(new BasicHttpContextHC4());
- }
-
- public HttpClientContext(final HttpContext context) {
- super(context);
- }
-
- public HttpClientContext() {
- super();
- }
-
- public RouteInfo getHttpRoute() {
- return getAttribute(HTTP_ROUTE, HttpRoute.class);
- }
-
- @SuppressWarnings("unchecked")
- public List getRedirectLocations() {
- return getAttribute(REDIRECT_LOCATIONS, List.class);
- }
-
- public CookieStore getCookieStore() {
- return getAttribute(COOKIE_STORE, CookieStore.class);
- }
-
- public void setCookieStore(final CookieStore cookieStore) {
- setAttribute(COOKIE_STORE, cookieStore);
- }
-
- public CookieSpec getCookieSpec() {
- return getAttribute(COOKIE_SPEC, CookieSpec.class);
- }
-
- public CookieOrigin getCookieOrigin() {
- return getAttribute(COOKIE_ORIGIN, CookieOrigin.class);
- }
-
- @SuppressWarnings("unchecked")
- private Lookup getLookup(final String name, final Class clazz) {
- return getAttribute(name, Lookup.class);
- }
-
- public Lookup getCookieSpecRegistry() {
- return getLookup(COOKIESPEC_REGISTRY, CookieSpecProvider.class);
- }
-
- public void setCookieSpecRegistry(final Lookup lookup) {
- setAttribute(COOKIESPEC_REGISTRY, lookup);
- }
-
- public Lookup getAuthSchemeRegistry() {
- return getLookup(AUTHSCHEME_REGISTRY, AuthSchemeProvider.class);
- }
-
- public void setAuthSchemeRegistry(final Lookup lookup) {
- setAttribute(AUTHSCHEME_REGISTRY, lookup);
- }
-
- public CredentialsProvider getCredentialsProvider() {
- return getAttribute(CREDS_PROVIDER, CredentialsProvider.class);
- }
-
- public void setCredentialsProvider(final CredentialsProvider credentialsProvider) {
- setAttribute(CREDS_PROVIDER, credentialsProvider);
- }
-
- public AuthCache getAuthCache() {
- return getAttribute(AUTH_CACHE, AuthCache.class);
- }
-
- public void setAuthCache(final AuthCache authCache) {
- setAttribute(AUTH_CACHE, authCache);
- }
-
- public AuthStateHC4 getTargetAuthState() {
- return getAttribute(TARGET_AUTH_STATE, AuthStateHC4.class);
- }
-
- public AuthStateHC4 getProxyAuthState() {
- return getAttribute(PROXY_AUTH_STATE, AuthStateHC4.class);
- }
-
- public T getUserToken(final Class clazz) {
- return getAttribute(USER_TOKEN, clazz);
- }
-
- public Object getUserToken() {
- return getAttribute(USER_TOKEN);
- }
-
- public void setUserToken(final Object obj) {
- setAttribute(USER_TOKEN, obj);
- }
-
- public RequestConfig getRequestConfig() {
- final RequestConfig config = getAttribute(REQUEST_CONFIG, RequestConfig.class);
- return config != null ? config : RequestConfig.DEFAULT;
- }
-
- public void setRequestConfig(final RequestConfig config) {
- setAttribute(REQUEST_CONFIG, config);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestAcceptEncoding.java b/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestAcceptEncoding.java
deleted file mode 100644
index 610c7459..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestAcceptEncoding.java
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client.protocol;
-
-import java.io.IOException;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * Class responsible for handling Content Encoding requests in HTTP.
- *
- * Instances of this class are stateless, therefore they're thread-safe and immutable.
- *
- * @see "http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.5"
- *
- * @since 4.1
- */
-@Immutable
-public class RequestAcceptEncoding implements HttpRequestInterceptor {
-
- /**
- * Adds the header {@code "Accept-Encoding: gzip,deflate"} to the request.
- */
- public void process(
- final HttpRequest request,
- final HttpContext context) throws HttpException, IOException {
-
- /* Signal support for Accept-Encoding transfer encodings. */
- if (!request.containsHeader("Accept-Encoding")) {
- request.addHeader("Accept-Encoding", "gzip,deflate");
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestAddCookiesHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestAddCookiesHC4.java
deleted file mode 100644
index c6bee3de..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestAddCookiesHC4.java
+++ /dev/null
@@ -1,212 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-import java.io.IOException;
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-
-import android.util.Log;
-
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.client.CookieStore;
-import org.apache.http.client.config.CookieSpecs;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.config.Lookup;
-import org.apache.http.conn.routing.RouteInfo;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieOrigin;
-import org.apache.http.cookie.CookieSpec;
-import org.apache.http.cookie.CookieSpecProvider;
-import org.apache.http.cookie.SetCookie2;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.TextUtils;
-
-/**
- * Request interceptor that matches cookies available in the current
- * {@link CookieStore} to the request being executed and generates
- * corresponding Cookie request headers.
- *
- * @since 4.0
- */
-@Immutable
-public class RequestAddCookiesHC4 implements HttpRequestInterceptor {
-
- private final static String TAG = "HttpClient";
-
- public RequestAddCookiesHC4() {
- super();
- }
-
- public void process(final HttpRequest request, final HttpContext context)
- throws HttpException, IOException {
- Args.notNull(request, "HTTP request");
- Args.notNull(context, "HTTP context");
-
- final String method = request.getRequestLine().getMethod();
- if (method.equalsIgnoreCase("CONNECT")) {
- return;
- }
-
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
-
- // Obtain cookie store
- final CookieStore cookieStore = clientContext.getCookieStore();
- if (cookieStore == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Cookie store not specified in HTTP context");
- }
- return;
- }
-
- // Obtain the registry of cookie specs
- final Lookup registry = clientContext.getCookieSpecRegistry();
- if (registry == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "CookieSpec registry not specified in HTTP context");
- }
- return;
- }
-
- // Obtain the target host, possibly virtual (required)
- final HttpHost targetHost = clientContext.getTargetHost();
- if (targetHost == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Target host not set in the context");
- }
- return;
- }
-
- // Obtain the route (required)
- final RouteInfo route = clientContext.getHttpRoute();
- if (route == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Connection route not set in the context");
- }
- return;
- }
-
- final RequestConfig config = clientContext.getRequestConfig();
- String policy = config.getCookieSpec();
- if (policy == null) {
- policy = CookieSpecs.BEST_MATCH;
- }
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "CookieSpec selected: " + policy);
- }
-
- URI requestURI = null;
- if (request instanceof HttpUriRequest) {
- requestURI = ((HttpUriRequest) request).getURI();
- } else {
- try {
- requestURI = new URI(request.getRequestLine().getUri());
- } catch (final URISyntaxException ignore) {
- }
- }
- final String path = requestURI != null ? requestURI.getPath() : null;
- final String hostName = targetHost.getHostName();
- int port = targetHost.getPort();
- if (port < 0) {
- port = route.getTargetHost().getPort();
- }
-
- final CookieOrigin cookieOrigin = new CookieOrigin(
- hostName,
- port >= 0 ? port : 0,
- !TextUtils.isEmpty(path) ? path : "/",
- route.isSecure());
-
- // Get an instance of the selected cookie policy
- final CookieSpecProvider provider = registry.lookup(policy);
- if (provider == null) {
- throw new HttpException("Unsupported cookie policy: " + policy);
- }
- final CookieSpec cookieSpec = provider.create(clientContext);
- // Get all cookies available in the HTTP state
- final List cookies = new ArrayList(cookieStore.getCookies());
- // Find cookies matching the given origin
- final List matchedCookies = new ArrayList();
- final Date now = new Date();
- for (final Cookie cookie : cookies) {
- if (!cookie.isExpired(now)) {
- if (cookieSpec.match(cookie, cookieOrigin)) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Cookie " + cookie + " match " + cookieOrigin);
- }
- matchedCookies.add(cookie);
- }
- } else {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Cookie " + cookie + " expired");
- }
- }
- }
- // Generate Cookie request headers
- if (!matchedCookies.isEmpty()) {
- final List headers = cookieSpec.formatCookies(matchedCookies);
- for (final Header header : headers) {
- request.addHeader(header);
- }
- }
-
- final int ver = cookieSpec.getVersion();
- if (ver > 0) {
- boolean needVersionHeader = false;
- for (final Cookie cookie : matchedCookies) {
- if (ver != cookie.getVersion() || !(cookie instanceof SetCookie2)) {
- needVersionHeader = true;
- }
- }
-
- if (needVersionHeader) {
- final Header header = cookieSpec.getVersionHeader();
- if (header != null) {
- // Advertise cookie version support
- request.addHeader(header);
- }
- }
- }
-
- // Stick the CookieSpec and CookieOrigin instances to the HTTP context
- // so they could be obtained by the response interceptor
- context.setAttribute(HttpClientContext.COOKIE_SPEC, cookieSpec);
- context.setAttribute(HttpClientContext.COOKIE_ORIGIN, cookieOrigin);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java b/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java
deleted file mode 100644
index d8bb3fbb..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestAuthCache.java
+++ /dev/null
@@ -1,157 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-import java.io.IOException;
-
-import android.util.Log;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.auth.AuthProtocolState;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.AuthStateHC4;
-import org.apache.http.auth.Credentials;
-import org.apache.http.client.AuthCache;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.conn.routing.RouteInfo;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-
-/**
- * Request interceptor that can preemptively authenticate against known hosts,
- * if there is a cached {@link AuthScheme} instance in the local
- * {@link AuthCache} associated with the given target or proxy host.
- *
- * @since 4.1
- */
-@Immutable
-public class RequestAuthCache implements HttpRequestInterceptor {
-
- private final static String TAG = "HttpClient";
-
- public RequestAuthCache() {
- super();
- }
-
- public void process(final HttpRequest request, final HttpContext context)
- throws HttpException, IOException {
- Args.notNull(request, "HTTP request");
- Args.notNull(context, "HTTP context");
-
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
-
- final AuthCache authCache = clientContext.getAuthCache();
- if (authCache == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Auth cache not set in the context");
- }
- return;
- }
-
- final CredentialsProvider credsProvider = clientContext.getCredentialsProvider();
- if (credsProvider == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Credentials provider not set in the context");
- }
- return;
- }
-
- final RouteInfo route = clientContext.getHttpRoute();
- if (route == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Route info not set in the context");
- }
- return;
- }
-
- HttpHost target = clientContext.getTargetHost();
- if (target == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Target host not set in the context");
- }
- return;
- }
-
- if (target.getPort() < 0) {
- target = new HttpHost(
- target.getHostName(),
- route.getTargetHost().getPort(),
- target.getSchemeName());
- }
-
- final AuthStateHC4 targetState = clientContext.getTargetAuthState();
- if (targetState != null && targetState.getState() == AuthProtocolState.UNCHALLENGED) {
- final AuthScheme authScheme = authCache.get(target);
- if (authScheme != null) {
- doPreemptiveAuth(target, authScheme, targetState, credsProvider);
- }
- }
-
- final HttpHost proxy = route.getProxyHost();
- final AuthStateHC4 proxyState = clientContext.getProxyAuthState();
- if (proxy != null && proxyState != null && proxyState.getState() == AuthProtocolState.UNCHALLENGED) {
- final AuthScheme authScheme = authCache.get(proxy);
- if (authScheme != null) {
- doPreemptiveAuth(proxy, authScheme, proxyState, credsProvider);
- }
- }
- }
-
- private void doPreemptiveAuth(
- final HttpHost host,
- final AuthScheme authScheme,
- final AuthStateHC4 authState,
- final CredentialsProvider credsProvider) {
- final String schemeName = authScheme.getSchemeName();
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Re-using cached '" + schemeName + "' auth scheme for " + host);
- }
-
- final AuthScope authScope = new AuthScope(host.getHostName(), host.getPort(), AuthScope.ANY_REALM, schemeName);
- final Credentials creds = credsProvider.getCredentials(authScope);
-
- if (creds != null) {
- if ("BASIC".equalsIgnoreCase(authScheme.getSchemeName())) {
- authState.setState(AuthProtocolState.CHALLENGED);
- } else {
- authState.setState(AuthProtocolState.SUCCESS);
- }
- authState.update(authScheme, creds);
- } else {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "No credentials for preemptive authentication");
- }
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestClientConnControl.java b/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestClientConnControl.java
deleted file mode 100644
index 84279b5e..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestClientConnControl.java
+++ /dev/null
@@ -1,94 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-import java.io.IOException;
-
-import android.util.Log;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.conn.routing.RouteInfo;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-
-/**
- * This protocol interceptor is responsible for adding Connection
- * or Proxy-Connection headers to the outgoing requests, which
- * is essential for managing persistence of HTTP/1.0 connections.
- *
- * @since 4.0
- */
-@Immutable
-public class RequestClientConnControl implements HttpRequestInterceptor {
-
- private final static String TAG = "HttpClient";
-
- private static final String PROXY_CONN_DIRECTIVE = "Proxy-Connection";
-
- public RequestClientConnControl() {
- super();
- }
-
- public void process(final HttpRequest request, final HttpContext context)
- throws HttpException, IOException {
- Args.notNull(request, "HTTP request");
-
- final String method = request.getRequestLine().getMethod();
- if (method.equalsIgnoreCase("CONNECT")) {
- request.setHeader(PROXY_CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
- return;
- }
-
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
-
- // Obtain the client connection (required)
- final RouteInfo route = clientContext.getHttpRoute();
- if (route == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Connection route not set in the context");
- }
- return;
- }
-
- if (route.getHopCount() == 1 || route.isTunnelled()) {
- if (!request.containsHeader(HTTP.CONN_DIRECTIVE)) {
- request.addHeader(HTTP.CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
- }
- }
- if (route.getHopCount() == 2 && !route.isTunnelled()) {
- if (!request.containsHeader(PROXY_CONN_DIRECTIVE)) {
- request.addHeader(PROXY_CONN_DIRECTIVE, HTTP.CONN_KEEP_ALIVE);
- }
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestDefaultHeadersHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestDefaultHeadersHC4.java
deleted file mode 100644
index 49d66f98..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestDefaultHeadersHC4.java
+++ /dev/null
@@ -1,89 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-import java.io.IOException;
-import java.util.Collection;
-
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.client.params.ClientPNames;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-
-/**
- * Request interceptor that adds default request headers.
- *
- * @since 4.0
- */
-@SuppressWarnings("deprecation")
-@Immutable
-public class RequestDefaultHeadersHC4 implements HttpRequestInterceptor {
-
- private final Collection extends Header> defaultHeaders;
-
- /**
- * @since 4.3
- */
- public RequestDefaultHeadersHC4(final Collection extends Header> defaultHeaders) {
- super();
- this.defaultHeaders = defaultHeaders;
- }
-
- public RequestDefaultHeadersHC4() {
- this(null);
- }
-
- public void process(final HttpRequest request, final HttpContext context)
- throws HttpException, IOException {
- Args.notNull(request, "HTTP request");
-
- final String method = request.getRequestLine().getMethod();
- if (method.equalsIgnoreCase("CONNECT")) {
- return;
- }
-
- // Add default headers
- @SuppressWarnings("unchecked")
- Collection extends Header> defHeaders = (Collection extends Header>)
- request.getParams().getParameter(ClientPNames.DEFAULT_HEADERS);
- if (defHeaders == null) {
- defHeaders = this.defaultHeaders;
- }
-
- if (defHeaders != null) {
- for (final Header defHeader : defHeaders) {
- request.addHeader(defHeader);
- }
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestExpectContinue.java b/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestExpectContinue.java
deleted file mode 100644
index 23817e68..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/RequestExpectContinue.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-import java.io.IOException;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpVersion;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-
-/**
- * RequestExpectContinue is responsible for enabling the 'expect-continue'
- * handshake by adding Expect header.
- *
- * This interceptor takes into account {@link RequestConfig#isExpectContinueEnabled()}
- * setting.
- *
- * @since 4.3
- */
-@Immutable
-public class RequestExpectContinue implements HttpRequestInterceptor {
-
- public RequestExpectContinue() {
- super();
- }
-
- public void process(final HttpRequest request, final HttpContext context)
- throws HttpException, IOException {
- Args.notNull(request, "HTTP request");
-
- if (!request.containsHeader(HTTP.EXPECT_DIRECTIVE)) {
- if (request instanceof HttpEntityEnclosingRequest) {
- final ProtocolVersion ver = request.getRequestLine().getProtocolVersion();
- final HttpEntity entity = ((HttpEntityEnclosingRequest)request).getEntity();
- // Do not send the expect header if request body is known to be empty
- if (entity != null
- && entity.getContentLength() != 0 && !ver.lessEquals(HttpVersion.HTTP_1_0)) {
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
- final RequestConfig config = clientContext.getRequestConfig();
- if (config.isExpectContinueEnabled()) {
- request.addHeader(HTTP.EXPECT_DIRECTIVE, HTTP.EXPECT_CONTINUE);
- }
- }
- }
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java b/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java
deleted file mode 100644
index f55b5be3..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/ResponseContentEncoding.java
+++ /dev/null
@@ -1,110 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client.protocol;
-
-import java.io.IOException;
-import java.util.Locale;
-
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.client.entity.DeflateDecompressingEntity;
-import org.apache.http.client.entity.GzipDecompressingEntity;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * {@link HttpResponseInterceptor} responsible for processing Content-Encoding
- * responses.
- *
- * Instances of this class are stateless and immutable, therefore threadsafe.
- *
- * @since 4.1
- *
- */
-@Immutable
-public class ResponseContentEncoding implements HttpResponseInterceptor {
-
- public static final String UNCOMPRESSED = "http.client.response.uncompressed";
-
- /**
- * Handles the following {@code Content-Encoding}s by
- * using the appropriate decompressor to wrap the response Entity:
- *
- *
gzip - see {@link GzipDecompressingEntity}
- *
deflate - see {@link DeflateDecompressingEntity}
- *
identity - no action needed
- *
- *
- * @param response the response which contains the entity
- * @param context not currently used
- *
- * @throws HttpException if the {@code Content-Encoding} is none of the above
- */
- public void process(
- final HttpResponse response,
- final HttpContext context) throws HttpException, IOException {
- final HttpEntity entity = response.getEntity();
-
- // entity can be null in case of 304 Not Modified, 204 No Content or similar
- // check for zero length entity.
- if (entity != null && entity.getContentLength() != 0) {
- final Header ceheader = entity.getContentEncoding();
- if (ceheader != null) {
- final HeaderElement[] codecs = ceheader.getElements();
- boolean uncompressed = false;
- for (final HeaderElement codec : codecs) {
- final String codecname = codec.getName().toLowerCase(Locale.ENGLISH);
- if ("gzip".equals(codecname) || "x-gzip".equals(codecname)) {
- response.setEntity(new GzipDecompressingEntity(response.getEntity()));
- uncompressed = true;
- break;
- } else if ("deflate".equals(codecname)) {
- response.setEntity(new DeflateDecompressingEntity(response.getEntity()));
- uncompressed = true;
- break;
- } else if ("identity".equals(codecname)) {
-
- /* Don't need to transform the content - no-op */
- return;
- } else {
- throw new HttpException("Unsupported Content-Coding: " + codec.getName());
- }
- }
- if (uncompressed) {
- response.removeHeaders("Content-Length");
- response.removeHeaders("Content-Encoding");
- response.removeHeaders("Content-MD5");
- }
- }
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/ResponseProcessCookiesHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/ResponseProcessCookiesHC4.java
deleted file mode 100644
index f99c452e..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/ResponseProcessCookiesHC4.java
+++ /dev/null
@@ -1,162 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.protocol;
-
-import java.io.IOException;
-import java.util.List;
-
-import android.util.Log;
-
-import org.apache.http.Header;
-import org.apache.http.HeaderIterator;
-import org.apache.http.HttpException;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.client.CookieStore;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieOrigin;
-import org.apache.http.cookie.CookieSpec;
-import org.apache.http.cookie.MalformedCookieException;
-import org.apache.http.cookie.SM;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-
-/**
- * Response interceptor that populates the current {@link CookieStore} with data
- * contained in response cookies received in the given the HTTP response.
- *
- * @since 4.0
- */
-@Immutable
-public class ResponseProcessCookiesHC4 implements HttpResponseInterceptor {
-
- private final static String TAG = "HttpClient";
-
- public ResponseProcessCookiesHC4() {
- super();
- }
-
- public void process(final HttpResponse response, final HttpContext context)
- throws HttpException, IOException {
- Args.notNull(response, "HTTP request");
- Args.notNull(context, "HTTP context");
-
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
-
- // Obtain actual CookieSpec instance
- final CookieSpec cookieSpec = clientContext.getCookieSpec();
- if (cookieSpec == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Cookie spec not specified in HTTP context");
- }
- return;
- }
- // Obtain cookie store
- final CookieStore cookieStore = clientContext.getCookieStore();
- if (cookieStore == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Cookie store not specified in HTTP context");
- }
- return;
- }
- // Obtain actual CookieOrigin instance
- final CookieOrigin cookieOrigin = clientContext.getCookieOrigin();
- if (cookieOrigin == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Cookie origin not specified in HTTP context");
- }
- return;
- }
- HeaderIterator it = response.headerIterator(SM.SET_COOKIE);
- processCookies(it, cookieSpec, cookieOrigin, cookieStore);
-
- // see if the cookie spec supports cookie versioning.
- if (cookieSpec.getVersion() > 0) {
- // process set-cookie2 headers.
- // Cookie2 will replace equivalent Cookie instances
- it = response.headerIterator(SM.SET_COOKIE2);
- processCookies(it, cookieSpec, cookieOrigin, cookieStore);
- }
- }
-
- private void processCookies(
- final HeaderIterator iterator,
- final CookieSpec cookieSpec,
- final CookieOrigin cookieOrigin,
- final CookieStore cookieStore) {
- while (iterator.hasNext()) {
- final Header header = iterator.nextHeader();
- try {
- final List cookies = cookieSpec.parse(header, cookieOrigin);
- for (final Cookie cookie : cookies) {
- try {
- cookieSpec.validate(cookie, cookieOrigin);
- cookieStore.addCookie(cookie);
-
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Cookie accepted [" + formatCooke(cookie) + "]");
- }
- } catch (final MalformedCookieException ex) {
- if (Log.isLoggable(TAG, Log.WARN)) {
- Log.w(TAG, "Cookie rejected [" + formatCooke(cookie) + "] "
- + ex.getMessage());
- }
- }
- }
- } catch (final MalformedCookieException ex) {
- if (Log.isLoggable(TAG, Log.WARN)) {
- Log.w(TAG, "Invalid cookie header: \""
- + header + "\". " + ex.getMessage());
- }
- }
- }
- }
-
- private static String formatCooke(final Cookie cookie) {
- final StringBuilder buf = new StringBuilder();
- buf.append(cookie.getName());
- buf.append("=\"");
- String v = cookie.getValue();
- if (v.length() > 100) {
- v = v.substring(0, 100) + "...";
- }
- buf.append(v);
- buf.append("\"");
- buf.append(", version:");
- buf.append(Integer.toString(cookie.getVersion()));
- buf.append(", domain:");
- buf.append(cookie.getDomain());
- buf.append(", path:");
- buf.append(cookie.getPath());
- buf.append(", expiry:");
- buf.append(cookie.getExpiryDate());
- return buf.toString();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/package-info.java
deleted file mode 100644
index 61f8d817..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/protocol/package-info.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Client specific HTTP protocol handlers.
- */
-package org.apache.http.client.protocol;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/utils/CloneUtilsHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/client/utils/CloneUtilsHC4.java
deleted file mode 100644
index 71a7ad81..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/utils/CloneUtilsHC4.java
+++ /dev/null
@@ -1,86 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.client.utils;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-
-import org.apache.http.annotation.Immutable;
-
-/**
- * A collection of utilities to workaround limitations of Java clone framework.
- *
- * @since 4.0
- */
-@Immutable
-public class CloneUtilsHC4 {
-
- /**
- * @since 4.3
- */
- public static T cloneObject(final T obj) throws CloneNotSupportedException {
- if (obj == null) {
- return null;
- }
- if (obj instanceof Cloneable) {
- final Class> clazz = obj.getClass ();
- final Method m;
- try {
- m = clazz.getMethod("clone", (Class[]) null);
- } catch (final NoSuchMethodException ex) {
- throw new NoSuchMethodError(ex.getMessage());
- }
- try {
- @SuppressWarnings("unchecked") // OK because clone() preserves the class
- final T result = (T) m.invoke(obj, (Object []) null);
- return result;
- } catch (final InvocationTargetException ex) {
- final Throwable cause = ex.getCause();
- if (cause instanceof CloneNotSupportedException) {
- throw ((CloneNotSupportedException) cause);
- } else {
- throw new Error("Unexpected exception", cause);
- }
- } catch (final IllegalAccessException ex) {
- throw new IllegalAccessError(ex.getMessage());
- }
- } else {
- throw new CloneNotSupportedException();
- }
- }
-
- public static Object clone(final Object obj) throws CloneNotSupportedException {
- return cloneObject(obj);
- }
-
- /**
- * This class should not be instantiated.
- */
- private CloneUtilsHC4() {
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/client/utils/DateUtils.java b/lib/httpclient-android/src/main/java/org/apache/http/client/utils/DateUtils.java
deleted file mode 100644
index 86f3c7eb..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/client/utils/DateUtils.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.client.utils;
-
-import java.lang.ref.SoftReference;
-import java.text.ParsePosition;
-import java.text.SimpleDateFormat;
-import java.util.Calendar;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-import java.util.TimeZone;
-
-import org.apache.http.annotation.Immutable;
-import org.apache.http.util.Args;
-
-/**
- * A utility class for parsing and formatting HTTP dates as used in cookies and
- * other headers. This class handles dates as defined by RFC 2616 section
- * 3.3.1 as well as some other common non-standard formats.
- *
- * @since 4.3
- */
-@Immutable
-public final class DateUtils {
-
- /**
- * Date format pattern used to parse HTTP date headers in RFC 1123 format.
- */
- public static final String PATTERN_RFC1123 = "EEE, dd MMM yyyy HH:mm:ss zzz";
-
- /**
- * Date format pattern used to parse HTTP date headers in RFC 1036 format.
- */
- public static final String PATTERN_RFC1036 = "EEE, dd-MMM-yy HH:mm:ss zzz";
-
- /**
- * Date format pattern used to parse HTTP date headers in ANSI C
- * asctime() format.
- */
- public static final String PATTERN_ASCTIME = "EEE MMM d HH:mm:ss yyyy";
-
- private static final String[] DEFAULT_PATTERNS = new String[] {
- PATTERN_RFC1123,
- PATTERN_RFC1036,
- PATTERN_ASCTIME
- };
-
- private static final Date DEFAULT_TWO_DIGIT_YEAR_START;
-
- public static final TimeZone GMT = TimeZone.getTimeZone("GMT");
-
- static {
- final Calendar calendar = Calendar.getInstance();
- calendar.setTimeZone(GMT);
- calendar.set(2000, Calendar.JANUARY, 1, 0, 0, 0);
- calendar.set(Calendar.MILLISECOND, 0);
- DEFAULT_TWO_DIGIT_YEAR_START = calendar.getTime();
- }
-
- /**
- * Parses a date value. The formats used for parsing the date value are retrieved from
- * the default http params.
- *
- * @param dateValue the date value to parse
- *
- * @return the parsed date or null if input could not be parsed
- */
- public static Date parseDate(final String dateValue) {
- return parseDate(dateValue, null, null);
- }
-
- /**
- * Parses the date value using the given date formats.
- *
- * @param dateValue the date value to parse
- * @param dateFormats the date formats to use
- *
- * @return the parsed date or null if input could not be parsed
- */
- public static Date parseDate(final String dateValue, final String[] dateFormats) {
- return parseDate(dateValue, dateFormats, null);
- }
-
- /**
- * Parses the date value using the given date formats.
- *
- * @param dateValue the date value to parse
- * @param dateFormats the date formats to use
- * @param startDate During parsing, two digit years will be placed in the range
- * startDate to startDate + 100 years. This value may
- * be null. When null is given as a parameter, year
- * 2000 will be used.
- *
- * @return the parsed date or null if input could not be parsed
- */
- public static Date parseDate(
- final String dateValue,
- final String[] dateFormats,
- final Date startDate) {
- Args.notNull(dateValue, "Date value");
- final String[] localDateFormats = dateFormats != null ? dateFormats : DEFAULT_PATTERNS;
- final Date localStartDate = startDate != null ? startDate : DEFAULT_TWO_DIGIT_YEAR_START;
- String v = dateValue;
- // trim single quotes around date if present
- // see issue #5279
- if (v.length() > 1 && v.startsWith("'") && v.endsWith("'")) {
- v = v.substring (1, v.length() - 1);
- }
-
- for (final String dateFormat : localDateFormats) {
- final SimpleDateFormat dateParser = DateFormatHolder.formatFor(dateFormat);
- dateParser.set2DigitYearStart(localStartDate);
- final ParsePosition pos = new ParsePosition(0);
- final Date result = dateParser.parse(v, pos);
- if (pos.getIndex() != 0) {
- return result;
- }
- }
- return null;
- }
-
- /**
- * Formats the given date according to the RFC 1123 pattern.
- *
- * @param date The date to format.
- * @return An RFC 1123 formatted date string.
- *
- * @see #PATTERN_RFC1123
- */
- public static String formatDate(final Date date) {
- return formatDate(date, PATTERN_RFC1123);
- }
-
- /**
- * Formats the given date according to the specified pattern. The pattern
- * must conform to that used by the {@link SimpleDateFormat simple date
- * format} class.
- *
- * @param date The date to format.
- * @param pattern The pattern to use for formatting the date.
- * @return A formatted date string.
- *
- * @throws IllegalArgumentException If the given date pattern is invalid.
- *
- * @see SimpleDateFormat
- */
- public static String formatDate(final Date date, final String pattern) {
- Args.notNull(date, "Date");
- Args.notNull(pattern, "Pattern");
- final SimpleDateFormat formatter = DateFormatHolder.formatFor(pattern);
- return formatter.format(date);
- }
-
- /**
- * Clears thread-local variable containing {@link java.text.DateFormat} cache.
- *
- * @since 4.3
- */
- public static void clearThreadLocal() {
- DateFormatHolder.clearThreadLocal();
- }
-
- /** This class should not be instantiated. */
- private DateUtils() {
- }
-
- /**
- * A factory for {@link SimpleDateFormat}s. The instances are stored in a
- * threadlocal way because SimpleDateFormat is not threadsafe as noted in
- * {@link SimpleDateFormat its javadoc}.
- *
- */
- final static class DateFormatHolder {
-
- private static final ThreadLocal>>
- THREADLOCAL_FORMATS = new ThreadLocal>>() {
-
- @Override
- protected SoftReference
- *
- *
- *
- * Verify the content the resultant keystore file
- *
keytool -list -v -keystore my.keystore
- *
- *
- *
- *
- * @since 4.0
- */
-@ThreadSafe
-public class SSLConnectionSocketFactory implements LayeredConnectionSocketFactory {
-
- private final static String TAG = "HttpClient";
-
- public static final String TLS = "TLS";
- public static final String SSL = "SSL";
- public static final String SSLV2 = "SSLv2";
-
- public static final X509HostnameVerifier ALLOW_ALL_HOSTNAME_VERIFIER
- = new AllowAllHostnameVerifierHC4();
-
- public static final X509HostnameVerifier BROWSER_COMPATIBLE_HOSTNAME_VERIFIER
- = new BrowserCompatHostnameVerifierHC4();
-
- public static final X509HostnameVerifier STRICT_HOSTNAME_VERIFIER
- = new StrictHostnameVerifierHC4();
-
- /**
- * Obtains default SSL socket factory with an SSL context based on the standard JSSE
- * trust material (cacerts file in the security properties directory).
- * System properties are not taken into consideration.
- *
- * @return default SSL socket factory
- */
- public static SSLConnectionSocketFactory getSocketFactory() throws SSLInitializationException {
- return new SSLConnectionSocketFactory(
- (javax.net.ssl.SSLSocketFactory) SSLSocketFactory.getDefault(),
- BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
- }
-
- private static String[] split(final String s) {
- if (TextUtils.isBlank(s)) {
- return null;
- }
- return s.split(" *, *");
- }
-
- /**
- * Obtains default SSL socket factory with an SSL context based on system properties
- * as described in
- *
- * "JavaTM Secure Socket Extension (JSSE) Reference Guide for the JavaTM 2 Platform
- * Standard Edition 5
- *
- * @return default system SSL socket factory
- */
- public static SSLConnectionSocketFactory getSystemSocketFactory() throws SSLInitializationException {
- return new SSLConnectionSocketFactory(
- (javax.net.ssl.SSLSocketFactory) SSLSocketFactory.getDefault(),
- split(System.getProperty("https.protocols")),
- split(System.getProperty("https.cipherSuites")),
- BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
- }
-
- private final javax.net.ssl.SSLSocketFactory socketfactory;
- private final X509HostnameVerifier hostnameVerifier;
- private final String[] supportedProtocols;
- private final String[] supportedCipherSuites;
-
- public SSLConnectionSocketFactory(final SSLContext sslContext) {
- this(sslContext, BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
- }
-
- public SSLConnectionSocketFactory(
- final SSLContext sslContext, final X509HostnameVerifier hostnameVerifier) {
- this(Args.notNull(sslContext, "SSL context").getSocketFactory(),
- null, null, hostnameVerifier);
- }
-
- public SSLConnectionSocketFactory(
- final SSLContext sslContext,
- final String[] supportedProtocols,
- final String[] supportedCipherSuites,
- final X509HostnameVerifier hostnameVerifier) {
- this(Args.notNull(sslContext, "SSL context").getSocketFactory(),
- supportedProtocols, supportedCipherSuites, hostnameVerifier);
- }
-
- public SSLConnectionSocketFactory(
- final javax.net.ssl.SSLSocketFactory socketfactory,
- final X509HostnameVerifier hostnameVerifier) {
- this(socketfactory, null, null, hostnameVerifier);
- }
-
- public SSLConnectionSocketFactory(
- final javax.net.ssl.SSLSocketFactory socketfactory,
- final String[] supportedProtocols,
- final String[] supportedCipherSuites,
- final X509HostnameVerifier hostnameVerifier) {
- this.socketfactory = Args.notNull(socketfactory, "SSL socket factory");
- this.supportedProtocols = supportedProtocols;
- this.supportedCipherSuites = supportedCipherSuites;
- this.hostnameVerifier = hostnameVerifier != null ? hostnameVerifier : BROWSER_COMPATIBLE_HOSTNAME_VERIFIER;
- }
-
- /**
- * Performs any custom initialization for a newly created SSLSocket
- * (before the SSL handshake happens).
- *
- * The default implementation is a no-op, but could be overridden to, e.g.,
- * call {@link javax.net.ssl.SSLSocket#setEnabledCipherSuites(String[])}.
- */
- protected void prepareSocket(final SSLSocket socket) throws IOException {
- }
-
- public Socket createSocket(final HttpContext context) throws IOException {
- return SocketFactory.getDefault().createSocket();
- }
-
- public Socket connectSocket(
- final int connectTimeout,
- final Socket socket,
- final HttpHost host,
- final InetSocketAddress remoteAddress,
- final InetSocketAddress localAddress,
- final HttpContext context) throws IOException {
- Args.notNull(host, "HTTP host");
- Args.notNull(remoteAddress, "Remote address");
- final Socket sock = socket != null ? socket : createSocket(context);
- if (localAddress != null) {
- sock.bind(localAddress);
- }
- try {
- if (connectTimeout > 0 && sock.getSoTimeout() == 0) {
- sock.setSoTimeout(connectTimeout);
- }
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Connecting socket to " + remoteAddress + " with timeout " + connectTimeout);
- }
- sock.connect(remoteAddress, connectTimeout);
- } catch (final IOException ex) {
- try {
- sock.close();
- } catch (final IOException ignore) {
- }
- throw ex;
- }
- // Setup SSL layering if necessary
- if (sock instanceof SSLSocket) {
- final SSLSocket sslsock = (SSLSocket) sock;
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Starting handshake");
- }
- sslsock.startHandshake();
- verifyHostname(sslsock, host.getHostName());
- return sock;
- } else {
- return createLayeredSocket(sock, host.getHostName(), remoteAddress.getPort(), context);
- }
- }
-
- @TargetApi(9)
- public Socket createLayeredSocket(
- final Socket socket,
- final String target,
- final int port,
- final HttpContext context) throws IOException {
- final SSLSocket sslsock = (SSLSocket) this.socketfactory.createSocket(
- socket,
- target,
- port,
- true);
- if (supportedProtocols != null) {
- sslsock.setEnabledProtocols(supportedProtocols);
- } else {
- // If supported protocols are not explicitly set, remove all SSL protocol versions
- final String[] allProtocols = sslsock.getEnabledProtocols();
- final List enabledProtocols = new ArrayList(allProtocols.length);
- for (String protocol: allProtocols) {
- if (!protocol.startsWith("SSL")) {
- enabledProtocols.add(protocol);
- }
- }
- if (!enabledProtocols.isEmpty()) {
- sslsock.setEnabledProtocols(enabledProtocols.toArray(new String[enabledProtocols.size()]));
- }
- }
- if (supportedCipherSuites != null) {
- sslsock.setEnabledCipherSuites(supportedCipherSuites);
- }
-
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Enabled protocols: " + Arrays.asList(sslsock.getEnabledProtocols()));
- Log.d(TAG, "Enabled cipher suites:" + Arrays.asList(sslsock.getEnabledCipherSuites()));
- }
- prepareSocket(sslsock);
-
- // Android specific code to enable SNI
- if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.GINGERBREAD) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Enabling SNI for " + target);
- }
- try {
- Method method = sslsock.getClass().getMethod("setHostname", String.class);
- method.invoke(sslsock, target);
- } catch (Exception ex) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "SNI configuration failed", ex);
- }
- }
- }
- // End of Android specific code
-
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Starting handshake");
- }
- sslsock.startHandshake();
- verifyHostname(sslsock, target);
- return sslsock;
- }
-
- X509HostnameVerifier getHostnameVerifier() {
- return this.hostnameVerifier;
- }
-
- private void verifyHostname(final SSLSocket sslsock, final String hostname) throws IOException {
- try {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- try {
- final SSLSession session = sslsock.getSession();
- Log.d(TAG, "Secure session established");
- Log.d(TAG, " negotiated protocol: " + session.getProtocol());
- Log.d(TAG, " negotiated cipher suite: " + session.getCipherSuite());
-
- final Certificate[] certs = session.getPeerCertificates();
- final X509Certificate x509 = (X509Certificate) certs[0];
- final X500Principal peer = x509.getSubjectX500Principal();
-
- Log.d(TAG, " peer principal: " + peer.toString());
- final Collection> altNames1 = x509.getSubjectAlternativeNames();
- if (altNames1 != null) {
- final List altNames = new ArrayList();
- for (final List> aC : altNames1) {
- if (!aC.isEmpty()) {
- altNames.add((String) aC.get(1));
- }
- }
- Log.d(TAG, " peer alternative names: " + altNames);
- }
-
- final X500Principal issuer = x509.getIssuerX500Principal();
- Log.d(TAG, " issuer principal: " + issuer.toString());
- final Collection> altNames2 = x509.getIssuerAlternativeNames();
- if (altNames2 != null) {
- final List altNames = new ArrayList();
- for (final List> aC : altNames2) {
- if (!aC.isEmpty()) {
- altNames.add((String) aC.get(1));
- }
- }
- Log.d(TAG, " issuer alternative names: " + altNames);
- }
- } catch (Exception ignore) {
- }
- }
-
- this.hostnameVerifier.verify(hostname, sslsock);
- // verifyHostName() didn't blowup - good!
- } catch (final IOException iox) {
- // close the socket before re-throwing the exception
- try { sslsock.close(); } catch (final Exception x) { /*ignore*/ }
- throw iox;
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/SSLContextBuilder.java b/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/SSLContextBuilder.java
deleted file mode 100644
index 5d81fdaa..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/SSLContextBuilder.java
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.ssl;
-
-import java.net.Socket;
-import java.security.KeyManagementException;
-import java.security.KeyStore;
-import java.security.KeyStoreException;
-import java.security.NoSuchAlgorithmException;
-import java.security.Principal;
-import java.security.PrivateKey;
-import java.security.SecureRandom;
-import java.security.UnrecoverableKeyException;
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Set;
-
-import javax.net.ssl.KeyManager;
-import javax.net.ssl.KeyManagerFactory;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.TrustManagerFactory;
-import javax.net.ssl.X509KeyManager;
-import javax.net.ssl.X509TrustManager;
-
-import org.apache.http.annotation.NotThreadSafe;
-
-/**
- * Builder for {@link SSLContext} instances.
- *
- * @since 4.3
- */
-@NotThreadSafe
-public class SSLContextBuilder {
-
- static final String TLS = "TLS";
- static final String SSL = "SSL";
-
- private String protocol;
- private Set keymanagers;
- private Set trustmanagers;
- private SecureRandom secureRandom;
-
- public SSLContextBuilder() {
- super();
- this.keymanagers = new HashSet();
- this.trustmanagers = new HashSet();
- }
-
- public SSLContextBuilder useTLS() {
- this.protocol = TLS;
- return this;
- }
-
- public SSLContextBuilder useSSL() {
- this.protocol = SSL;
- return this;
- }
-
- public SSLContextBuilder useProtocol(final String protocol) {
- this.protocol = protocol;
- return this;
- }
-
- public SSLContextBuilder setSecureRandom(final SecureRandom secureRandom) {
- this.secureRandom = secureRandom;
- return this;
- }
-
- public SSLContextBuilder loadTrustMaterial(
- final KeyStore truststore,
- final TrustStrategy trustStrategy) throws NoSuchAlgorithmException, KeyStoreException {
- final TrustManagerFactory tmfactory = TrustManagerFactory.getInstance(
- TrustManagerFactory.getDefaultAlgorithm());
- tmfactory.init(truststore);
- final TrustManager[] tms = tmfactory.getTrustManagers();
- if (tms != null) {
- if (trustStrategy != null) {
- for (int i = 0; i < tms.length; i++) {
- final TrustManager tm = tms[i];
- if (tm instanceof X509TrustManager) {
- tms[i] = new TrustManagerDelegate(
- (X509TrustManager) tm, trustStrategy);
- }
- }
- }
- for (final TrustManager tm : tms) {
- this.trustmanagers.add(tm);
- }
- }
- return this;
- }
-
- public SSLContextBuilder loadTrustMaterial(
- final KeyStore truststore) throws NoSuchAlgorithmException, KeyStoreException {
- return loadTrustMaterial(truststore, null);
- }
-
- public SSLContextBuilder loadKeyMaterial(
- final KeyStore keystore,
- final char[] keyPassword)
- throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
- loadKeyMaterial(keystore, keyPassword, null);
- return this;
- }
-
- public SSLContextBuilder loadKeyMaterial(
- final KeyStore keystore,
- final char[] keyPassword,
- final PrivateKeyStrategy aliasStrategy)
- throws NoSuchAlgorithmException, KeyStoreException, UnrecoverableKeyException {
- final KeyManagerFactory kmfactory = KeyManagerFactory.getInstance(
- KeyManagerFactory.getDefaultAlgorithm());
- kmfactory.init(keystore, keyPassword);
- final KeyManager[] kms = kmfactory.getKeyManagers();
- if (kms != null) {
- if (aliasStrategy != null) {
- for (int i = 0; i < kms.length; i++) {
- final KeyManager km = kms[i];
- if (km instanceof X509KeyManager) {
- kms[i] = new KeyManagerDelegate(
- (X509KeyManager) km, aliasStrategy);
- }
- }
- }
- for (final KeyManager km : kms) {
- keymanagers.add(km);
- }
- }
- return this;
- }
-
- public SSLContext build() throws NoSuchAlgorithmException, KeyManagementException {
- final SSLContext sslcontext = SSLContext.getInstance(
- this.protocol != null ? this.protocol : TLS);
- sslcontext.init(
- !keymanagers.isEmpty() ? keymanagers.toArray(new KeyManager[keymanagers.size()]) : null,
- !trustmanagers.isEmpty() ? trustmanagers.toArray(new TrustManager[trustmanagers.size()]) : null,
- secureRandom);
- return sslcontext;
- }
-
- static class TrustManagerDelegate implements X509TrustManager {
-
- private final X509TrustManager trustManager;
- private final TrustStrategy trustStrategy;
-
- TrustManagerDelegate(final X509TrustManager trustManager, final TrustStrategy trustStrategy) {
- super();
- this.trustManager = trustManager;
- this.trustStrategy = trustStrategy;
- }
-
- public void checkClientTrusted(
- final X509Certificate[] chain, final String authType) throws CertificateException {
- this.trustManager.checkClientTrusted(chain, authType);
- }
-
- public void checkServerTrusted(
- final X509Certificate[] chain, final String authType) throws CertificateException {
- if (!this.trustStrategy.isTrusted(chain, authType)) {
- this.trustManager.checkServerTrusted(chain, authType);
- }
- }
-
- public X509Certificate[] getAcceptedIssuers() {
- return this.trustManager.getAcceptedIssuers();
- }
-
- }
-
- static class KeyManagerDelegate implements X509KeyManager {
-
- private final X509KeyManager keyManager;
- private final PrivateKeyStrategy aliasStrategy;
-
- KeyManagerDelegate(final X509KeyManager keyManager, final PrivateKeyStrategy aliasStrategy) {
- super();
- this.keyManager = keyManager;
- this.aliasStrategy = aliasStrategy;
- }
-
- public String[] getClientAliases(
- final String keyType, final Principal[] issuers) {
- return this.keyManager.getClientAliases(keyType, issuers);
- }
-
- public String chooseClientAlias(
- final String[] keyTypes, final Principal[] issuers, final Socket socket) {
- final Map validAliases = new HashMap();
- for (final String keyType: keyTypes) {
- final String[] aliases = this.keyManager.getClientAliases(keyType, issuers);
- if (aliases != null) {
- for (final String alias: aliases) {
- validAliases.put(alias,
- new PrivateKeyDetails(keyType, this.keyManager.getCertificateChain(alias)));
- }
- }
- }
- return this.aliasStrategy.chooseAlias(validAliases, socket);
- }
-
- public String[] getServerAliases(
- final String keyType, final Principal[] issuers) {
- return this.keyManager.getServerAliases(keyType, issuers);
- }
-
- public String chooseServerAlias(
- final String keyType, final Principal[] issuers, final Socket socket) {
- final Map validAliases = new HashMap();
- final String[] aliases = this.keyManager.getServerAliases(keyType, issuers);
- if (aliases != null) {
- for (final String alias: aliases) {
- validAliases.put(alias,
- new PrivateKeyDetails(keyType, this.keyManager.getCertificateChain(alias)));
- }
- }
- return this.aliasStrategy.chooseAlias(validAliases, socket);
- }
-
- public X509Certificate[] getCertificateChain(final String alias) {
- return this.keyManager.getCertificateChain(alias);
- }
-
- public PrivateKey getPrivateKey(final String alias) {
- return this.keyManager.getPrivateKey(alias);
- }
-
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/SSLContexts.java b/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/SSLContexts.java
deleted file mode 100644
index 87a17a71..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/SSLContexts.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.ssl;
-
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-
-import javax.net.ssl.SSLContext;
-
-import org.apache.http.annotation.Immutable;
-
-/**
- * {@link SSLContext} factory methods.
- *
- * @since 4.3
- */
-@Immutable
-public class SSLContexts {
-
- /**
- * Creates default factory based on the standard JSSE trust material
- * (cacerts file in the security properties directory). System properties
- * are not taken into consideration.
- *
- * @return the default SSL socket factory
- */
- public static SSLContext createDefault() throws SSLInitializationException {
- try {
- final SSLContext sslcontext = SSLContext.getInstance(SSLContextBuilder.TLS);
- sslcontext.init(null, null, null);
- return sslcontext;
- } catch (final NoSuchAlgorithmException ex) {
- throw new SSLInitializationException(ex.getMessage(), ex);
- } catch (final KeyManagementException ex) {
- throw new SSLInitializationException(ex.getMessage(), ex);
- }
- }
-
- /**
- * Creates default SSL context based on system properties. This method obtains
- * default SSL context by calling SSLContext.getInstance("Default").
- * Please note that Default algorithm is supported as of Java 6.
- * This method will fall back onto {@link #createDefault()} when
- * Default algorithm is not available.
- *
- * @return default system SSL context
- */
- public static SSLContext createSystemDefault() throws SSLInitializationException {
- try {
- return SSLContext.getInstance("Default");
- } catch (final NoSuchAlgorithmException ex) {
- return createDefault();
- }
- }
-
- /**
- * Creates custom SSL context.
- *
- * @return default system SSL context
- */
- public static SSLContextBuilder custom() {
- return new SSLContextBuilder();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/SSLInitializationException.java b/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/SSLInitializationException.java
deleted file mode 100644
index 51e05113..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/SSLInitializationException.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.conn.ssl;
-
-public class SSLInitializationException extends IllegalStateException {
-
- private static final long serialVersionUID = -8243587425648536702L;
-
- public SSLInitializationException(final String message, final Throwable cause) {
- super(message, cause);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/StrictHostnameVerifierHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/StrictHostnameVerifierHC4.java
deleted file mode 100644
index 4fdc5d41..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/StrictHostnameVerifierHC4.java
+++ /dev/null
@@ -1,69 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.ssl;
-
-import javax.net.ssl.SSLException;
-
-import org.apache.http.annotation.Immutable;
-
-/**
- * The Strict HostnameVerifier works the same way as Sun Java 1.4, Sun
- * Java 5, Sun Java 6-rc. It's also pretty close to IE6. This
- * implementation appears to be compliant with RFC 2818 for dealing with
- * wildcards.
- *
- * The hostname must match either the first CN, or any of the subject-alts.
- * A wildcard can occur in the CN, and in any of the subject-alts. The
- * one divergence from IE6 is how we only check the first CN. IE6 allows
- * a match against any of the CNs present. We decided to follow in
- * Sun Java 1.4's footsteps and only check the first CN. (If you need
- * to check all the CN's, feel free to write your own implementation!).
- *
- * A wildcard such as "*.foo.com" matches only subdomains in the same
- * level, for example "a.foo.com". It does not match deeper subdomains
- * such as "a.b.foo.com".
- *
- *
- * @since 4.0
- */
-@Immutable
-public class StrictHostnameVerifierHC4 extends AbstractVerifierHC4 {
-
- public final void verify(
- final String host,
- final String[] cns,
- final String[] subjectAlts) throws SSLException {
- verify(host, cns, subjectAlts, true);
- }
-
- @Override
- public final String toString() {
- return "STRICT";
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/TokenParser.java b/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/TokenParser.java
deleted file mode 100644
index 4fb032ec..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/TokenParser.java
+++ /dev/null
@@ -1,266 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.ssl;
-
-import java.util.BitSet;
-
-import org.apache.http.message.ParserCursor;
-import org.apache.http.util.CharArrayBuffer;
-
-/**
- * Low level parser for header field elements. The parsing routines of this class are designed
- * to produce near zero intermediate garbage and make no intermediate copies of input data.
- *
- * This class is immutable and thread safe.
- *
- * Temporary package-private copy of org.apache.http.message.TokenParser
- */
-class TokenParser {
-
- public static BitSet INIT_BITSET(final int ... b) {
- final BitSet bitset = new BitSet();
- for (final int aB : b) {
- bitset.set(aB);
- }
- return bitset;
- }
-
- /** US-ASCII CR, carriage return (13) */
- public static final char CR = '\r';
-
- /** US-ASCII LF, line feed (10) */
- public static final char LF = '\n';
-
- /** US-ASCII SP, space (32) */
- public static final char SP = ' ';
-
- /** US-ASCII HT, horizontal-tab (9) */
- public static final char HT = '\t';
-
- /** Double quote */
- public static final char DQUOTE = '\"';
-
- /** Backward slash / escape character */
- public static final char ESCAPE = '\\';
-
- public static boolean isWhitespace(final char ch) {
- return ch == SP || ch == HT || ch == CR || ch == LF;
- }
-
- public static final TokenParser INSTANCE = new TokenParser();
-
- /**
- * Extracts from the sequence of chars a token terminated with any of the given delimiters
- * discarding semantically insignificant whitespace characters.
- *
- * @param buf buffer with the sequence of chars to be parsed
- * @param cursor defines the bounds and current position of the buffer
- * @param delimiters set of delimiting characters. Can be null if the token
- * is not delimited by any character.
- */
- public String parseToken(final CharArrayBuffer buf, final ParserCursor cursor, final BitSet delimiters) {
- final StringBuilder dst = new StringBuilder();
- boolean whitespace = false;
- while (!cursor.atEnd()) {
- final char current = buf.charAt(cursor.getPos());
- if (delimiters != null && delimiters.get(current)) {
- break;
- } else if (isWhitespace(current)) {
- skipWhiteSpace(buf, cursor);
- whitespace = true;
- } else {
- if (whitespace && dst.length() > 0) {
- dst.append(' ');
- }
- copyContent(buf, cursor, delimiters, dst);
- whitespace = false;
- }
- }
- return dst.toString();
- }
-
- /**
- * Extracts from the sequence of chars a value which can be enclosed in quote marks and
- * terminated with any of the given delimiters discarding semantically insignificant
- * whitespace characters.
- *
- * @param buf buffer with the sequence of chars to be parsed
- * @param cursor defines the bounds and current position of the buffer
- * @param delimiters set of delimiting characters. Can be null if the value
- * is not delimited by any character.
- */
- public String parseValue(final CharArrayBuffer buf, final ParserCursor cursor, final BitSet delimiters) {
- final StringBuilder dst = new StringBuilder();
- boolean whitespace = false;
- while (!cursor.atEnd()) {
- final char current = buf.charAt(cursor.getPos());
- if (delimiters != null && delimiters.get(current)) {
- break;
- } else if (isWhitespace(current)) {
- skipWhiteSpace(buf, cursor);
- whitespace = true;
- } else if (current == DQUOTE) {
- if (whitespace && dst.length() > 0) {
- dst.append(' ');
- }
- copyQuotedContent(buf, cursor, dst);
- whitespace = false;
- } else {
- if (whitespace && dst.length() > 0) {
- dst.append(' ');
- }
- copyUnquotedContent(buf, cursor, delimiters, dst);
- whitespace = false;
- }
- }
- return dst.toString();
- }
-
- /**
- * Skips semantically insignificant whitespace characters and moves the cursor to the closest
- * non-whitespace character.
- *
- * @param buf buffer with the sequence of chars to be parsed
- * @param cursor defines the bounds and current position of the buffer
- */
- public void skipWhiteSpace(final CharArrayBuffer buf, final ParserCursor cursor) {
- int pos = cursor.getPos();
- final int indexFrom = cursor.getPos();
- final int indexTo = cursor.getUpperBound();
- for (int i = indexFrom; i < indexTo; i++) {
- final char current = buf.charAt(i);
- if (!isWhitespace(current)) {
- break;
- } else {
- pos++;
- }
- }
- cursor.updatePos(pos);
- }
-
- /**
- * Transfers content into the destination buffer until a whitespace character or any of
- * the given delimiters is encountered.
- *
- * @param buf buffer with the sequence of chars to be parsed
- * @param cursor defines the bounds and current position of the buffer
- * @param delimiters set of delimiting characters. Can be null if the value
- * is delimited by a whitespace only.
- * @param dst destination buffer
- */
- public void copyContent(final CharArrayBuffer buf, final ParserCursor cursor, final BitSet delimiters,
- final StringBuilder dst) {
- int pos = cursor.getPos();
- final int indexFrom = cursor.getPos();
- final int indexTo = cursor.getUpperBound();
- for (int i = indexFrom; i < indexTo; i++) {
- final char current = buf.charAt(i);
- if ((delimiters != null && delimiters.get(current)) || isWhitespace(current)) {
- break;
- } else {
- pos++;
- dst.append(current);
- }
- }
- cursor.updatePos(pos);
- }
-
- /**
- * Transfers content into the destination buffer until a whitespace character, a quote,
- * or any of the given delimiters is encountered.
- *
- * @param buf buffer with the sequence of chars to be parsed
- * @param cursor defines the bounds and current position of the buffer
- * @param delimiters set of delimiting characters. Can be null if the value
- * is delimited by a whitespace or a quote only.
- * @param dst destination buffer
- */
- public void copyUnquotedContent(final CharArrayBuffer buf, final ParserCursor cursor,
- final BitSet delimiters, final StringBuilder dst) {
- int pos = cursor.getPos();
- final int indexFrom = cursor.getPos();
- final int indexTo = cursor.getUpperBound();
- for (int i = indexFrom; i < indexTo; i++) {
- final char current = buf.charAt(i);
- if ((delimiters != null && delimiters.get(current))
- || isWhitespace(current) || current == DQUOTE) {
- break;
- } else {
- pos++;
- dst.append(current);
- }
- }
- cursor.updatePos(pos);
- }
-
- /**
- * Transfers content enclosed with quote marks into the destination buffer.
- *
- * @param buf buffer with the sequence of chars to be parsed
- * @param cursor defines the bounds and current position of the buffer
- * @param dst destination buffer
- */
- public void copyQuotedContent(final CharArrayBuffer buf, final ParserCursor cursor,
- final StringBuilder dst) {
- if (cursor.atEnd()) {
- return;
- }
- int pos = cursor.getPos();
- int indexFrom = cursor.getPos();
- final int indexTo = cursor.getUpperBound();
- char current = buf.charAt(pos);
- if (current != DQUOTE) {
- return;
- }
- pos++;
- indexFrom++;
- boolean escaped = false;
- for (int i = indexFrom; i < indexTo; i++, pos++) {
- current = buf.charAt(i);
- if (escaped) {
- if (current != DQUOTE && current != ESCAPE) {
- dst.append(ESCAPE);
- }
- dst.append(current);
- escaped = false;
- } else {
- if (current == DQUOTE) {
- pos++;
- break;
- }
- if (current == ESCAPE) {
- escaped = true;
- } else if (current != CR && current != LF) {
- dst.append(current);
- }
- }
- }
- cursor.updatePos(pos);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/TrustSelfSignedStrategy.java b/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/TrustSelfSignedStrategy.java
deleted file mode 100644
index 038b1eda..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/TrustSelfSignedStrategy.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.conn.ssl;
-
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-
-/**
- * A trust strategy that accepts self-signed certificates as trusted. Verification of all other
- * certificates is done by the trust manager configured in the SSL context.
- *
- * @since 4.1
- */
-public class TrustSelfSignedStrategy implements TrustStrategy {
-
- public boolean isTrusted(
- final X509Certificate[] chain, final String authType) throws CertificateException {
- return chain.length == 1;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/TrustStrategy.java b/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/TrustStrategy.java
deleted file mode 100644
index 3af87778..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/TrustStrategy.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.conn.ssl;
-
-import java.security.cert.CertificateException;
-import java.security.cert.X509Certificate;
-
-/**
- * A strategy to establish trustworthiness of certificates without consulting the trust manager
- * configured in the actual SSL context. This interface can be used to override the standard
- * JSSE certificate verification process.
- *
- * @since 4.1
- */
-public interface TrustStrategy {
-
- /**
- * Determines whether the certificate chain can be trusted without consulting the trust manager
- * configured in the actual SSL context. This method can be used to override the standard JSSE
- * certificate verification process.
- *
- * Please note that, if this method returns false, the trust manager configured
- * in the actual SSL context can still clear the certificate as trusted.
- *
- * @param chain the peer certificate chain
- * @param authType the authentication type based on the client certificate
- * @return true if the certificate can be trusted without verification by
- * the trust manager, false otherwise.
- * @throws CertificateException thrown if the certificate is not trusted or invalid.
- */
- boolean isTrusted(X509Certificate[] chain, String authType) throws CertificateException;
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/package-info.java
deleted file mode 100644
index 292cb38d..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/conn/ssl/package-info.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Client TLS/SSL support.
- */
-package org.apache.http.conn.ssl;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/conn/util/InetAddressUtilsHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/conn/util/InetAddressUtilsHC4.java
deleted file mode 100644
index 1e90308d..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/conn/util/InetAddressUtilsHC4.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.conn.util;
-
-import java.util.regex.Pattern;
-
-import org.apache.http.annotation.Immutable;
-
-/**
- * A collection of utilities relating to InetAddresses.
- *
- * @since 4.0
- */
-@Immutable
-public class InetAddressUtilsHC4 {
-
- private InetAddressUtilsHC4() {
- }
-
- private static final String IPV4_BASIC_PATTERN_STRING =
- "(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\\.){3}" + // initial 3 fields, 0-255 followed by .
- "([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])"; // final field, 0-255
-
- private static final Pattern IPV4_PATTERN =
- Pattern.compile("^" + IPV4_BASIC_PATTERN_STRING + "$");
-
- private static final Pattern IPV4_MAPPED_IPV6_PATTERN = // TODO does not allow for redundant leading zeros
- Pattern.compile("^::[fF]{4}:" + IPV4_BASIC_PATTERN_STRING + "$");
-
- private static final Pattern IPV6_STD_PATTERN =
- Pattern.compile(
- "^[0-9a-fA-F]{1,4}(:[0-9a-fA-F]{1,4}){7}$");
-
- private static final Pattern IPV6_HEX_COMPRESSED_PATTERN =
- Pattern.compile(
- "^(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)" + // 0-6 hex fields
- "::" +
- "(([0-9A-Fa-f]{1,4}(:[0-9A-Fa-f]{1,4}){0,5})?)$"); // 0-6 hex fields
-
- /*
- * The above pattern is not totally rigorous as it allows for more than 7 hex fields in total
- */
- private static final char COLON_CHAR = ':';
-
- // Must not have more than 7 colons (i.e. 8 fields)
- private static final int MAX_COLON_COUNT = 7;
-
- /**
- * Checks whether the parameter is a valid IPv4 address
- *
- * @param input the address string to check for validity
- * @return true if the input parameter is a valid IPv4 address
- */
- public static boolean isIPv4Address(final String input) {
- return IPV4_PATTERN.matcher(input).matches();
- }
-
- public static boolean isIPv4MappedIPv64Address(final String input) {
- return IPV4_MAPPED_IPV6_PATTERN.matcher(input).matches();
- }
-
- /**
- * Checks whether the parameter is a valid standard (non-compressed) IPv6 address
- *
- * @param input the address string to check for validity
- * @return true if the input parameter is a valid standard (non-compressed) IPv6 address
- */
- public static boolean isIPv6StdAddress(final String input) {
- return IPV6_STD_PATTERN.matcher(input).matches();
- }
-
- /**
- * Checks whether the parameter is a valid compressed IPv6 address
- *
- * @param input the address string to check for validity
- * @return true if the input parameter is a valid compressed IPv6 address
- */
- public static boolean isIPv6HexCompressedAddress(final String input) {
- int colonCount = 0;
- for(int i = 0; i < input.length(); i++) {
- if (input.charAt(i) == COLON_CHAR) {
- colonCount++;
- }
- }
- return colonCount <= MAX_COLON_COUNT && IPV6_HEX_COMPRESSED_PATTERN.matcher(input).matches();
- }
-
- /**
- * Checks whether the parameter is a valid IPv6 address (including compressed).
- *
- * @param input the address string to check for validity
- * @return true if the input parameter is a valid standard or compressed IPv6 address
- */
- public static boolean isIPv6Address(final String input) {
- return isIPv6StdAddress(input) || isIPv6HexCompressedAddress(input);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/conn/util/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/conn/util/package-info.java
deleted file mode 100644
index 7cf3d584..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/conn/util/package-info.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Connection utility classes.
- */
-package org.apache.http.conn.util;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/cookie/CookieRestrictionViolationException.java b/lib/httpclient-android/src/main/java/org/apache/http/cookie/CookieRestrictionViolationException.java
deleted file mode 100644
index ab9b3469..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/cookie/CookieRestrictionViolationException.java
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie;
-
-import org.apache.http.annotation.Immutable;
-
-/**
- * Signals that a cookie violates a restriction imposed by the cookie
- * specification.
- *
- * @since 4.1
- */
-@Immutable
-public class CookieRestrictionViolationException extends MalformedCookieException {
-
- private static final long serialVersionUID = 7371235577078589013L;
-
- /**
- * Creates a new CookeFormatViolationException with a null detail
- * message.
- */
- public CookieRestrictionViolationException() {
- super();
- }
-
- /**
- * Creates a new CookeRestrictionViolationException with a specified
- * message string.
- *
- * @param message The exception detail message
- */
- public CookieRestrictionViolationException(final String message) {
- super(message);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/cookie/CookieSpecProvider.java b/lib/httpclient-android/src/main/java/org/apache/http/cookie/CookieSpecProvider.java
deleted file mode 100644
index fdb4f027..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/cookie/CookieSpecProvider.java
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.cookie;
-
-import org.apache.http.protocol.HttpContext;
-
-/**
- * Factory for {@link CookieSpec} implementations.
- *
- * @since 4.3
- */
-public interface CookieSpecProvider {
-
- /**
- * Creates an instance of {@link CookieSpec}.
- *
- * @return auth scheme.
- */
- CookieSpec create(HttpContext context);
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/cookie/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/cookie/package-info.java
deleted file mode 100644
index 2c3563d9..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/cookie/package-info.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Client HTTP state management APIs.
- */
-package org.apache.http.cookie;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/cookie/params/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/cookie/params/package-info.java
deleted file mode 100644
index 5fe0162b..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/cookie/params/package-info.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Deprecated.
- * @deprecated (4.3).
- */
-package org.apache.http.cookie.params;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/entity/AbstractHttpEntityHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/entity/AbstractHttpEntityHC4.java
deleted file mode 100644
index 75030da2..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/entity/AbstractHttpEntityHC4.java
+++ /dev/null
@@ -1,191 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.IOException;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.message.BasicHeader;
-import org.apache.http.protocol.HTTP;
-
-/**
- * Abstract base class for entities.
- * Provides the commonly used attributes for streamed and self-contained
- * implementations of {@link HttpEntity HttpEntity}.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public abstract class AbstractHttpEntityHC4 implements HttpEntity {
-
- /**
- * Buffer size for output stream processing.
- *
- * @since 4.3
- */
- protected static final int OUTPUT_BUFFER_SIZE = 4096;
-
- protected Header contentType;
- protected Header contentEncoding;
- protected boolean chunked;
-
- /**
- * Protected default constructor.
- * The contentType, contentEncoding and chunked attributes of the created object are set to
- * null, null and false, respectively.
- */
- protected AbstractHttpEntityHC4() {
- super();
- }
-
-
- /**
- * Obtains the Content-Type header.
- * The default implementation returns the value of the
- * {@link #contentType contentType} attribute.
- *
- * @return the Content-Type header, or null
- */
- public Header getContentType() {
- return this.contentType;
- }
-
-
- /**
- * Obtains the Content-Encoding header.
- * The default implementation returns the value of the
- * {@link #contentEncoding contentEncoding} attribute.
- *
- * @return the Content-Encoding header, or null
- */
- public Header getContentEncoding() {
- return this.contentEncoding;
- }
-
- /**
- * Obtains the 'chunked' flag.
- * The default implementation returns the value of the
- * {@link #chunked chunked} attribute.
- *
- * @return the 'chunked' flag
- */
- public boolean isChunked() {
- return this.chunked;
- }
-
-
- /**
- * Specifies the Content-Type header.
- * The default implementation sets the value of the
- * {@link #contentType contentType} attribute.
- *
- * @param contentType the new Content-Encoding header, or
- * null to unset
- */
- public void setContentType(final Header contentType) {
- this.contentType = contentType;
- }
-
- /**
- * Specifies the Content-Type header, as a string.
- * The default implementation calls
- * {@link #setContentType(Header) setContentType(Header)}.
- *
- * @param ctString the new Content-Type header, or
- * null to unset
- */
- public void setContentType(final String ctString) {
- Header h = null;
- if (ctString != null) {
- h = new BasicHeader(HTTP.CONTENT_TYPE, ctString);
- }
- setContentType(h);
- }
-
-
- /**
- * Specifies the Content-Encoding header.
- * The default implementation sets the value of the
- * {@link #contentEncoding contentEncoding} attribute.
- *
- * @param contentEncoding the new Content-Encoding header, or
- * null to unset
- */
- public void setContentEncoding(final Header contentEncoding) {
- this.contentEncoding = contentEncoding;
- }
-
- /**
- * Specifies the Content-Encoding header, as a string.
- * The default implementation calls
- * {@link #setContentEncoding(Header) setContentEncoding(Header)}.
- *
- * @param ceString the new Content-Encoding header, or
- * null to unset
- */
- public void setContentEncoding(final String ceString) {
- Header h = null;
- if (ceString != null) {
- h = new BasicHeader(HTTP.CONTENT_ENCODING, ceString);
- }
- setContentEncoding(h);
- }
-
-
- /**
- * Specifies the 'chunked' flag.
- *
- * Note that the chunked setting is a hint only.
- * If using HTTP/1.0, chunking is never performed.
- * Otherwise, even if chunked is false, HttpClient must
- * use chunk coding if the entity content length is
- * unknown (-1).
- *
- * The default implementation sets the value of the
- * {@link #chunked chunked} attribute.
- *
- * @param b the new 'chunked' flag
- */
- public void setChunked(final boolean b) {
- this.chunked = b;
- }
-
-
- /**
- * The default implementation does not consume anything.
- *
- * @deprecated (4.1) Either use {@link #getContent()} and call {@link java.io.InputStream#close()} on that;
- * otherwise call {@link #writeTo(java.io.OutputStream)} which is required to free the resources.
- */
- @Deprecated
- public void consumeContent() throws IOException {
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/entity/BasicHttpEntityHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/entity/BasicHttpEntityHC4.java
deleted file mode 100644
index 6b1ecf97..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/entity/BasicHttpEntityHC4.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.Args;
-import org.apache.http.util.Asserts;
-
-/**
- * A generic streamed, non-repeatable entity that obtains its content
- * from an {@link InputStream}.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class BasicHttpEntityHC4 extends AbstractHttpEntityHC4 {
-
- private InputStream content;
- private long length;
-
- /**
- * Creates a new basic entity.
- * The content is initially missing, the content length
- * is set to a negative number.
- */
- public BasicHttpEntityHC4() {
- super();
- this.length = -1;
- }
-
- public long getContentLength() {
- return this.length;
- }
-
- /**
- * Obtains the content, once only.
- *
- * @return the content, if this is the first call to this method
- * since {@link #setContent setContent} has been called
- *
- * @throws IllegalStateException
- * if the content has not been provided
- */
- public InputStream getContent() throws IllegalStateException {
- Asserts.check(this.content != null, "Content has not been provided");
- return this.content;
- }
-
- /**
- * Tells that this entity is not repeatable.
- *
- * @return false
- */
- public boolean isRepeatable() {
- return false;
- }
-
- /**
- * Specifies the length of the content.
- *
- * @param len the number of bytes in the content, or
- * a negative number to indicate an unknown length
- */
- public void setContentLength(final long len) {
- this.length = len;
- }
-
- /**
- * Specifies the content.
- *
- * @param instream the stream to return with the next call to
- * {@link #getContent getContent}
- */
- public void setContent(final InputStream instream) {
- this.content = instream;
- }
-
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = getContent();
- try {
- int l;
- final byte[] tmp = new byte[OUTPUT_BUFFER_SIZE];
- while ((l = instream.read(tmp)) != -1) {
- outstream.write(tmp, 0, l);
- }
- } finally {
- instream.close();
- }
- }
-
- public boolean isStreaming() {
- return this.content != null;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/entity/BufferedHttpEntityHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/entity/BufferedHttpEntityHC4.java
deleted file mode 100644
index 91d54d6a..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/entity/BufferedHttpEntityHC4.java
+++ /dev/null
@@ -1,125 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.Args;
-import org.apache.http.util.EntityUtilsHC4;
-
-/**
- * A wrapping entity that buffers it content if necessary.
- * The buffered entity is always repeatable.
- * If the wrapped entity is repeatable itself, calls are passed through.
- * If the wrapped entity is not repeatable, the content is read into a
- * buffer once and provided from there as often as required.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class BufferedHttpEntityHC4 extends HttpEntityWrapperHC4 {
-
- private final byte[] buffer;
-
- /**
- * Creates a new buffered entity wrapper.
- *
- * @param entity the entity to wrap, not null
- * @throws IllegalArgumentException if wrapped is null
- */
- public BufferedHttpEntityHC4(final HttpEntity entity) throws IOException {
- super(entity);
- if (!entity.isRepeatable() || entity.getContentLength() < 0) {
- this.buffer = EntityUtilsHC4.toByteArray(entity);
- } else {
- this.buffer = null;
- }
- }
-
- @Override
- public long getContentLength() {
- if (this.buffer != null) {
- return this.buffer.length;
- } else {
- return super.getContentLength();
- }
- }
-
- @Override
- public InputStream getContent() throws IOException {
- if (this.buffer != null) {
- return new ByteArrayInputStream(this.buffer);
- } else {
- return super.getContent();
- }
- }
-
- /**
- * Tells that this entity does not have to be chunked.
- *
- * @return false
- */
- @Override
- public boolean isChunked() {
- return (buffer == null) && super.isChunked();
- }
-
- /**
- * Tells that this entity is repeatable.
- *
- * @return true
- */
- @Override
- public boolean isRepeatable() {
- return true;
- }
-
-
- @Override
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- if (this.buffer != null) {
- outstream.write(this.buffer);
- } else {
- super.writeTo(outstream);
- }
- }
-
-
- // non-javadoc, see interface HttpEntity
- @Override
- public boolean isStreaming() {
- return (buffer == null) && super.isStreaming();
- }
-
-} // class BufferedHttpEntityHC4
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/entity/ByteArrayEntityHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/entity/ByteArrayEntityHC4.java
deleted file mode 100644
index 60075aba..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/entity/ByteArrayEntityHC4.java
+++ /dev/null
@@ -1,131 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.Args;
-
-/**
- * A self contained, repeatable entity that obtains its content from a byte array.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class ByteArrayEntityHC4 extends AbstractHttpEntityHC4 implements Cloneable {
-
- /**
- * @deprecated (4.2)
- */
- @Deprecated
- protected final byte[] content;
- private final byte[] b;
- private final int off, len;
-
- /**
- * @since 4.2
- */
- @SuppressWarnings("deprecation")
- public ByteArrayEntityHC4(final byte[] b, final ContentType contentType) {
- super();
- Args.notNull(b, "Source byte array");
- this.content = b;
- this.b = b;
- this.off = 0;
- this.len = this.b.length;
- if (contentType != null) {
- setContentType(contentType.toString());
- }
- }
-
- /**
- * @since 4.2
- */
- @SuppressWarnings("deprecation")
- public ByteArrayEntityHC4(final byte[] b, final int off, final int len, final ContentType contentType) {
- super();
- Args.notNull(b, "Source byte array");
- if ((off < 0) || (off > b.length) || (len < 0) ||
- ((off + len) < 0) || ((off + len) > b.length)) {
- throw new IndexOutOfBoundsException("off: " + off + " len: " + len + " b.length: " + b.length);
- }
- this.content = b;
- this.b = b;
- this.off = off;
- this.len = len;
- if (contentType != null) {
- setContentType(contentType.toString());
- }
- }
-
- public ByteArrayEntityHC4(final byte[] b) {
- this(b, null);
- }
-
- public ByteArrayEntityHC4(final byte[] b, final int off, final int len) {
- this(b, off, len, null);
- }
-
- public boolean isRepeatable() {
- return true;
- }
-
- public long getContentLength() {
- return this.len;
- }
-
- public InputStream getContent() {
- return new ByteArrayInputStream(this.b, this.off, this.len);
- }
-
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- outstream.write(this.b, this.off, this.len);
- outstream.flush();
- }
-
-
- /**
- * Tells that this entity is not streaming.
- *
- * @return false
- */
- public boolean isStreaming() {
- return false;
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
-} // class ByteArrayEntityHC4
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/entity/ContentType.java b/lib/httpclient-android/src/main/java/org/apache/http/entity/ContentType.java
deleted file mode 100644
index fe26ebed..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/entity/ContentType.java
+++ /dev/null
@@ -1,305 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.Serializable;
-import java.nio.charset.Charset;
-import java.nio.charset.UnsupportedCharsetException;
-import java.util.Locale;
-
-import org.apache.http.Consts;
-import org.apache.http.Header;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpEntity;
-import org.apache.http.NameValuePair;
-import org.apache.http.ParseException;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.message.BasicHeaderValueFormatterHC4;
-import org.apache.http.message.BasicHeaderValueParserHC4;
-import org.apache.http.message.ParserCursor;
-import org.apache.http.util.Args;
-import org.apache.http.util.CharArrayBuffer;
-import org.apache.http.util.TextUtils;
-
-/**
- * Content type information consisting of a MIME type and an optional charset.
- *
- * This class makes no attempts to verify validity of the MIME type.
- * The input parameters of the {@link #create(String, String)} method, however, may not
- * contain characters <">, <;>, <,> reserved by the HTTP specification.
- *
- * @since 4.2
- */
-@Immutable
-public final class ContentType implements Serializable {
-
- private static final long serialVersionUID = -7768694718232371896L;
-
- // constants
- public static final ContentType APPLICATION_ATOM_XML = create(
- "application/atom+xml", Consts.ISO_8859_1);
- public static final ContentType APPLICATION_FORM_URLENCODED = create(
- "application/x-www-form-urlencoded", Consts.ISO_8859_1);
- public static final ContentType APPLICATION_JSON = create(
- "application/json", Consts.UTF_8);
- public static final ContentType APPLICATION_OCTET_STREAM = create(
- "application/octet-stream", (Charset) null);
- public static final ContentType APPLICATION_SVG_XML = create(
- "application/svg+xml", Consts.ISO_8859_1);
- public static final ContentType APPLICATION_XHTML_XML = create(
- "application/xhtml+xml", Consts.ISO_8859_1);
- public static final ContentType APPLICATION_XML = create(
- "application/xml", Consts.ISO_8859_1);
- public static final ContentType MULTIPART_FORM_DATA = create(
- "multipart/form-data", Consts.ISO_8859_1);
- public static final ContentType TEXT_HTML = create(
- "text/html", Consts.ISO_8859_1);
- public static final ContentType TEXT_PLAIN = create(
- "text/plain", Consts.ISO_8859_1);
- public static final ContentType TEXT_XML = create(
- "text/xml", Consts.ISO_8859_1);
- public static final ContentType WILDCARD = create(
- "*/*", (Charset) null);
-
- // defaults
- public static final ContentType DEFAULT_TEXT = TEXT_PLAIN;
- public static final ContentType DEFAULT_BINARY = APPLICATION_OCTET_STREAM;
-
- private final String mimeType;
- private final Charset charset;
- private final NameValuePair[] params;
-
- ContentType(
- final String mimeType,
- final Charset charset) {
- this.mimeType = mimeType;
- this.charset = charset;
- this.params = null;
- }
-
- ContentType(
- final String mimeType,
- final NameValuePair[] params) throws UnsupportedCharsetException {
- this.mimeType = mimeType;
- this.params = params;
- final String s = getParameter("charset");
- this.charset = !TextUtils.isBlank(s) ? Charset.forName(s) : null;
- }
-
- public String getMimeType() {
- return this.mimeType;
- }
-
- public Charset getCharset() {
- return this.charset;
- }
-
- /**
- * @since 4.3
- */
- public String getParameter(final String name) {
- Args.notEmpty(name, "Parameter name");
- if (this.params == null) {
- return null;
- }
- for (final NameValuePair param: this.params) {
- if (param.getName().equalsIgnoreCase(name)) {
- return param.getValue();
- }
- }
- return null;
- }
-
- /**
- * Generates textual representation of this content type which can be used as the value
- * of a Content-Type header.
- */
- @Override
- public String toString() {
- final CharArrayBuffer buf = new CharArrayBuffer(64);
- buf.append(this.mimeType);
- if (this.params != null) {
- buf.append("; ");
- BasicHeaderValueFormatterHC4.INSTANCE.formatParameters(buf, this.params, false);
- } else if (this.charset != null) {
- buf.append("; charset=");
- buf.append(this.charset.name());
- }
- return buf.toString();
- }
-
- private static boolean valid(final String s) {
- for (int i = 0; i < s.length(); i++) {
- final char ch = s.charAt(i);
- if (ch == '"' || ch == ',' || ch == ';') {
- return false;
- }
- }
- return true;
- }
-
- /**
- * Creates a new instance of {@link ContentType}.
- *
- * @param mimeType MIME type. It may not be null or empty. It may not contain
- * characters <">, <;>, <,> reserved by the HTTP specification.
- * @param charset charset.
- * @return content type
- */
- public static ContentType create(final String mimeType, final Charset charset) {
- final String type = Args.notBlank(mimeType, "MIME type").toLowerCase(Locale.US);
- Args.check(valid(type), "MIME type may not contain reserved characters");
- return new ContentType(type, charset);
- }
-
- /**
- * Creates a new instance of {@link ContentType} without a charset.
- *
- * @param mimeType MIME type. It may not be null or empty. It may not contain
- * characters <">, <;>, <,> reserved by the HTTP specification.
- * @return content type
- */
- public static ContentType create(final String mimeType) {
- return new ContentType(mimeType, (Charset) null);
- }
-
- /**
- * Creates a new instance of {@link ContentType}.
- *
- * @param mimeType MIME type. It may not be null or empty. It may not contain
- * characters <">, <;>, <,> reserved by the HTTP specification.
- * @param charset charset. It may not contain characters <">, <;>, <,> reserved by the HTTP
- * specification. This parameter is optional.
- * @return content type
- * @throws UnsupportedCharsetException Thrown when the named charset is not available in
- * this instance of the Java virtual machine
- */
- public static ContentType create(
- final String mimeType, final String charset) throws UnsupportedCharsetException {
- return create(mimeType, !TextUtils.isBlank(charset) ? Charset.forName(charset) : null);
- }
-
- private static ContentType create(final HeaderElement helem) {
- final String mimeType = helem.getName();
- final NameValuePair[] params = helem.getParameters();
- return new ContentType(mimeType, params != null && params.length > 0 ? params : null);
- }
-
- /**
- * Parses textual representation of Content-Type value.
- *
- * @param s text
- * @return content type
- * @throws ParseException if the given text does not represent a valid
- * Content-Type value.
- * @throws UnsupportedCharsetException Thrown when the named charset is not available in
- * this instance of the Java virtual machine
- */
- public static ContentType parse(
- final String s) throws ParseException, UnsupportedCharsetException {
- Args.notNull(s, "Content type");
- final CharArrayBuffer buf = new CharArrayBuffer(s.length());
- buf.append(s);
- final ParserCursor cursor = new ParserCursor(0, s.length());
- final HeaderElement[] elements = BasicHeaderValueParserHC4.INSTANCE.parseElements(buf, cursor);
- if (elements.length > 0) {
- return create(elements[0]);
- } else {
- throw new ParseException("Invalid content type: " + s);
- }
- }
-
- /**
- * Extracts Content-Type value from {@link HttpEntity} exactly as
- * specified by the Content-Type header of the entity. Returns null
- * if not specified.
- *
- * @param entity HTTP entity
- * @return content type
- * @throws ParseException if the given text does not represent a valid
- * Content-Type value.
- * @throws UnsupportedCharsetException Thrown when the named charset is not available in
- * this instance of the Java virtual machine
- */
- public static ContentType get(
- final HttpEntity entity) throws ParseException, UnsupportedCharsetException {
- if (entity == null) {
- return null;
- }
- final Header header = entity.getContentType();
- if (header != null) {
- final HeaderElement[] elements = header.getElements();
- if (elements.length > 0) {
- return create(elements[0]);
- }
- }
- return null;
- }
-
- /**
- * Extracts Content-Type value from {@link HttpEntity} or returns the default value
- * {@link #DEFAULT_TEXT} if not explicitly specified.
- *
- * @param entity HTTP entity
- * @return content type
- * @throws ParseException if the given text does not represent a valid
- * Content-Type value.
- * @throws UnsupportedCharsetException Thrown when the named charset is not available in
- * this instance of the Java virtual machine
- */
- public static ContentType getOrDefault(
- final HttpEntity entity) throws ParseException, UnsupportedCharsetException {
- final ContentType contentType = get(entity);
- return contentType != null ? contentType : DEFAULT_TEXT;
- }
-
- /**
- * Creates a new instance with this MIME type and the given Charset.
- *
- * @param charset charset
- * @return a new instance with this MIME type and the given Charset.
- * @since 4.3
- */
- public ContentType withCharset(final Charset charset) {
- return create(this.getMimeType(), charset);
- }
-
- /**
- * Creates a new instance with this MIME type and the given Charset name.
- *
- * @param charset name
- * @return a new instance with this MIME type and the given Charset name.
- * @throws UnsupportedCharsetException Thrown when the named charset is not available in
- * this instance of the Java virtual machine
- * @since 4.3
- */
- public ContentType withCharset(final String charset) {
- return create(this.getMimeType(), charset);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/entity/FileEntityHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/entity/FileEntityHC4.java
deleted file mode 100644
index 3e6c52d4..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/entity/FileEntityHC4.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.Args;
-
-/**
- * A self contained, repeatable entity that obtains its content from a file.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class FileEntityHC4 extends AbstractHttpEntityHC4 implements Cloneable {
-
- protected final File file;
-
- /**
- * @deprecated (4.1.3) {@link #FileEntityHC4(File, ContentType)}
- */
- @Deprecated
- public FileEntityHC4(final File file, final String contentType) {
- super();
- this.file = Args.notNull(file, "File");
- setContentType(contentType);
- }
-
- /**
- * @since 4.2
- */
- public FileEntityHC4(final File file, final ContentType contentType) {
- super();
- this.file = Args.notNull(file, "File");
- if (contentType != null) {
- setContentType(contentType.toString());
- }
- }
-
- /**
- * @since 4.2
- */
- public FileEntityHC4(final File file) {
- super();
- this.file = Args.notNull(file, "File");
- }
-
- public boolean isRepeatable() {
- return true;
- }
-
- public long getContentLength() {
- return this.file.length();
- }
-
- public InputStream getContent() throws IOException {
- return new FileInputStream(this.file);
- }
-
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = new FileInputStream(this.file);
- try {
- final byte[] tmp = new byte[OUTPUT_BUFFER_SIZE];
- int l;
- while ((l = instream.read(tmp)) != -1) {
- outstream.write(tmp, 0, l);
- }
- outstream.flush();
- } finally {
- instream.close();
- }
- }
-
- /**
- * Tells that this entity is not streaming.
- *
- * @return false
- */
- public boolean isStreaming() {
- return false;
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- // File instance is considered immutable
- // No need to make a copy of it
- return super.clone();
- }
-
-} // class FileEntityHC4
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/entity/HttpEntityWrapperHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/entity/HttpEntityWrapperHC4.java
deleted file mode 100644
index c8ae0a7f..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/entity/HttpEntityWrapperHC4.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.Args;
-
-/**
- * Base class for wrapping entities.
- * Keeps a {@link #wrappedEntity wrappedEntity} and delegates all
- * calls to it. Implementations of wrapping entities can derive
- * from this class and need to override only those methods that
- * should not be delegated to the wrapped entity.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class HttpEntityWrapperHC4 implements HttpEntity {
-
- /** The wrapped entity. */
- protected HttpEntity wrappedEntity;
-
- /**
- * Creates a new entity wrapper.
- */
- public HttpEntityWrapperHC4(final HttpEntity wrappedEntity) {
- super();
- this.wrappedEntity = Args.notNull(wrappedEntity, "Wrapped entity");
- } // constructor
-
- public boolean isRepeatable() {
- return wrappedEntity.isRepeatable();
- }
-
- public boolean isChunked() {
- return wrappedEntity.isChunked();
- }
-
- public long getContentLength() {
- return wrappedEntity.getContentLength();
- }
-
- public Header getContentType() {
- return wrappedEntity.getContentType();
- }
-
- public Header getContentEncoding() {
- return wrappedEntity.getContentEncoding();
- }
-
- public InputStream getContent()
- throws IOException {
- return wrappedEntity.getContent();
- }
-
- public void writeTo(final OutputStream outstream)
- throws IOException {
- wrappedEntity.writeTo(outstream);
- }
-
- public boolean isStreaming() {
- return wrappedEntity.isStreaming();
- }
-
- /**
- * @deprecated (4.1) Either use {@link #getContent()} and call {@link java.io.InputStream#close()} on that;
- * otherwise call {@link #writeTo(OutputStream)} which is required to free the resources.
- */
- @Deprecated
- public void consumeContent() throws IOException {
- wrappedEntity.consumeContent();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/entity/InputStreamEntityHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/entity/InputStreamEntityHC4.java
deleted file mode 100644
index 9570e190..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/entity/InputStreamEntityHC4.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.Args;
-
-/**
- * A streamed, non-repeatable entity that obtains its content from
- * an {@link InputStream}.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class InputStreamEntityHC4 extends AbstractHttpEntityHC4 {
-
- private final InputStream content;
- private final long length;
-
- /**
- * Creates an entity with an unknown length.
- * Equivalent to {@code new InputStreamEntityHC4(instream, -1)}.
- *
- * @param instream input stream
- * @throws IllegalArgumentException if {@code instream} is {@code null}
- * @since 4.3
- */
- public InputStreamEntityHC4(final InputStream instream) {
- this(instream, -1);
- }
-
- /**
- * Creates an entity with a specified content length.
- *
- * @param instream input stream
- * @param length of the input stream, {@code -1} if unknown
- * @throws IllegalArgumentException if {@code instream} is {@code null}
- */
- public InputStreamEntityHC4(final InputStream instream, final long length) {
- this(instream, length, null);
- }
-
- /**
- * Creates an entity with a content type and unknown length.
- * Equivalent to {@code new InputStreamEntityHC4(instream, -1, contentType)}.
- *
- * @param instream input stream
- * @param contentType content type
- * @throws IllegalArgumentException if {@code instream} is {@code null}
- * @since 4.3
- */
- public InputStreamEntityHC4(final InputStream instream, final ContentType contentType) {
- this(instream, -1, contentType);
- }
-
- /**
- * @param instream input stream
- * @param length of the input stream, {@code -1} if unknown
- * @param contentType for specifying the {@code Content-Type} header, may be {@code null}
- * @throws IllegalArgumentException if {@code instream} is {@code null}
- * @since 4.2
- */
- public InputStreamEntityHC4(final InputStream instream, final long length, final ContentType contentType) {
- super();
- this.content = Args.notNull(instream, "Source input stream");
- this.length = length;
- if (contentType != null) {
- setContentType(contentType.toString());
- }
- }
-
- public boolean isRepeatable() {
- return false;
- }
-
- /**
- * @return the content length or {@code -1} if unknown
- */
- public long getContentLength() {
- return this.length;
- }
-
- public InputStream getContent() throws IOException {
- return this.content;
- }
-
- /**
- * Writes bytes from the {@code InputStream} this entity was constructed
- * with to an {@code OutputStream}. The content length
- * determines how many bytes are written. If the length is unknown ({@code -1}), the
- * stream will be completely consumed (to the end of the stream).
- *
- */
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- final InputStream instream = this.content;
- try {
- final byte[] buffer = new byte[OUTPUT_BUFFER_SIZE];
- int l;
- if (this.length < 0) {
- // consume until EOF
- while ((l = instream.read(buffer)) != -1) {
- outstream.write(buffer, 0, l);
- }
- } else {
- // consume no more than length
- long remaining = this.length;
- while (remaining > 0) {
- l = instream.read(buffer, 0, (int)Math.min(OUTPUT_BUFFER_SIZE, remaining));
- if (l == -1) {
- break;
- }
- outstream.write(buffer, 0, l);
- remaining -= l;
- }
- }
- } finally {
- instream.close();
- }
- }
-
- public boolean isStreaming() {
- return true;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/entity/SerializableEntityHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/entity/SerializableEntityHC4.java
deleted file mode 100644
index 34c5e1bf..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/entity/SerializableEntityHC4.java
+++ /dev/null
@@ -1,126 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.ObjectOutputStream;
-import java.io.OutputStream;
-import java.io.Serializable;
-
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.Args;
-
-/**
- * A streamed entity that obtains its content from a {@link Serializable}.
- * The content obtained from the {@link Serializable} instance can
- * optionally be buffered in a byte array in order to make the
- * entity self-contained and repeatable.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class SerializableEntityHC4 extends AbstractHttpEntityHC4 {
-
- private byte[] objSer;
-
- private Serializable objRef;
-
- /**
- * Creates new instance of this class.
- *
- * @param ser input
- * @param bufferize tells whether the content should be
- * stored in an internal buffer
- * @throws IOException in case of an I/O error
- */
- public SerializableEntityHC4(final Serializable ser, final boolean bufferize) throws IOException {
- super();
- Args.notNull(ser, "Source object");
- if (bufferize) {
- createBytes(ser);
- } else {
- this.objRef = ser;
- }
- }
-
- /**
- * @since 4.3
- */
- public SerializableEntityHC4(final Serializable ser) {
- super();
- Args.notNull(ser, "Source object");
- this.objRef = ser;
- }
-
- private void createBytes(final Serializable ser) throws IOException {
- final ByteArrayOutputStream baos = new ByteArrayOutputStream();
- final ObjectOutputStream out = new ObjectOutputStream(baos);
- out.writeObject(ser);
- out.flush();
- this.objSer = baos.toByteArray();
- }
-
- public InputStream getContent() throws IOException, IllegalStateException {
- if (this.objSer == null) {
- createBytes(this.objRef);
- }
- return new ByteArrayInputStream(this.objSer);
- }
-
- public long getContentLength() {
- if (this.objSer == null) {
- return -1;
- } else {
- return this.objSer.length;
- }
- }
-
- public boolean isRepeatable() {
- return true;
- }
-
- public boolean isStreaming() {
- return this.objSer == null;
- }
-
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- if (this.objSer == null) {
- final ObjectOutputStream out = new ObjectOutputStream(outstream);
- out.writeObject(this.objRef);
- out.flush();
- } else {
- outstream.write(this.objSer);
- outstream.flush();
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/entity/StringEntityHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/entity/StringEntityHC4.java
deleted file mode 100644
index 82e71b80..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/entity/StringEntityHC4.java
+++ /dev/null
@@ -1,188 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.entity;
-
-import java.io.ByteArrayInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.nio.charset.Charset;
-import java.nio.charset.UnsupportedCharsetException;
-
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.Args;
-
-/**
- * A self contained, repeatable entity that obtains its content from
- * a {@link String}.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class StringEntityHC4 extends AbstractHttpEntityHC4 implements Cloneable {
-
- protected final byte[] content;
-
- /**
- * Creates a StringEntityHC4 with the specified content and content type.
- *
- * @param string content to be used. Not {@code null}.
- * @param contentType content type to be used. May be {@code null}, in which case the default
- * MIME type {@link ContentType#TEXT_PLAIN} is assumed.
- *
- * @throws IllegalArgumentException if the string parameter is null
- * @throws UnsupportedCharsetException Thrown when the named charset is not available in
- * this instance of the Java virtual machine
- * @since 4.2
- */
- public StringEntityHC4(final String string, final ContentType contentType) throws UnsupportedCharsetException {
- super();
- Args.notNull(string, "Source string");
- Charset charset = contentType != null ? contentType.getCharset() : null;
- if (charset == null) {
- charset = Charset.forName(HTTP.DEFAULT_CONTENT_CHARSET);
- }
- try {
- this.content = string.getBytes(charset.name());
- } catch (final UnsupportedEncodingException ex) {
- // should never happen
- throw new UnsupportedCharsetException(charset.name());
- }
- if (contentType != null) {
- setContentType(contentType.toString());
- }
- }
-
- /**
- * Creates a StringEntityHC4 with the specified content, MIME type and charset
- *
- * @param string content to be used. Not {@code null}.
- * @param mimeType MIME type to be used. May be {@code null}, in which case the default
- * is {@link HTTP#PLAIN_TEXT_TYPE} i.e. "text/plain"
- * @param charset character set to be used. May be {@code null}, in which case the default
- * is {@link HTTP#DEFAULT_CONTENT_CHARSET} i.e. "ISO-8859-1"
- * @throws UnsupportedEncodingException If the named charset is not supported.
- *
- * @since 4.1
- * @throws IllegalArgumentException if the string parameter is null
- *
- * @deprecated (4.1.3) use {@link #StringEntityHC4(String, ContentType)}
- */
- @Deprecated
- public StringEntityHC4(
- final String string, final String mimeType, final String charset) throws UnsupportedEncodingException {
- super();
- Args.notNull(string, "Source string");
- final String mt = mimeType != null ? mimeType : HTTP.PLAIN_TEXT_TYPE;
- final String cs = charset != null ? charset :HTTP.DEFAULT_CONTENT_CHARSET;
- this.content = string.getBytes(cs);
- setContentType(mt + HTTP.CHARSET_PARAM + cs);
- }
-
- /**
- * Creates a StringEntityHC4 with the specified content and charset. The MIME type defaults
- * to "text/plain".
- *
- * @param string content to be used. Not {@code null}.
- * @param charset character set to be used. May be {@code null}, in which case the default
- * is {@link HTTP#DEFAULT_CONTENT_CHARSET} is assumed
- *
- * @throws IllegalArgumentException if the string parameter is null
- * @throws UnsupportedCharsetException Thrown when the named charset is not available in
- * this instance of the Java virtual machine
- */
- public StringEntityHC4(final String string, final String charset)
- throws UnsupportedCharsetException {
- this(string, ContentType.create(ContentType.TEXT_PLAIN.getMimeType(), charset));
- }
-
- /**
- * Creates a StringEntityHC4 with the specified content and charset. The MIME type defaults
- * to "text/plain".
- *
- * @param string content to be used. Not {@code null}.
- * @param charset character set to be used. May be {@code null}, in which case the default
- * is {@link HTTP#DEFAULT_CONTENT_CHARSET} is assumed
- *
- * @throws IllegalArgumentException if the string parameter is null
- *
- * @since 4.2
- */
- public StringEntityHC4(final String string, final Charset charset) {
- this(string, ContentType.create(ContentType.TEXT_PLAIN.getMimeType(), charset));
- }
-
- /**
- * Creates a StringEntityHC4 with the specified content. The content type defaults to
- * {@link ContentType#TEXT_PLAIN}.
- *
- * @param string content to be used. Not {@code null}.
- *
- * @throws IllegalArgumentException if the string parameter is null
- * @throws UnsupportedEncodingException if the default HTTP charset is not supported.
- */
- public StringEntityHC4(final String string)
- throws UnsupportedEncodingException {
- this(string, ContentType.DEFAULT_TEXT);
- }
-
- public boolean isRepeatable() {
- return true;
- }
-
- public long getContentLength() {
- return this.content.length;
- }
-
- public InputStream getContent() throws IOException {
- return new ByteArrayInputStream(this.content);
- }
-
- public void writeTo(final OutputStream outstream) throws IOException {
- Args.notNull(outstream, "Output stream");
- outstream.write(this.content);
- outstream.flush();
- }
-
- /**
- * Tells that this entity is not streaming.
- *
- * @return false
- */
- public boolean isStreaming() {
- return false;
- }
-
- @Override
- public Object clone() throws CloneNotSupportedException {
- return super.clone();
- }
-
-} // class StringEntityHC4
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/entity/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/entity/package-info.java
deleted file mode 100644
index 83b867a9..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/entity/package-info.java
+++ /dev/null
@@ -1,31 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Core HTTP entity implementations.
- */
-package org.apache.http.entity;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/BHttpConnectionBase.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
deleted file mode 100644
index 2e221407..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/BHttpConnectionBase.java
+++ /dev/null
@@ -1,393 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.InetAddress;
-import java.net.Socket;
-import java.net.SocketAddress;
-import java.net.SocketException;
-import java.net.SocketTimeoutException;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
-
-import org.apache.http.Header;
-import org.apache.http.HttpConnection;
-import org.apache.http.HttpConnectionMetrics;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpInetConnection;
-import org.apache.http.HttpMessage;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.config.MessageConstraints;
-import org.apache.http.entity.BasicHttpEntityHC4;
-import org.apache.http.entity.ContentLengthStrategy;
-import org.apache.http.impl.entity.LaxContentLengthStrategyHC4;
-import org.apache.http.impl.entity.StrictContentLengthStrategyHC4;
-import org.apache.http.impl.io.ChunkedInputStreamHC4;
-import org.apache.http.impl.io.ChunkedOutputStreamHC4;
-import org.apache.http.impl.io.ContentLengthInputStreamHC4;
-import org.apache.http.impl.io.ContentLengthOutputStreamHC4;
-import org.apache.http.impl.io.HttpTransportMetricsImpl;
-import org.apache.http.impl.io.IdentityInputStreamHC4;
-import org.apache.http.impl.io.IdentityOutputStreamHC4;
-import org.apache.http.impl.io.SessionInputBufferImpl;
-import org.apache.http.impl.io.SessionOutputBufferImpl;
-import org.apache.http.io.SessionInputBuffer;
-import org.apache.http.io.SessionOutputBuffer;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.util.Args;
-import org.apache.http.util.Asserts;
-import org.apache.http.util.NetUtils;
-
-/**
- * This class serves as a base for all {@link HttpConnection} implementations and provides
- * functionality common to both client and server HTTP connections.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class BHttpConnectionBase implements HttpConnection, HttpInetConnection {
-
- private final SessionInputBufferImpl inbuffer;
- private final SessionOutputBufferImpl outbuffer;
- private final HttpConnectionMetricsImpl connMetrics;
- private final ContentLengthStrategy incomingContentStrategy;
- private final ContentLengthStrategy outgoingContentStrategy;
-
- private volatile boolean open;
- private volatile Socket socket;
-
- /**
- * Creates new instance of BHttpConnectionBase.
- *
- * @param buffersize buffer size. Must be a positive number.
- * @param fragmentSizeHint fragment size hint.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
- * If null simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
- * If null simple type cast will be used for char to byte conversion.
- * @param constraints Message constraints. If null
- * {@link MessageConstraints#DEFAULT} will be used.
- * @param incomingContentStrategy incoming content length strategy. If null
- * {@link LaxContentLengthStrategyHC4#INSTANCE} will be used.
- * @param outgoingContentStrategy outgoing content length strategy. If null
- * {@link StrictContentLengthStrategyHC4#INSTANCE} will be used.
- */
- protected BHttpConnectionBase(
- final int buffersize,
- final int fragmentSizeHint,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
- final MessageConstraints constraints,
- final ContentLengthStrategy incomingContentStrategy,
- final ContentLengthStrategy outgoingContentStrategy) {
- super();
- Args.positive(buffersize, "Buffer size");
- final HttpTransportMetricsImpl inTransportMetrics = new HttpTransportMetricsImpl();
- final HttpTransportMetricsImpl outTransportMetrics = new HttpTransportMetricsImpl();
- this.inbuffer = new SessionInputBufferImpl(inTransportMetrics, buffersize, -1,
- constraints != null ? constraints : MessageConstraints.DEFAULT, chardecoder);
- this.outbuffer = new SessionOutputBufferImpl(outTransportMetrics, buffersize, fragmentSizeHint,
- charencoder);
- this.connMetrics = new HttpConnectionMetricsImpl(inTransportMetrics, outTransportMetrics);
- this.incomingContentStrategy = incomingContentStrategy != null ? incomingContentStrategy :
- LaxContentLengthStrategyHC4.INSTANCE;
- this.outgoingContentStrategy = outgoingContentStrategy != null ? outgoingContentStrategy :
- StrictContentLengthStrategyHC4.INSTANCE;
- }
-
- protected void ensureOpen() throws IOException {
- Asserts.check(this.open, "Connection is not open");
- if (!this.inbuffer.isBound()) {
- this.inbuffer.bind(getSocketInputStream(this.socket));
- }
- if (!this.outbuffer.isBound()) {
- this.outbuffer.bind(getSocketOutputStream(this.socket));
- }
- }
-
- protected InputStream getSocketInputStream(final Socket socket) throws IOException {
- return socket.getInputStream();
- }
-
- protected OutputStream getSocketOutputStream(final Socket socket) throws IOException {
- return socket.getOutputStream();
- }
-
- /**
- * Binds this connection to the given {@link Socket}. This socket will be
- * used by the connection to send and receive data.
- *
- * After this method's execution the connection status will be reported
- * as open and the {@link #isOpen()} will return true.
- *
- * @param socket the socket.
- * @throws IOException in case of an I/O error.
- */
- protected void bind(final Socket socket) throws IOException {
- Args.notNull(socket, "Socket");
- this.socket = socket;
- this.open = true;
- this.inbuffer.bind(null);
- this.outbuffer.bind(null);
- }
-
- protected SessionInputBuffer getSessionInputBuffer() {
- return this.inbuffer;
- }
-
- protected SessionOutputBuffer getSessionOutputBuffer() {
- return this.outbuffer;
- }
-
- protected void doFlush() throws IOException {
- this.outbuffer.flush();
- }
-
- public boolean isOpen() {
- return this.open;
- }
-
- protected Socket getSocket() {
- return this.socket;
- }
-
- protected OutputStream createOutputStream(
- final long len,
- final SessionOutputBuffer outbuffer) {
- if (len == ContentLengthStrategy.CHUNKED) {
- return new ChunkedOutputStreamHC4(2048, outbuffer);
- } else if (len == ContentLengthStrategy.IDENTITY) {
- return new IdentityOutputStreamHC4(outbuffer);
- } else {
- return new ContentLengthOutputStreamHC4(outbuffer, len);
- }
- }
-
- protected OutputStream prepareOutput(final HttpMessage message) throws HttpException {
- final long len = this.outgoingContentStrategy.determineLength(message);
- return createOutputStream(len, this.outbuffer);
- }
-
- protected InputStream createInputStream(
- final long len,
- final SessionInputBuffer inbuffer) {
- if (len == ContentLengthStrategy.CHUNKED) {
- return new ChunkedInputStreamHC4(inbuffer);
- } else if (len == ContentLengthStrategy.IDENTITY) {
- return new IdentityInputStreamHC4(inbuffer);
- } else {
- return new ContentLengthInputStreamHC4(inbuffer, len);
- }
- }
-
- protected HttpEntity prepareInput(final HttpMessage message) throws HttpException {
- final BasicHttpEntityHC4 entity = new BasicHttpEntityHC4();
-
- final long len = this.incomingContentStrategy.determineLength(message);
- final InputStream instream = createInputStream(len, this.inbuffer);
- if (len == ContentLengthStrategy.CHUNKED) {
- entity.setChunked(true);
- entity.setContentLength(-1);
- entity.setContent(instream);
- } else if (len == ContentLengthStrategy.IDENTITY) {
- entity.setChunked(false);
- entity.setContentLength(-1);
- entity.setContent(instream);
- } else {
- entity.setChunked(false);
- entity.setContentLength(len);
- entity.setContent(instream);
- }
-
- final Header contentTypeHeader = message.getFirstHeader(HTTP.CONTENT_TYPE);
- if (contentTypeHeader != null) {
- entity.setContentType(contentTypeHeader);
- }
- final Header contentEncodingHeader = message.getFirstHeader(HTTP.CONTENT_ENCODING);
- if (contentEncodingHeader != null) {
- entity.setContentEncoding(contentEncodingHeader);
- }
- return entity;
- }
-
- public InetAddress getLocalAddress() {
- if (this.socket != null) {
- return this.socket.getLocalAddress();
- } else {
- return null;
- }
- }
-
- public int getLocalPort() {
- if (this.socket != null) {
- return this.socket.getLocalPort();
- } else {
- return -1;
- }
- }
-
- public InetAddress getRemoteAddress() {
- if (this.socket != null) {
- return this.socket.getInetAddress();
- } else {
- return null;
- }
- }
-
- public int getRemotePort() {
- if (this.socket != null) {
- return this.socket.getPort();
- } else {
- return -1;
- }
- }
-
- public void setSocketTimeout(final int timeout) {
- if (this.socket != null) {
- try {
- this.socket.setSoTimeout(timeout);
- } catch (final SocketException ignore) {
- // It is not quite clear from the Sun's documentation if there are any
- // other legitimate cases for a socket exception to be thrown when setting
- // SO_TIMEOUT besides the socket being already closed
- }
- }
- }
-
- public int getSocketTimeout() {
- if (this.socket != null) {
- try {
- return this.socket.getSoTimeout();
- } catch (final SocketException ignore) {
- return -1;
- }
- } else {
- return -1;
- }
- }
-
- public void shutdown() throws IOException {
- this.open = false;
- final Socket tmpsocket = this.socket;
- if (tmpsocket != null) {
- tmpsocket.close();
- }
- }
-
- public void close() throws IOException {
- if (!this.open) {
- return;
- }
- this.open = false;
- final Socket sock = this.socket;
- try {
- this.inbuffer.clear();
- this.outbuffer.flush();
- try {
- try {
- sock.shutdownOutput();
- } catch (final IOException ignore) {
- }
- try {
- sock.shutdownInput();
- } catch (final IOException ignore) {
- }
- } catch (final UnsupportedOperationException ignore) {
- // if one isn't supported, the other one isn't either
- }
- } finally {
- sock.close();
- }
- }
-
- private int fillInputBuffer(final int timeout) throws IOException {
- final int oldtimeout = this.socket.getSoTimeout();
- try {
- this.socket.setSoTimeout(timeout);
- return this.inbuffer.fillBuffer();
- } finally {
- this.socket.setSoTimeout(oldtimeout);
- }
- }
-
- protected boolean awaitInput(final int timeout) throws IOException {
- if (this.inbuffer.hasBufferedData()) {
- return true;
- }
- fillInputBuffer(timeout);
- return this.inbuffer.hasBufferedData();
- }
-
- public boolean isStale() {
- if (!isOpen()) {
- return true;
- }
- try {
- final int bytesRead = fillInputBuffer(1);
- return bytesRead < 0;
- } catch (final SocketTimeoutException ex) {
- return false;
- } catch (final IOException ex) {
- return true;
- }
- }
-
- protected void incrementRequestCount() {
- this.connMetrics.incrementRequestCount();
- }
-
- protected void incrementResponseCount() {
- this.connMetrics.incrementResponseCount();
- }
-
- public HttpConnectionMetrics getMetrics() {
- return this.connMetrics;
- }
-
- @Override
- public String toString() {
- if (this.socket != null) {
- final StringBuilder buffer = new StringBuilder();
- final SocketAddress remoteAddress = this.socket.getRemoteSocketAddress();
- final SocketAddress localAddress = this.socket.getLocalSocketAddress();
- if (remoteAddress != null && localAddress != null) {
- NetUtils.formatAddress(buffer, localAddress);
- buffer.append("<->");
- NetUtils.formatAddress(buffer, remoteAddress);
- }
- return buffer.toString();
- } else {
- return "[Not bound]";
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/ConnSupport.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/ConnSupport.java
deleted file mode 100644
index a957629f..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/ConnSupport.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl;
-
-import org.apache.http.config.ConnectionConfig;
-
-import java.nio.charset.Charset;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
-import java.nio.charset.CodingErrorAction;
-
-/**
- * Connection support methods.
- *
- * @since 4.3
- */
-public final class ConnSupport {
-
- public static CharsetDecoder createDecoder(final ConnectionConfig cconfig) {
- if (cconfig == null) {
- return null;
- }
- final Charset charset = cconfig.getCharset();
- final CodingErrorAction malformed = cconfig.getMalformedInputAction();
- final CodingErrorAction unmappable = cconfig.getUnmappableInputAction();
- if (charset != null) {
- return charset.newDecoder()
- .onMalformedInput(malformed != null ? malformed : CodingErrorAction.REPORT)
- .onUnmappableCharacter(unmappable != null ? unmappable: CodingErrorAction.REPORT);
- } else {
- return null;
- }
- }
-
- public static CharsetEncoder createEncoder(final ConnectionConfig cconfig) {
- if (cconfig == null) {
- return null;
- }
- final Charset charset = cconfig.getCharset();
- if (charset != null) {
- final CodingErrorAction malformed = cconfig.getMalformedInputAction();
- final CodingErrorAction unmappable = cconfig.getUnmappableInputAction();
- return charset.newEncoder()
- .onMalformedInput(malformed != null ? malformed : CodingErrorAction.REPORT)
- .onUnmappableCharacter(unmappable != null ? unmappable: CodingErrorAction.REPORT);
- } else {
- return null;
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
deleted file mode 100644
index e40a6f32..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultBHttpClientConnection.java
+++ /dev/null
@@ -1,182 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.Socket;
-import java.net.SocketTimeoutException;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
-
-import org.apache.http.HttpClientConnection;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.config.MessageConstraints;
-import org.apache.http.entity.ContentLengthStrategy;
-import org.apache.http.impl.io.DefaultHttpRequestWriterFactory;
-import org.apache.http.impl.io.DefaultHttpResponseParserFactory;
-import org.apache.http.io.HttpMessageParser;
-import org.apache.http.io.HttpMessageParserFactory;
-import org.apache.http.io.HttpMessageWriter;
-import org.apache.http.io.HttpMessageWriterFactory;
-import org.apache.http.util.Args;
-
-/**
- * Default implementation of {@link HttpClientConnection}.
- *
- * @since 4.3
- */
-@NotThreadSafe
-public class DefaultBHttpClientConnection extends BHttpConnectionBase
- implements HttpClientConnection {
-
- private final HttpMessageParser responseParser;
- private final HttpMessageWriter requestWriter;
-
- /**
- * Creates new instance of DefaultBHttpClientConnection.
- *
- * @param buffersize buffer size. Must be a positive number.
- * @param fragmentSizeHint fragment size hint.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
- * If null simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
- * If null simple type cast will be used for char to byte conversion.
- * @param constraints Message constraints. If null
- * {@link MessageConstraints#DEFAULT} will be used.
- * @param incomingContentStrategy incoming content length strategy. If null
- * {@link org.apache.http.impl.entity.LaxContentLengthStrategyHC4#INSTANCE} will be used.
- * @param outgoingContentStrategy outgoing content length strategy. If null
- * {@link org.apache.http.impl.entity.StrictContentLengthStrategyHC4#INSTANCE} will be used.
- * @param requestWriterFactory request writer factory. If null
- * {@link DefaultHttpRequestWriterFactory#INSTANCE} will be used.
- * @param responseParserFactory response parser factory. If null
- * {@link DefaultHttpResponseParserFactory#INSTANCE} will be used.
- */
- public DefaultBHttpClientConnection(
- final int buffersize,
- final int fragmentSizeHint,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
- final MessageConstraints constraints,
- final ContentLengthStrategy incomingContentStrategy,
- final ContentLengthStrategy outgoingContentStrategy,
- final HttpMessageWriterFactory requestWriterFactory,
- final HttpMessageParserFactory responseParserFactory) {
- super(buffersize, fragmentSizeHint, chardecoder, charencoder,
- constraints, incomingContentStrategy, outgoingContentStrategy);
- this.requestWriter = (requestWriterFactory != null ? requestWriterFactory :
- DefaultHttpRequestWriterFactory.INSTANCE).create(getSessionOutputBuffer());
- this.responseParser = (responseParserFactory != null ? responseParserFactory :
- DefaultHttpResponseParserFactory.INSTANCE).create(getSessionInputBuffer(), constraints);
- }
-
- public DefaultBHttpClientConnection(
- final int buffersize,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
- final MessageConstraints constraints) {
- this(buffersize, buffersize, chardecoder, charencoder, constraints, null, null, null, null);
- }
-
- public DefaultBHttpClientConnection(final int buffersize) {
- this(buffersize, buffersize, null, null, null, null, null, null, null);
- }
-
- protected void onResponseReceived(final HttpResponse response) {
- }
-
- protected void onRequestSubmitted(final HttpRequest request) {
- }
-
- @Override
- public void bind(final Socket socket) throws IOException {
- super.bind(socket);
- }
-
- public boolean isResponseAvailable(final int timeout) throws IOException {
- ensureOpen();
- try {
- return awaitInput(timeout);
- } catch (final SocketTimeoutException ex) {
- return false;
- }
- }
-
- public void sendRequestHeader(final HttpRequest request)
- throws HttpException, IOException {
- Args.notNull(request, "HTTP request");
- ensureOpen();
- this.requestWriter.write(request);
- onRequestSubmitted(request);
- incrementRequestCount();
- }
-
- public void sendRequestEntity(final HttpEntityEnclosingRequest request)
- throws HttpException, IOException {
- Args.notNull(request, "HTTP request");
- ensureOpen();
- final HttpEntity entity = request.getEntity();
- if (entity == null) {
- return;
- }
- final OutputStream outstream = prepareOutput(request);
- entity.writeTo(outstream);
- outstream.close();
- }
-
- public HttpResponse receiveResponseHeader() throws HttpException, IOException {
- ensureOpen();
- final HttpResponse response = (HttpResponse) this.responseParser.parse();
- onResponseReceived(response);
- if (response.getStatusLine().getStatusCode() >= HttpStatus.SC_OK) {
- incrementResponseCount();
- }
- return response;
- }
-
- public void receiveResponseEntity(
- final HttpResponse response) throws HttpException, IOException {
- Args.notNull(response, "HTTP response");
- ensureOpen();
- final HttpEntity entity = prepareInput(response);
- response.setEntity(entity);
- }
-
- public void flush() throws IOException {
- ensureOpen();
- doFlush();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultBHttpClientConnectionFactory.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultBHttpClientConnectionFactory.java
deleted file mode 100644
index f44be115..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultBHttpClientConnectionFactory.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import org.apache.http.HttpConnectionFactory;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.config.ConnectionConfig;
-import org.apache.http.entity.ContentLengthStrategy;
-import org.apache.http.io.HttpMessageParserFactory;
-import org.apache.http.io.HttpMessageWriterFactory;
-
-import java.io.IOException;
-import java.net.Socket;
-
-/**
- * Default factory for {@link org.apache.http.HttpClientConnection}s.
- *
- * @since 4.3
- */
-@Immutable
-public class DefaultBHttpClientConnectionFactory
- implements HttpConnectionFactory {
-
- public static final DefaultBHttpClientConnectionFactory INSTANCE = new DefaultBHttpClientConnectionFactory();
-
- private final ConnectionConfig cconfig;
- private final ContentLengthStrategy incomingContentStrategy;
- private final ContentLengthStrategy outgoingContentStrategy;
- private final HttpMessageWriterFactory requestWriterFactory;
- private final HttpMessageParserFactory responseParserFactory;
-
- public DefaultBHttpClientConnectionFactory(
- final ConnectionConfig cconfig,
- final ContentLengthStrategy incomingContentStrategy,
- final ContentLengthStrategy outgoingContentStrategy,
- final HttpMessageWriterFactory requestWriterFactory,
- final HttpMessageParserFactory responseParserFactory) {
- super();
- this.cconfig = cconfig != null ? cconfig : ConnectionConfig.DEFAULT;
- this.incomingContentStrategy = incomingContentStrategy;
- this.outgoingContentStrategy = outgoingContentStrategy;
- this.requestWriterFactory = requestWriterFactory;
- this.responseParserFactory = responseParserFactory;
- }
-
- public DefaultBHttpClientConnectionFactory(
- final ConnectionConfig cconfig,
- final HttpMessageWriterFactory requestWriterFactory,
- final HttpMessageParserFactory responseParserFactory) {
- this(cconfig, null, null, requestWriterFactory, responseParserFactory);
- }
-
- public DefaultBHttpClientConnectionFactory(final ConnectionConfig cconfig) {
- this(cconfig, null, null, null, null);
- }
-
- public DefaultBHttpClientConnectionFactory() {
- this(null, null, null, null, null);
- }
-
- public DefaultBHttpClientConnection createConnection(final Socket socket) throws IOException {
- final DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(
- this.cconfig.getBufferSize(),
- this.cconfig.getFragmentSizeHint(),
- ConnSupport.createDecoder(this.cconfig),
- ConnSupport.createEncoder(this.cconfig),
- this.cconfig.getMessageConstraints(),
- this.incomingContentStrategy,
- this.outgoingContentStrategy,
- this.requestWriterFactory,
- this.responseParserFactory);
- conn.bind(socket);
- return conn;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
deleted file mode 100644
index e4848387..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultBHttpServerConnection.java
+++ /dev/null
@@ -1,174 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.Socket;
-import java.nio.charset.CharsetDecoder;
-import java.nio.charset.CharsetEncoder;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpException;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpServerConnection;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.config.MessageConstraints;
-import org.apache.http.entity.ContentLengthStrategy;
-import org.apache.http.impl.entity.DisallowIdentityContentLengthStrategy;
-import org.apache.http.impl.io.DefaultHttpRequestParserFactory;
-import org.apache.http.impl.io.DefaultHttpResponseWriterFactory;
-import org.apache.http.io.HttpMessageParser;
-import org.apache.http.io.HttpMessageParserFactory;
-import org.apache.http.io.HttpMessageWriter;
-import org.apache.http.io.HttpMessageWriterFactory;
-import org.apache.http.util.Args;
-
-/**
- * Default implementation of {@link HttpServerConnection}.
- *
- * @since 4.3
- */
-@NotThreadSafe
-public class DefaultBHttpServerConnection extends BHttpConnectionBase
- implements HttpServerConnection {
-
- private final HttpMessageParser requestParser;
- private final HttpMessageWriter responseWriter;
-
- /**
- * Creates new instance of DefaultBHttpServerConnection.
- *
- * @param buffersize buffer size. Must be a positive number.
- * @param fragmentSizeHint fragment size hint.
- * @param chardecoder decoder to be used for decoding HTTP protocol elements.
- * If null simple type cast will be used for byte to char conversion.
- * @param charencoder encoder to be used for encoding HTTP protocol elements.
- * If null simple type cast will be used for char to byte conversion.
- * @param constraints Message constraints. If null
- * {@link MessageConstraints#DEFAULT} will be used.
- * @param incomingContentStrategy incoming content length strategy. If null
- * {@link DisallowIdentityContentLengthStrategy#INSTANCE} will be used.
- * @param outgoingContentStrategy outgoing content length strategy. If null
- * {@link org.apache.http.impl.entity.StrictContentLengthStrategyHC4#INSTANCE} will be used.
- * @param requestParserFactory request parser factory. If null
- * {@link DefaultHttpRequestParserFactory#INSTANCE} will be used.
- * @param responseWriterFactory response writer factory. If null
- * {@link DefaultHttpResponseWriterFactory#INSTANCE} will be used.
- */
- public DefaultBHttpServerConnection(
- final int buffersize,
- final int fragmentSizeHint,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
- final MessageConstraints constraints,
- final ContentLengthStrategy incomingContentStrategy,
- final ContentLengthStrategy outgoingContentStrategy,
- final HttpMessageParserFactory requestParserFactory,
- final HttpMessageWriterFactory responseWriterFactory) {
- super(buffersize, fragmentSizeHint, chardecoder, charencoder, constraints,
- incomingContentStrategy != null ? incomingContentStrategy :
- DisallowIdentityContentLengthStrategy.INSTANCE, outgoingContentStrategy);
- this.requestParser = (requestParserFactory != null ? requestParserFactory :
- DefaultHttpRequestParserFactory.INSTANCE).create(getSessionInputBuffer(), constraints);
- this.responseWriter = (responseWriterFactory != null ? responseWriterFactory :
- DefaultHttpResponseWriterFactory.INSTANCE).create(getSessionOutputBuffer());
- }
-
- public DefaultBHttpServerConnection(
- final int buffersize,
- final CharsetDecoder chardecoder,
- final CharsetEncoder charencoder,
- final MessageConstraints constraints) {
- this(buffersize, buffersize, chardecoder, charencoder, constraints, null, null, null, null);
- }
-
- public DefaultBHttpServerConnection(final int buffersize) {
- this(buffersize, buffersize, null, null, null, null, null, null, null);
- }
-
- protected void onRequestReceived(final HttpRequest request) {
- }
-
- protected void onResponseSubmitted(final HttpResponse response) {
- }
-
- @Override
- public void bind(final Socket socket) throws IOException {
- super.bind(socket);
- }
-
- public HttpRequest receiveRequestHeader()
- throws HttpException, IOException {
- ensureOpen();
- final HttpRequest request = (HttpRequest) this.requestParser.parse();
- onRequestReceived(request);
- incrementRequestCount();
- return request;
- }
-
- public void receiveRequestEntity(final HttpEntityEnclosingRequest request)
- throws HttpException, IOException {
- Args.notNull(request, "HTTP request");
- ensureOpen();
- final HttpEntity entity = prepareInput(request);
- request.setEntity(entity);
- }
-
- public void sendResponseHeader(final HttpResponse response)
- throws HttpException, IOException {
- Args.notNull(response, "HTTP response");
- ensureOpen();
- this.responseWriter.write(response);
- onResponseSubmitted(response);
- if (response.getStatusLine().getStatusCode() >= 200) {
- incrementResponseCount();
- }
- }
-
- public void sendResponseEntity(final HttpResponse response)
- throws HttpException, IOException {
- Args.notNull(response, "HTTP response");
- ensureOpen();
- final HttpEntity entity = response.getEntity();
- if (entity == null) {
- return;
- }
- final OutputStream outstream = prepareOutput(response);
- entity.writeTo(outstream);
- outstream.close();
- }
-
- public void flush() throws IOException {
- ensureOpen();
- doFlush();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultBHttpServerConnectionFactory.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultBHttpServerConnectionFactory.java
deleted file mode 100644
index b944b3df..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultBHttpServerConnectionFactory.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import org.apache.http.HttpConnectionFactory;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.config.ConnectionConfig;
-import org.apache.http.entity.ContentLengthStrategy;
-import org.apache.http.io.HttpMessageParserFactory;
-import org.apache.http.io.HttpMessageWriterFactory;
-
-import java.io.IOException;
-import java.net.Socket;
-
-/**
- * Default factory for {@link org.apache.http.HttpServerConnection}s.
- *
- * @since 4.3
- */
-@Immutable
-public class DefaultBHttpServerConnectionFactory
- implements HttpConnectionFactory {
-
- public static final DefaultBHttpServerConnectionFactory INSTANCE = new DefaultBHttpServerConnectionFactory();
-
- private final ConnectionConfig cconfig;
- private final ContentLengthStrategy incomingContentStrategy;
- private final ContentLengthStrategy outgoingContentStrategy;
- private final HttpMessageParserFactory requestParserFactory;
- private final HttpMessageWriterFactory responseWriterFactory;
-
- public DefaultBHttpServerConnectionFactory(
- final ConnectionConfig cconfig,
- final ContentLengthStrategy incomingContentStrategy,
- final ContentLengthStrategy outgoingContentStrategy,
- final HttpMessageParserFactory requestParserFactory,
- final HttpMessageWriterFactory responseWriterFactory) {
- super();
- this.cconfig = cconfig != null ? cconfig : ConnectionConfig.DEFAULT;
- this.incomingContentStrategy = incomingContentStrategy;
- this.outgoingContentStrategy = outgoingContentStrategy;
- this.requestParserFactory = requestParserFactory;
- this.responseWriterFactory = responseWriterFactory;
- }
-
- public DefaultBHttpServerConnectionFactory(
- final ConnectionConfig cconfig,
- final HttpMessageParserFactory requestParserFactory,
- final HttpMessageWriterFactory responseWriterFactory) {
- this(cconfig, null, null, requestParserFactory, responseWriterFactory);
- }
-
- public DefaultBHttpServerConnectionFactory(final ConnectionConfig cconfig) {
- this(cconfig, null, null, null, null);
- }
-
- public DefaultBHttpServerConnectionFactory() {
- this(null, null, null, null, null);
- }
-
- public DefaultBHttpServerConnection createConnection(final Socket socket) throws IOException {
- final DefaultBHttpServerConnection conn = new DefaultBHttpServerConnection(
- this.cconfig.getBufferSize(),
- this.cconfig.getFragmentSizeHint(),
- ConnSupport.createDecoder(this.cconfig),
- ConnSupport.createEncoder(this.cconfig),
- this.cconfig.getMessageConstraints(),
- this.incomingContentStrategy,
- this.outgoingContentStrategy,
- this.requestParserFactory,
- this.responseWriterFactory);
- conn.bind(socket);
- return conn;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategyHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategyHC4.java
deleted file mode 100644
index bcdd1000..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultConnectionReuseStrategyHC4.java
+++ /dev/null
@@ -1,189 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.Header;
-import org.apache.http.HeaderIterator;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.HttpVersion;
-import org.apache.http.ParseException;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.TokenIterator;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.message.BasicTokenIterator;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-
-/**
- * Default implementation of a strategy deciding about connection re-use.
- * The default implementation first checks some basics, for example
- * whether the connection is still open or whether the end of the
- * request entity can be determined without closing the connection.
- * If these checks pass, the tokens in the Connection header will
- * be examined. In the absence of a Connection header, the
- * non-standard but commonly used Proxy-Connection header takes
- * it's role. A token close indicates that the connection cannot
- * be reused. If there is no such token, a token keep-alive
- * indicates that the connection should be re-used. If neither token is found,
- * or if there are no Connection headers, the default policy for
- * the HTTP version is applied. Since HTTP/1.1, connections are
- * re-used by default. Up until HTTP/1.0, connections are not
- * re-used by default.
- *
- * @since 4.0
- */
-@Immutable
-public class DefaultConnectionReuseStrategyHC4 implements ConnectionReuseStrategy {
-
- public static final DefaultConnectionReuseStrategyHC4 INSTANCE = new DefaultConnectionReuseStrategyHC4();
-
- public DefaultConnectionReuseStrategyHC4() {
- super();
- }
-
- // see interface ConnectionReuseStrategy
- public boolean keepAlive(final HttpResponse response,
- final HttpContext context) {
- Args.notNull(response, "HTTP response");
- Args.notNull(context, "HTTP context");
-
- // Check for a self-terminating entity. If the end of the entity will
- // be indicated by closing the connection, there is no keep-alive.
- final ProtocolVersion ver = response.getStatusLine().getProtocolVersion();
- final Header teh = response.getFirstHeader(HTTP.TRANSFER_ENCODING);
- if (teh != null) {
- if (!HTTP.CHUNK_CODING.equalsIgnoreCase(teh.getValue())) {
- return false;
- }
- } else {
- if (canResponseHaveBody(response)) {
- final Header[] clhs = response.getHeaders(HTTP.CONTENT_LEN);
- // Do not reuse if not properly content-length delimited
- if (clhs.length == 1) {
- final Header clh = clhs[0];
- try {
- final int contentLen = Integer.parseInt(clh.getValue());
- if (contentLen < 0) {
- return false;
- }
- } catch (final NumberFormatException ex) {
- return false;
- }
- } else {
- return false;
- }
- }
- }
-
- // Check for the "Connection" header. If that is absent, check for
- // the "Proxy-Connection" header. The latter is an unspecified and
- // broken but unfortunately common extension of HTTP.
- HeaderIterator hit = response.headerIterator(HTTP.CONN_DIRECTIVE);
- if (!hit.hasNext()) {
- hit = response.headerIterator("Proxy-Connection");
- }
-
- // Experimental usage of the "Connection" header in HTTP/1.0 is
- // documented in RFC 2068, section 19.7.1. A token "keep-alive" is
- // used to indicate that the connection should be persistent.
- // Note that the final specification of HTTP/1.1 in RFC 2616 does not
- // include this information. Neither is the "Connection" header
- // mentioned in RFC 1945, which informally describes HTTP/1.0.
- //
- // RFC 2616 specifies "close" as the only connection token with a
- // specific meaning: it disables persistent connections.
- //
- // The "Proxy-Connection" header is not formally specified anywhere,
- // but is commonly used to carry one token, "close" or "keep-alive".
- // The "Connection" header, on the other hand, is defined as a
- // sequence of tokens, where each token is a header name, and the
- // token "close" has the above-mentioned additional meaning.
- //
- // To get through this mess, we treat the "Proxy-Connection" header
- // in exactly the same way as the "Connection" header, but only if
- // the latter is missing. We scan the sequence of tokens for both
- // "close" and "keep-alive". As "close" is specified by RFC 2068,
- // it takes precedence and indicates a non-persistent connection.
- // If there is no "close" but a "keep-alive", we take the hint.
-
- if (hit.hasNext()) {
- try {
- final TokenIterator ti = createTokenIterator(hit);
- boolean keepalive = false;
- while (ti.hasNext()) {
- final String token = ti.nextToken();
- if (HTTP.CONN_CLOSE.equalsIgnoreCase(token)) {
- return false;
- } else if (HTTP.CONN_KEEP_ALIVE.equalsIgnoreCase(token)) {
- // continue the loop, there may be a "close" afterwards
- keepalive = true;
- }
- }
- if (keepalive)
- {
- return true;
- // neither "close" nor "keep-alive", use default policy
- }
-
- } catch (final ParseException px) {
- // invalid connection header means no persistent connection
- // we don't have logging in HttpCore, so the exception is lost
- return false;
- }
- }
-
- // default since HTTP/1.1 is persistent, before it was non-persistent
- return !ver.lessEquals(HttpVersion.HTTP_1_0);
- }
-
-
- /**
- * Creates a token iterator from a header iterator.
- * This method can be overridden to replace the implementation of
- * the token iterator.
- *
- * @param hit the header iterator
- *
- * @return the token iterator
- */
- protected TokenIterator createTokenIterator(final HeaderIterator hit) {
- return new BasicTokenIterator(hit);
- }
-
- private boolean canResponseHaveBody(final HttpResponse response) {
- final int status = response.getStatusLine().getStatusCode();
- return status >= HttpStatus.SC_OK
- && status != HttpStatus.SC_NO_CONTENT
- && status != HttpStatus.SC_NOT_MODIFIED
- && status != HttpStatus.SC_RESET_CONTENT;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultHttpRequestFactoryHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultHttpRequestFactoryHC4.java
deleted file mode 100644
index f502d972..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultHttpRequestFactoryHC4.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestFactory;
-import org.apache.http.MethodNotSupportedException;
-import org.apache.http.RequestLine;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.message.BasicHttpEntityEnclosingRequest;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.util.Args;
-
-/**
- * Default factory for creating {@link HttpRequest} objects.
- *
- * @since 4.0
- */
-@Immutable
-public class DefaultHttpRequestFactoryHC4 implements HttpRequestFactory {
-
- public static final DefaultHttpRequestFactoryHC4 INSTANCE = new DefaultHttpRequestFactoryHC4();
-
- private static final String[] RFC2616_COMMON_METHODS = {
- "GET"
- };
-
- private static final String[] RFC2616_ENTITY_ENC_METHODS = {
- "POST",
- "PUT"
- };
-
- private static final String[] RFC2616_SPECIAL_METHODS = {
- "HEAD",
- "OPTIONS",
- "DELETE",
- "TRACE",
- "CONNECT"
- };
-
-
- public DefaultHttpRequestFactoryHC4() {
- super();
- }
-
- private static boolean isOneOf(final String[] methods, final String method) {
- for (final String method2 : methods) {
- if (method2.equalsIgnoreCase(method)) {
- return true;
- }
- }
- return false;
- }
-
- public HttpRequest newHttpRequest(final RequestLine requestline)
- throws MethodNotSupportedException {
- Args.notNull(requestline, "Request line");
- final String method = requestline.getMethod();
- if (isOneOf(RFC2616_COMMON_METHODS, method)) {
- return new BasicHttpRequest(requestline);
- } else if (isOneOf(RFC2616_ENTITY_ENC_METHODS, method)) {
- return new BasicHttpEntityEnclosingRequest(requestline);
- } else if (isOneOf(RFC2616_SPECIAL_METHODS, method)) {
- return new BasicHttpRequest(requestline);
- } else {
- throw new MethodNotSupportedException(method + " method not supported");
- }
- }
-
- public HttpRequest newHttpRequest(final String method, final String uri)
- throws MethodNotSupportedException {
- if (isOneOf(RFC2616_COMMON_METHODS, method)) {
- return new BasicHttpRequest(method, uri);
- } else if (isOneOf(RFC2616_ENTITY_ENC_METHODS, method)) {
- return new BasicHttpEntityEnclosingRequest(method, uri);
- } else if (isOneOf(RFC2616_SPECIAL_METHODS, method)) {
- return new BasicHttpRequest(method, uri);
- } else {
- throw new MethodNotSupportedException(method
- + " method not supported");
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultHttpResponseFactoryHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultHttpResponseFactoryHC4.java
deleted file mode 100644
index a80b12ee..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/DefaultHttpResponseFactoryHC4.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.util.Locale;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpResponseFactory;
-import org.apache.http.ProtocolVersion;
-import org.apache.http.ReasonPhraseCatalog;
-import org.apache.http.StatusLine;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.message.BasicHttpResponse;
-import org.apache.http.message.BasicStatusLine;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-
-/**
- * Default factory for creating {@link HttpResponse} objects.
- *
- * @since 4.0
- */
-@Immutable
-public class DefaultHttpResponseFactoryHC4 implements HttpResponseFactory {
-
- public static final DefaultHttpResponseFactoryHC4 INSTANCE = new DefaultHttpResponseFactoryHC4();
-
- /** The catalog for looking up reason phrases. */
- protected final ReasonPhraseCatalog reasonCatalog;
-
-
- /**
- * Creates a new response factory with the given catalog.
- *
- * @param catalog the catalog of reason phrases
- */
- public DefaultHttpResponseFactoryHC4(final ReasonPhraseCatalog catalog) {
- this.reasonCatalog = Args.notNull(catalog, "Reason phrase catalog");
- }
-
- /**
- * Creates a new response factory with the default catalog.
- * The default catalog is {@link EnglishReasonPhraseCatalog}.
- */
- public DefaultHttpResponseFactoryHC4() {
- this(EnglishReasonPhraseCatalogHC4.INSTANCE);
- }
-
-
- // non-javadoc, see interface HttpResponseFactory
- public HttpResponse newHttpResponse(
- final ProtocolVersion ver,
- final int status,
- final HttpContext context) {
- Args.notNull(ver, "HTTP version");
- final Locale loc = determineLocale(context);
- final String reason = this.reasonCatalog.getReason(status, loc);
- final StatusLine statusline = new BasicStatusLine(ver, status, reason);
- return new BasicHttpResponse(statusline, this.reasonCatalog, loc);
- }
-
-
- // non-javadoc, see interface HttpResponseFactory
- public HttpResponse newHttpResponse(
- final StatusLine statusline,
- final HttpContext context) {
- Args.notNull(statusline, "Status line");
- return new BasicHttpResponse(statusline, this.reasonCatalog, determineLocale(context));
- }
-
- /**
- * Determines the locale of the response.
- * The implementation in this class always returns the default locale.
- *
- * @param context the context from which to determine the locale, or
- * null to use the default locale
- *
- * @return the locale for the response, never null
- */
- protected Locale determineLocale(final HttpContext context) {
- return Locale.getDefault();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/EnglishReasonPhraseCatalogHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/EnglishReasonPhraseCatalogHC4.java
deleted file mode 100644
index 091111a4..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/EnglishReasonPhraseCatalogHC4.java
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import java.util.Locale;
-
-import org.apache.http.HttpStatus;
-import org.apache.http.ReasonPhraseCatalog;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.util.Args;
-
-/**
- * English reason phrases for HTTP status codes.
- * All status codes defined in RFC1945 (HTTP/1.0), RFC2616 (HTTP/1.1), and
- * RFC2518 (WebDAV) are supported.
- *
- * @since 4.0
- */
-@Immutable
-public class EnglishReasonPhraseCatalogHC4 implements ReasonPhraseCatalog {
-
- // static array with english reason phrases defined below
-
- /**
- * The default instance of this catalog.
- * This catalog is thread safe, so there typically
- * is no need to create other instances.
- */
- public final static EnglishReasonPhraseCatalogHC4 INSTANCE =
- new EnglishReasonPhraseCatalogHC4();
-
-
- /**
- * Restricted default constructor, for derived classes.
- * If you need an instance of this class, use {@link #INSTANCE INSTANCE}.
- */
- protected EnglishReasonPhraseCatalogHC4() {
- // no body
- }
-
-
- /**
- * Obtains the reason phrase for a status code.
- *
- * @param status the status code, in the range 100-599
- * @param loc ignored
- *
- * @return the reason phrase, or null
- */
- public String getReason(final int status, final Locale loc) {
- Args.check(status >= 100 && status < 600, "Unknown category for status code " + status);
- final int category = status / 100;
- final int subcode = status - 100*category;
-
- String reason = null;
- if (REASON_PHRASES[category].length > subcode) {
- reason = REASON_PHRASES[category][subcode];
- }
-
- return reason;
- }
-
-
- /** Reason phrases lookup table. */
- private static final String[][] REASON_PHRASES = new String[][]{
- null,
- new String[3], // 1xx
- new String[8], // 2xx
- new String[8], // 3xx
- new String[25], // 4xx
- new String[8] // 5xx
- };
-
-
-
- /**
- * Stores the given reason phrase, by status code.
- * Helper method to initialize the static lookup table.
- *
- * @param status the status code for which to define the phrase
- * @param reason the reason phrase for this status code
- */
- private static void setReason(final int status, final String reason) {
- final int category = status / 100;
- final int subcode = status - 100*category;
- REASON_PHRASES[category][subcode] = reason;
- }
-
-
- // ----------------------------------------------------- Static Initializer
-
- /** Set up status code to "reason phrase" map. */
- static {
- // HTTP 1.0 Server status codes -- see RFC 1945
- setReason(HttpStatus.SC_OK,
- "OK");
- setReason(HttpStatus.SC_CREATED,
- "Created");
- setReason(HttpStatus.SC_ACCEPTED,
- "Accepted");
- setReason(HttpStatus.SC_NO_CONTENT,
- "No Content");
- setReason(HttpStatus.SC_MOVED_PERMANENTLY,
- "Moved Permanently");
- setReason(HttpStatus.SC_MOVED_TEMPORARILY,
- "Moved Temporarily");
- setReason(HttpStatus.SC_NOT_MODIFIED,
- "Not Modified");
- setReason(HttpStatus.SC_BAD_REQUEST,
- "Bad Request");
- setReason(HttpStatus.SC_UNAUTHORIZED,
- "Unauthorized");
- setReason(HttpStatus.SC_FORBIDDEN,
- "Forbidden");
- setReason(HttpStatus.SC_NOT_FOUND,
- "Not Found");
- setReason(HttpStatus.SC_INTERNAL_SERVER_ERROR,
- "Internal Server Error");
- setReason(HttpStatus.SC_NOT_IMPLEMENTED,
- "Not Implemented");
- setReason(HttpStatus.SC_BAD_GATEWAY,
- "Bad Gateway");
- setReason(HttpStatus.SC_SERVICE_UNAVAILABLE,
- "Service Unavailable");
-
- // HTTP 1.1 Server status codes -- see RFC 2048
- setReason(HttpStatus.SC_CONTINUE,
- "Continue");
- setReason(HttpStatus.SC_TEMPORARY_REDIRECT,
- "Temporary Redirect");
- setReason(HttpStatus.SC_METHOD_NOT_ALLOWED,
- "Method Not Allowed");
- setReason(HttpStatus.SC_CONFLICT,
- "Conflict");
- setReason(HttpStatus.SC_PRECONDITION_FAILED,
- "Precondition Failed");
- setReason(HttpStatus.SC_REQUEST_TOO_LONG,
- "Request Too Long");
- setReason(HttpStatus.SC_REQUEST_URI_TOO_LONG,
- "Request-URI Too Long");
- setReason(HttpStatus.SC_UNSUPPORTED_MEDIA_TYPE,
- "Unsupported Media Type");
- setReason(HttpStatus.SC_MULTIPLE_CHOICES,
- "Multiple Choices");
- setReason(HttpStatus.SC_SEE_OTHER,
- "See Other");
- setReason(HttpStatus.SC_USE_PROXY,
- "Use Proxy");
- setReason(HttpStatus.SC_PAYMENT_REQUIRED,
- "Payment Required");
- setReason(HttpStatus.SC_NOT_ACCEPTABLE,
- "Not Acceptable");
- setReason(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED,
- "Proxy Authentication Required");
- setReason(HttpStatus.SC_REQUEST_TIMEOUT,
- "Request Timeout");
-
- setReason(HttpStatus.SC_SWITCHING_PROTOCOLS,
- "Switching Protocols");
- setReason(HttpStatus.SC_NON_AUTHORITATIVE_INFORMATION,
- "Non Authoritative Information");
- setReason(HttpStatus.SC_RESET_CONTENT,
- "Reset Content");
- setReason(HttpStatus.SC_PARTIAL_CONTENT,
- "Partial Content");
- setReason(HttpStatus.SC_GATEWAY_TIMEOUT,
- "Gateway Timeout");
- setReason(HttpStatus.SC_HTTP_VERSION_NOT_SUPPORTED,
- "Http Version Not Supported");
- setReason(HttpStatus.SC_GONE,
- "Gone");
- setReason(HttpStatus.SC_LENGTH_REQUIRED,
- "Length Required");
- setReason(HttpStatus.SC_REQUESTED_RANGE_NOT_SATISFIABLE,
- "Requested Range Not Satisfiable");
- setReason(HttpStatus.SC_EXPECTATION_FAILED,
- "Expectation Failed");
-
- // WebDAV Server-specific status codes
- setReason(HttpStatus.SC_PROCESSING,
- "Processing");
- setReason(HttpStatus.SC_MULTI_STATUS,
- "Multi-Status");
- setReason(HttpStatus.SC_UNPROCESSABLE_ENTITY,
- "Unprocessable Entity");
- setReason(HttpStatus.SC_INSUFFICIENT_SPACE_ON_RESOURCE,
- "Insufficient Space On Resource");
- setReason(HttpStatus.SC_METHOD_FAILURE,
- "Method Failure");
- setReason(HttpStatus.SC_LOCKED,
- "Locked");
- setReason(HttpStatus.SC_INSUFFICIENT_STORAGE,
- "Insufficient Storage");
- setReason(HttpStatus.SC_FAILED_DEPENDENCY,
- "Failed Dependency");
- }
-
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/NoConnectionReuseStrategyHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/NoConnectionReuseStrategyHC4.java
deleted file mode 100644
index 77fbf3c2..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/NoConnectionReuseStrategyHC4.java
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl;
-
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * A strategy that never re-uses a connection.
- *
- * @since 4.0
- */
-@Immutable
-public class NoConnectionReuseStrategyHC4 implements ConnectionReuseStrategy {
-
- public static final NoConnectionReuseStrategyHC4 INSTANCE = new NoConnectionReuseStrategyHC4();
-
- public NoConnectionReuseStrategyHC4() {
- super();
- }
-
- public boolean keepAlive(final HttpResponse response, final HttpContext context) {
- return false;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/AuthSchemeBaseHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/AuthSchemeBaseHC4.java
deleted file mode 100644
index b9767206..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/AuthSchemeBaseHC4.java
+++ /dev/null
@@ -1,169 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.auth;
-
-import java.util.Locale;
-
-import org.apache.http.FormattedHeader;
-import org.apache.http.Header;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.ChallengeState;
-import org.apache.http.auth.ContextAwareAuthScheme;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.CharArrayBuffer;
-
-/**
- * Abstract authentication scheme class that serves as a basis
- * for all authentication schemes supported by HttpClient. This class
- * defines the generic way of parsing an authentication challenge. It
- * does not make any assumptions regarding the format of the challenge
- * nor does it impose any specific way of responding to that challenge.
- *
- *
- * @since 4.0
- */
-@NotThreadSafe
-public abstract class AuthSchemeBaseHC4 implements ContextAwareAuthScheme {
-
- private ChallengeState challengeState;
-
- /**
- * Creates an instance of AuthSchemeBase with the given challenge
- * state.
- *
- * @since 4.2
- *
- * @deprecated (4.3) do not use.
- */
- @Deprecated
- public AuthSchemeBaseHC4(final ChallengeState challengeState) {
- super();
- this.challengeState = challengeState;
- }
-
- public AuthSchemeBaseHC4() {
- super();
- }
-
- /**
- * Processes the given challenge token. Some authentication schemes
- * may involve multiple challenge-response exchanges. Such schemes must be able
- * to maintain the state information when dealing with sequential challenges
- *
- * @param header the challenge header
- *
- * @throws MalformedChallengeException is thrown if the authentication challenge
- * is malformed
- */
- public void processChallenge(final Header header) throws MalformedChallengeException {
- Args.notNull(header, "Header");
- final String authheader = header.getName();
- if (authheader.equalsIgnoreCase(AUTH.WWW_AUTH)) {
- this.challengeState = ChallengeState.TARGET;
- } else if (authheader.equalsIgnoreCase(AUTH.PROXY_AUTH)) {
- this.challengeState = ChallengeState.PROXY;
- } else {
- throw new MalformedChallengeException("Unexpected header name: " + authheader);
- }
-
- final CharArrayBuffer buffer;
- int pos;
- if (header instanceof FormattedHeader) {
- buffer = ((FormattedHeader) header).getBuffer();
- pos = ((FormattedHeader) header).getValuePos();
- } else {
- final String s = header.getValue();
- if (s == null) {
- throw new MalformedChallengeException("Header value is null");
- }
- buffer = new CharArrayBuffer(s.length());
- buffer.append(s);
- pos = 0;
- }
- while (pos < buffer.length() && HTTP.isWhitespace(buffer.charAt(pos))) {
- pos++;
- }
- final int beginIndex = pos;
- while (pos < buffer.length() && !HTTP.isWhitespace(buffer.charAt(pos))) {
- pos++;
- }
- final int endIndex = pos;
- final String s = buffer.substring(beginIndex, endIndex);
- if (!s.equalsIgnoreCase(getSchemeName())) {
- throw new MalformedChallengeException("Invalid scheme identifier: " + s);
- }
-
- parseChallenge(buffer, pos, buffer.length());
- }
-
-
- @SuppressWarnings("deprecation")
- public Header authenticate(
- final Credentials credentials,
- final HttpRequest request,
- final HttpContext context) throws AuthenticationException {
- return authenticate(credentials, request);
- }
-
- protected abstract void parseChallenge(
- CharArrayBuffer buffer, int beginIndex, int endIndex) throws MalformedChallengeException;
-
- /**
- * Returns true if authenticating against a proxy, false
- * otherwise.
- */
- public boolean isProxy() {
- return this.challengeState != null && this.challengeState == ChallengeState.PROXY;
- }
-
- /**
- * Returns {@link ChallengeState} value or null if unchallenged.
- *
- * @since 4.2
- */
- public ChallengeState getChallengeState() {
- return this.challengeState;
- }
-
- @Override
- public String toString() {
- final String name = getSchemeName();
- if (name != null) {
- return name.toUpperCase(Locale.ENGLISH);
- } else {
- return super.toString();
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/BasicSchemeFactoryHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/BasicSchemeFactoryHC4.java
deleted file mode 100644
index 99d6fe32..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/BasicSchemeFactoryHC4.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-import java.nio.charset.Charset;
-
-import org.apache.http.annotation.Immutable;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthSchemeFactory;
-import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * {@link AuthSchemeProvider} implementation that creates and initializes
- * {@link BasicScheme} instances.
- *
- * @since 4.0
- */
-@Immutable
-@SuppressWarnings("deprecation")
-public class BasicSchemeFactoryHC4 implements AuthSchemeFactory, AuthSchemeProvider {
-
- private final Charset charset;
-
- /**
- * @since 4.3
- */
- public BasicSchemeFactoryHC4(final Charset charset) {
- super();
- this.charset = charset;
- }
-
- public BasicSchemeFactoryHC4() {
- this(null);
- }
-
- public AuthScheme newInstance(final HttpParams params) {
- return new BasicSchemeHC4();
- }
-
- public AuthScheme create(final HttpContext context) {
- return new BasicSchemeHC4(this.charset);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/BasicSchemeHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/BasicSchemeHC4.java
deleted file mode 100644
index 8059b972..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/BasicSchemeHC4.java
+++ /dev/null
@@ -1,218 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.auth;
-
-import java.nio.charset.Charset;
-
-import android.util.Base64;
-import org.apache.http.Consts;
-import org.apache.http.Header;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.ChallengeState;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.message.BufferedHeader;
-import org.apache.http.protocol.BasicHttpContextHC4;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.CharArrayBuffer;
-import org.apache.http.util.EncodingUtils;
-
-/**
- * Basic authentication scheme as defined in RFC 2617.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class BasicSchemeHC4 extends RFC2617SchemeHC4 {
-
- /** Whether the basic authentication process is complete */
- private boolean complete;
-
- /**
- * @since 4.3
- */
- public BasicSchemeHC4(final Charset credentialsCharset) {
- super(credentialsCharset);
- this.complete = false;
- }
-
- /**
- * Creates an instance of BasicScheme with the given challenge
- * state.
- *
- * @since 4.2
- *
- * @deprecated (4.3) do not use.
- */
- @Deprecated
- public BasicSchemeHC4(final ChallengeState challengeState) {
- super(challengeState);
- }
-
- public BasicSchemeHC4() {
- this(Consts.ASCII);
- }
-
- /**
- * Returns textual designation of the basic authentication scheme.
- *
- * @return basic
- */
- public String getSchemeName() {
- return "basic";
- }
-
- /**
- * Processes the Basic challenge.
- *
- * @param header the challenge header
- *
- * @throws MalformedChallengeException is thrown if the authentication challenge
- * is malformed
- */
- @Override
- public void processChallenge(
- final Header header) throws MalformedChallengeException {
- super.processChallenge(header);
- this.complete = true;
- }
-
- /**
- * Tests if the Basic authentication process has been completed.
- *
- * @return true if Basic authorization has been processed,
- * false otherwise.
- */
- public boolean isComplete() {
- return this.complete;
- }
-
- /**
- * Returns false. Basic authentication scheme is request based.
- *
- * @return false.
- */
- public boolean isConnectionBased() {
- return false;
- }
-
- /**
- * @deprecated (4.2) Use {@link org.apache.http.auth.ContextAwareAuthScheme#authenticate(
- * Credentials, HttpRequest, org.apache.http.protocol.HttpContext)}
- */
- @Deprecated
- public Header authenticate(
- final Credentials credentials, final HttpRequest request) throws AuthenticationException {
- return authenticate(credentials, request, new BasicHttpContextHC4());
- }
-
- /**
- * Produces basic authorization header for the given set of {@link Credentials}.
- *
- * @param credentials The set of credentials to be used for authentication
- * @param request The request being authenticated
- * @throws org.apache.http.auth.InvalidCredentialsException if authentication
- * credentials are not valid or not applicable for this authentication scheme
- * @throws AuthenticationException if authorization string cannot
- * be generated due to an authentication failure
- *
- * @return a basic authorization string
- */
- @Override
- public Header authenticate(
- final Credentials credentials,
- final HttpRequest request,
- final HttpContext context) throws AuthenticationException {
-
- Args.notNull(credentials, "Credentials");
- Args.notNull(request, "HTTP request");
- final StringBuilder tmp = new StringBuilder();
- tmp.append(credentials.getUserPrincipal().getName());
- tmp.append(":");
- tmp.append((credentials.getPassword() == null) ? "null" : credentials.getPassword());
-
- final byte[] base64password = Base64.encode(
- EncodingUtils.getBytes(tmp.toString(), getCredentialsCharset(request)),
- Base64.NO_WRAP);
-
- final CharArrayBuffer buffer = new CharArrayBuffer(32);
- if (isProxy()) {
- buffer.append(AUTH.PROXY_AUTH_RESP);
- } else {
- buffer.append(AUTH.WWW_AUTH_RESP);
- }
- buffer.append(": Basic ");
- buffer.append(base64password, 0, base64password.length);
-
- return new BufferedHeader(buffer);
- }
-
- /**
- * Returns a basic Authorization header value for the given
- * {@link Credentials} and charset.
- *
- * @param credentials The credentials to encode.
- * @param charset The charset to use for encoding the credentials
- *
- * @return a basic authorization header
- *
- * @deprecated (4.3) use {@link #authenticate(Credentials, HttpRequest, HttpContext)}.
- */
- @Deprecated
- public static Header authenticate(
- final Credentials credentials,
- final String charset,
- final boolean proxy) {
- Args.notNull(credentials, "Credentials");
- Args.notNull(charset, "charset");
-
- final StringBuilder tmp = new StringBuilder();
- tmp.append(credentials.getUserPrincipal().getName());
- tmp.append(":");
- tmp.append((credentials.getPassword() == null) ? "null" : credentials.getPassword());
-
- final byte[] base64password = Base64.encode(
- EncodingUtils.getBytes(tmp.toString(), charset),
- Base64.NO_WRAP);
-
- final CharArrayBuffer buffer = new CharArrayBuffer(32);
- if (proxy) {
- buffer.append(AUTH.PROXY_AUTH_RESP);
- } else {
- buffer.append(AUTH.WWW_AUTH_RESP);
- }
- buffer.append(": Basic ");
- buffer.append(base64password, 0, base64password.length);
-
- return new BufferedHeader(buffer);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/DigestSchemeFactoryHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/DigestSchemeFactoryHC4.java
deleted file mode 100644
index 564d8dfc..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/DigestSchemeFactoryHC4.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-import java.nio.charset.Charset;
-
-import org.apache.http.annotation.Immutable;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthSchemeFactory;
-import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * {@link AuthSchemeProvider} implementation that creates and initializes
- * {@link DigestScheme} instances.
- *
- * @since 4.0
- */
-@Immutable
-@SuppressWarnings("deprecation")
-public class DigestSchemeFactoryHC4 implements AuthSchemeFactory, AuthSchemeProvider {
-
- private final Charset charset;
-
- /**
- * @since 4.3
- */
- public DigestSchemeFactoryHC4(final Charset charset) {
- super();
- this.charset = charset;
- }
-
- public DigestSchemeFactoryHC4() {
- this(null);
- }
-
- public AuthScheme newInstance(final HttpParams params) {
- return new DigestSchemeHC4();
- }
-
- public AuthScheme create(final HttpContext context) {
- return new DigestSchemeHC4(this.charset);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/DigestSchemeHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/DigestSchemeHC4.java
deleted file mode 100644
index cfd3a56c..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/DigestSchemeHC4.java
+++ /dev/null
@@ -1,489 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.auth;
-
-import java.io.IOException;
-import java.nio.charset.Charset;
-import java.security.MessageDigest;
-import java.security.SecureRandom;
-import java.util.ArrayList;
-import java.util.Formatter;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Locale;
-import java.util.Set;
-import java.util.StringTokenizer;
-
-import org.apache.http.Consts;
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.ChallengeState;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.message.BasicHeaderValueFormatterHC4;
-import org.apache.http.message.BasicNameValuePair;
-import org.apache.http.message.BufferedHeader;
-import org.apache.http.protocol.BasicHttpContextHC4;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.CharArrayBuffer;
-import org.apache.http.util.EncodingUtils;
-
-/**
- * Digest authentication scheme as defined in RFC 2617.
- * Both MD5 (default) and MD5-sess are supported.
- * Currently only qop=auth or no qop is supported. qop=auth-int
- * is unsupported. If auth and auth-int are provided, auth is
- * used.
- *
- * Since the digest username is included as clear text in the generated
- * Authentication header, the charset of the username must be compatible
- * with the HTTP element charset used by the connection.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class DigestSchemeHC4 extends RFC2617SchemeHC4 {
-
- /**
- * Hexa values used when creating 32 character long digest in HTTP DigestSchemeHC4
- * in case of authentication.
- *
- * @see #encode(byte[])
- */
- private static final char[] HEXADECIMAL = {
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd',
- 'e', 'f'
- };
-
- /** Whether the digest authentication process is complete */
- private boolean complete;
-
- private static final int QOP_UNKNOWN = -1;
- private static final int QOP_MISSING = 0;
- private static final int QOP_AUTH_INT = 1;
- private static final int QOP_AUTH = 2;
-
- private String lastNonce;
- private long nounceCount;
- private String cnonce;
- private String a1;
- private String a2;
-
- /**
- * @since 4.3
- */
- public DigestSchemeHC4(final Charset credentialsCharset) {
- super(credentialsCharset);
- this.complete = false;
- }
-
- /**
- * Creates an instance of DigestScheme with the given challenge
- * state.
- *
- * @since 4.2
- *
- * @deprecated (4.3) do not use.
- */
- @Deprecated
- public DigestSchemeHC4(final ChallengeState challengeState) {
- super(challengeState);
- }
-
- public DigestSchemeHC4() {
- this(Consts.ASCII);
- }
-
- /**
- * Processes the Digest challenge.
- *
- * @param header the challenge header
- *
- * @throws MalformedChallengeException is thrown if the authentication challenge
- * is malformed
- */
- @Override
- public void processChallenge(
- final Header header) throws MalformedChallengeException {
- super.processChallenge(header);
- this.complete = true;
- }
-
- /**
- * Tests if the Digest authentication process has been completed.
- *
- * @return true if Digest authorization has been processed,
- * false otherwise.
- */
- public boolean isComplete() {
- final String s = getParameter("stale");
- if ("true".equalsIgnoreCase(s)) {
- return false;
- } else {
- return this.complete;
- }
- }
-
- /**
- * Returns textual designation of the digest authentication scheme.
- *
- * @return digest
- */
- public String getSchemeName() {
- return "digest";
- }
-
- /**
- * Returns false. Digest authentication scheme is request based.
- *
- * @return false.
- */
- public boolean isConnectionBased() {
- return false;
- }
-
- public void overrideParamter(final String name, final String value) {
- getParameters().put(name, value);
- }
-
- /**
- * @deprecated (4.2) Use {@link org.apache.http.auth.ContextAwareAuthScheme#authenticate(
- * Credentials, HttpRequest, org.apache.http.protocol.HttpContext)}
- */
- @Deprecated
- public Header authenticate(
- final Credentials credentials, final HttpRequest request) throws AuthenticationException {
- return authenticate(credentials, request, new BasicHttpContextHC4());
- }
-
- /**
- * Produces a digest authorization string for the given set of
- * {@link Credentials}, method name and URI.
- *
- * @param credentials A set of credentials to be used for athentication
- * @param request The request being authenticated
- *
- * @throws org.apache.http.auth.InvalidCredentialsException if authentication credentials
- * are not valid or not applicable for this authentication scheme
- * @throws AuthenticationException if authorization string cannot
- * be generated due to an authentication failure
- *
- * @return a digest authorization string
- */
- @Override
- public Header authenticate(
- final Credentials credentials,
- final HttpRequest request,
- final HttpContext context) throws AuthenticationException {
-
- Args.notNull(credentials, "Credentials");
- Args.notNull(request, "HTTP request");
- if (getParameter("realm") == null) {
- throw new AuthenticationException("missing realm in challenge");
- }
- if (getParameter("nonce") == null) {
- throw new AuthenticationException("missing nonce in challenge");
- }
- // Add method name and request-URI to the parameter map
- getParameters().put("methodname", request.getRequestLine().getMethod());
- getParameters().put("uri", request.getRequestLine().getUri());
- final String charset = getParameter("charset");
- if (charset == null) {
- getParameters().put("charset", getCredentialsCharset(request));
- }
- return createDigestHeader(credentials, request);
- }
-
- private static MessageDigest createMessageDigest(
- final String digAlg) throws UnsupportedDigestAlgorithmException {
- try {
- return MessageDigest.getInstance(digAlg);
- } catch (final Exception e) {
- throw new UnsupportedDigestAlgorithmException(
- "Unsupported algorithm in HTTP Digest authentication: "
- + digAlg);
- }
- }
-
- /**
- * Creates digest-response header as defined in RFC2617.
- *
- * @param credentials User credentials
- *
- * @return The digest-response as String.
- */
- private Header createDigestHeader(
- final Credentials credentials,
- final HttpRequest request) throws AuthenticationException {
- final String uri = getParameter("uri");
- final String realm = getParameter("realm");
- final String nonce = getParameter("nonce");
- final String opaque = getParameter("opaque");
- final String method = getParameter("methodname");
- String algorithm = getParameter("algorithm");
- // If an algorithm is not specified, default to MD5.
- if (algorithm == null) {
- algorithm = "MD5";
- }
-
- final Set qopset = new HashSet(8);
- int qop = QOP_UNKNOWN;
- final String qoplist = getParameter("qop");
- if (qoplist != null) {
- final StringTokenizer tok = new StringTokenizer(qoplist, ",");
- while (tok.hasMoreTokens()) {
- final String variant = tok.nextToken().trim();
- qopset.add(variant.toLowerCase(Locale.ENGLISH));
- }
- if (request instanceof HttpEntityEnclosingRequest && qopset.contains("auth-int")) {
- qop = QOP_AUTH_INT;
- } else if (qopset.contains("auth")) {
- qop = QOP_AUTH;
- }
- } else {
- qop = QOP_MISSING;
- }
-
- if (qop == QOP_UNKNOWN) {
- throw new AuthenticationException("None of the qop methods is supported: " + qoplist);
- }
-
- String charset = getParameter("charset");
- if (charset == null) {
- charset = "ISO-8859-1";
- }
-
- String digAlg = algorithm;
- if (digAlg.equalsIgnoreCase("MD5-sess")) {
- digAlg = "MD5";
- }
-
- final MessageDigest digester;
- try {
- digester = createMessageDigest(digAlg);
- } catch (final UnsupportedDigestAlgorithmException ex) {
- throw new AuthenticationException("Unsuppported digest algorithm: " + digAlg);
- }
-
- final String uname = credentials.getUserPrincipal().getName();
- final String pwd = credentials.getPassword();
-
- if (nonce.equals(this.lastNonce)) {
- nounceCount++;
- } else {
- nounceCount = 1;
- cnonce = null;
- lastNonce = nonce;
- }
- final StringBuilder sb = new StringBuilder(256);
- final Formatter formatter = new Formatter(sb, Locale.US);
- formatter.format("%08x", nounceCount);
- formatter.close();
- final String nc = sb.toString();
-
- if (cnonce == null) {
- cnonce = createCnonce();
- }
-
- a1 = null;
- a2 = null;
- // 3.2.2.2: Calculating digest
- if (algorithm.equalsIgnoreCase("MD5-sess")) {
- // H( unq(username-value) ":" unq(realm-value) ":" passwd )
- // ":" unq(nonce-value)
- // ":" unq(cnonce-value)
-
- // calculated one per session
- sb.setLength(0);
- sb.append(uname).append(':').append(realm).append(':').append(pwd);
- final String checksum = encode(digester.digest(EncodingUtils.getBytes(sb.toString(), charset)));
- sb.setLength(0);
- sb.append(checksum).append(':').append(nonce).append(':').append(cnonce);
- a1 = sb.toString();
- } else {
- // unq(username-value) ":" unq(realm-value) ":" passwd
- sb.setLength(0);
- sb.append(uname).append(':').append(realm).append(':').append(pwd);
- a1 = sb.toString();
- }
-
- final String hasha1 = encode(digester.digest(EncodingUtils.getBytes(a1, charset)));
-
- if (qop == QOP_AUTH) {
- // Method ":" digest-uri-value
- a2 = method + ':' + uri;
- } else if (qop == QOP_AUTH_INT) {
- // Method ":" digest-uri-value ":" H(entity-body)
- HttpEntity entity = null;
- if (request instanceof HttpEntityEnclosingRequest) {
- entity = ((HttpEntityEnclosingRequest) request).getEntity();
- }
- if (entity != null && !entity.isRepeatable()) {
- // If the entity is not repeatable, try falling back onto QOP_AUTH
- if (qopset.contains("auth")) {
- qop = QOP_AUTH;
- a2 = method + ':' + uri;
- } else {
- throw new AuthenticationException("Qop auth-int cannot be used with " +
- "a non-repeatable entity");
- }
- } else {
- final HttpEntityDigester entityDigester = new HttpEntityDigester(digester);
- try {
- if (entity != null) {
- entity.writeTo(entityDigester);
- }
- entityDigester.close();
- } catch (final IOException ex) {
- throw new AuthenticationException("I/O error reading entity content", ex);
- }
- a2 = method + ':' + uri + ':' + encode(entityDigester.getDigest());
- }
- } else {
- a2 = method + ':' + uri;
- }
-
- final String hasha2 = encode(digester.digest(EncodingUtils.getBytes(a2, charset)));
-
- // 3.2.2.1
-
- final String digestValue;
- if (qop == QOP_MISSING) {
- sb.setLength(0);
- sb.append(hasha1).append(':').append(nonce).append(':').append(hasha2);
- digestValue = sb.toString();
- } else {
- sb.setLength(0);
- sb.append(hasha1).append(':').append(nonce).append(':').append(nc).append(':')
- .append(cnonce).append(':').append(qop == QOP_AUTH_INT ? "auth-int" : "auth")
- .append(':').append(hasha2);
- digestValue = sb.toString();
- }
-
- final String digest = encode(digester.digest(EncodingUtils.getAsciiBytes(digestValue)));
-
- final CharArrayBuffer buffer = new CharArrayBuffer(128);
- if (isProxy()) {
- buffer.append(AUTH.PROXY_AUTH_RESP);
- } else {
- buffer.append(AUTH.WWW_AUTH_RESP);
- }
- buffer.append(": Digest ");
-
- final List params = new ArrayList(20);
- params.add(new BasicNameValuePair("username", uname));
- params.add(new BasicNameValuePair("realm", realm));
- params.add(new BasicNameValuePair("nonce", nonce));
- params.add(new BasicNameValuePair("uri", uri));
- params.add(new BasicNameValuePair("response", digest));
-
- if (qop != QOP_MISSING) {
- params.add(new BasicNameValuePair("qop", qop == QOP_AUTH_INT ? "auth-int" : "auth"));
- params.add(new BasicNameValuePair("nc", nc));
- params.add(new BasicNameValuePair("cnonce", cnonce));
- }
- // algorithm cannot be null here
- params.add(new BasicNameValuePair("algorithm", algorithm));
- if (opaque != null) {
- params.add(new BasicNameValuePair("opaque", opaque));
- }
-
- for (int i = 0; i < params.size(); i++) {
- final BasicNameValuePair param = params.get(i);
- if (i > 0) {
- buffer.append(", ");
- }
- final String name = param.getName();
- final boolean noQuotes = ("nc".equals(name) || "qop".equals(name)
- || "algorithm".equals(name));
- BasicHeaderValueFormatterHC4.INSTANCE.formatNameValuePair(buffer, param, !noQuotes);
- }
- return new BufferedHeader(buffer);
- }
-
- String getCnonce() {
- return cnonce;
- }
-
- String getA1() {
- return a1;
- }
-
- String getA2() {
- return a2;
- }
-
- /**
- * Encodes the 128 bit (16 bytes) MD5 digest into a 32 characters long
- * String according to RFC 2617.
- *
- * @param binaryData array containing the digest
- * @return encoded MD5, or null if encoding failed
- */
- static String encode(final byte[] binaryData) {
- final int n = binaryData.length;
- final char[] buffer = new char[n * 2];
- for (int i = 0; i < n; i++) {
- final int low = (binaryData[i] & 0x0f);
- final int high = ((binaryData[i] & 0xf0) >> 4);
- buffer[i * 2] = HEXADECIMAL[high];
- buffer[(i * 2) + 1] = HEXADECIMAL[low];
- }
-
- return new String(buffer);
- }
-
-
- /**
- * Creates a random cnonce value based on the current time.
- *
- * @return The cnonce value as String.
- */
- public static String createCnonce() {
- final SecureRandom rnd = new SecureRandom();
- final byte[] tmp = new byte[8];
- rnd.nextBytes(tmp);
- return encode(tmp);
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("DIGEST [complete=").append(complete)
- .append(", nonce=").append(lastNonce)
- .append(", nc=").append(nounceCount)
- .append("]");
- return builder.toString();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
deleted file mode 100644
index 0744c7de..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/HttpAuthenticator.java
+++ /dev/null
@@ -1,252 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-import java.io.IOException;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Queue;
-
-import android.util.Log;
-
-import org.apache.http.Header;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.auth.AuthOption;
-import org.apache.http.auth.AuthProtocolState;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthStateHC4;
-import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.ContextAwareAuthScheme;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.client.AuthenticationStrategy;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Asserts;
-
-/**
- * @since 4.3
- */
-public class HttpAuthenticator {
-
- private final static String TAG = "HttpClient";
-
- public HttpAuthenticator() {
- super();
- }
-
- public boolean isAuthenticationRequested(
- final HttpHost host,
- final HttpResponse response,
- final AuthenticationStrategy authStrategy,
- final AuthStateHC4 authState,
- final HttpContext context) {
- if (authStrategy.isAuthenticationRequested(host, response, context)) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Authentication required");
- }
- if (authState.getState() == AuthProtocolState.SUCCESS) {
- authStrategy.authFailed(host, authState.getAuthScheme(), context);
- }
- return true;
- } else {
- switch (authState.getState()) {
- case CHALLENGED:
- case HANDSHAKE:
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Authentication succeeded");
- }
- authState.setState(AuthProtocolState.SUCCESS);
- authStrategy.authSucceeded(host, authState.getAuthScheme(), context);
- break;
- case SUCCESS:
- break;
- default:
- authState.setState(AuthProtocolState.UNCHALLENGED);
- }
- return false;
- }
- }
-
- public boolean handleAuthChallenge(
- final HttpHost host,
- final HttpResponse response,
- final AuthenticationStrategy authStrategy,
- final AuthStateHC4 authState,
- final HttpContext context) {
- try {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, host.toHostString() + " requested authentication");
- }
- final Map challenges = authStrategy.getChallenges(host, response, context);
- if (challenges.isEmpty()) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Response contains no authentication challenges");
- }
- return false;
- }
-
- final AuthScheme authScheme = authState.getAuthScheme();
- switch (authState.getState()) {
- case FAILURE:
- return false;
- case SUCCESS:
- authState.reset();
- break;
- case CHALLENGED:
- case HANDSHAKE:
- if (authScheme == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Auth scheme is null");
- }
- authStrategy.authFailed(host, null, context);
- authState.reset();
- authState.setState(AuthProtocolState.FAILURE);
- return false;
- }
- case UNCHALLENGED:
- if (authScheme != null) {
- final String id = authScheme.getSchemeName();
- final Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
- if (challenge != null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Authorization challenge processed");
- }
- authScheme.processChallenge(challenge);
- if (authScheme.isComplete()) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Authentication failed");
- }
- authStrategy.authFailed(host, authState.getAuthScheme(), context);
- authState.reset();
- authState.setState(AuthProtocolState.FAILURE);
- return false;
- } else {
- authState.setState(AuthProtocolState.HANDSHAKE);
- return true;
- }
- } else {
- authState.reset();
- // Retry authentication with a different scheme
- }
- }
- }
- final Queue authOptions = authStrategy.select(challenges, host, response, context);
- if (authOptions != null && !authOptions.isEmpty()) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Selected authentication options: " + authOptions);
- }
- authState.setState(AuthProtocolState.CHALLENGED);
- authState.update(authOptions);
- return true;
- } else {
- return false;
- }
- } catch (final MalformedChallengeException ex) {
- if (Log.isLoggable(TAG, Log.WARN)) {
- Log.w(TAG, "Malformed challenge: " + ex.getMessage());
- }
- authState.reset();
- return false;
- }
- }
-
- public void generateAuthResponse(
- final HttpRequest request,
- final AuthStateHC4 authState,
- final HttpContext context) throws HttpException, IOException {
- AuthScheme authScheme = authState.getAuthScheme();
- Credentials creds = authState.getCredentials();
- switch (authState.getState()) {
- case FAILURE:
- return;
- case SUCCESS:
- ensureAuthScheme(authScheme);
- if (authScheme.isConnectionBased()) {
- return;
- }
- break;
- case CHALLENGED:
- final Queue authOptions = authState.getAuthOptions();
- if (authOptions != null) {
- while (!authOptions.isEmpty()) {
- final AuthOption authOption = authOptions.remove();
- authScheme = authOption.getAuthScheme();
- creds = authOption.getCredentials();
- authState.update(authScheme, creds);
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Generating response to an authentication challenge using "
- + authScheme.getSchemeName() + " scheme");
- }
- try {
- final Header header = doAuth(authScheme, creds, request, context);
- request.addHeader(header);
- break;
- } catch (final AuthenticationException ex) {
- if (Log.isLoggable(TAG, Log.WARN)) {
- Log.w(TAG, authScheme + " authentication error: " + ex.getMessage());
- }
- }
- }
- return;
- } else {
- ensureAuthScheme(authScheme);
- }
- }
- if (authScheme != null) {
- try {
- final Header header = doAuth(authScheme, creds, request, context);
- request.addHeader(header);
- } catch (final AuthenticationException ex) {
- if (Log.isLoggable(TAG, Log.ERROR)) {
- Log.e(TAG, authScheme + " authentication error: " + ex.getMessage());
- }
- }
- }
- }
-
- private void ensureAuthScheme(final AuthScheme authScheme) {
- Asserts.notNull(authScheme, "Auth scheme");
- }
-
- @SuppressWarnings("deprecation")
- private Header doAuth(
- final AuthScheme authScheme,
- final Credentials creds,
- final HttpRequest request,
- final HttpContext context) throws AuthenticationException {
- if (authScheme instanceof ContextAwareAuthScheme) {
- return ((ContextAwareAuthScheme) authScheme).authenticate(creds, request, context);
- } else {
- return authScheme.authenticate(creds, request);
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/HttpEntityDigester.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/HttpEntityDigester.java
deleted file mode 100644
index 08bc2e67..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/HttpEntityDigester.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.auth;
-
-import java.io.IOException;
-import java.io.OutputStream;
-import java.security.MessageDigest;
-
-class HttpEntityDigester extends OutputStream {
-
- private final MessageDigest digester;
- private boolean closed;
- private byte[] digest;
-
- HttpEntityDigester(final MessageDigest digester) {
- super();
- this.digester = digester;
- this.digester.reset();
- }
-
- @Override
- public void write(final int b) throws IOException {
- if (this.closed) {
- throw new IOException("Stream has been already closed");
- }
- this.digester.update((byte) b);
- }
-
- @Override
- public void write(final byte[] b, final int off, final int len) throws IOException {
- if (this.closed) {
- throw new IOException("Stream has been already closed");
- }
- this.digester.update(b, off, len);
- }
-
- @Override
- public void close() throws IOException {
- if (this.closed) {
- return;
- }
- this.closed = true;
- this.digest = this.digester.digest();
- super.close();
- }
-
- public byte[] getDigest() {
- return this.digest;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
deleted file mode 100644
index 58f0252b..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/NTLMEngineImpl.java
+++ /dev/null
@@ -1,1671 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.auth;
-
-import java.io.UnsupportedEncodingException;
-import java.security.Key;
-import java.security.MessageDigest;
-import java.util.Arrays;
-import java.util.Locale;
-
-import javax.crypto.Cipher;
-import javax.crypto.spec.SecretKeySpec;
-
-import android.util.Base64;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.util.EncodingUtils;
-
-/**
- * Provides an implementation for NTLMv1, NTLMv2, and NTLM2 Session forms of the NTLM
- * authentication protocol.
- *
- * @since 4.1
- */
-@NotThreadSafe
-final class NTLMEngineImpl implements NTLMEngine {
-
- // Flags we use; descriptions according to:
- // http://davenport.sourceforge.net/ntlm.html
- // and
- // http://msdn.microsoft.com/en-us/library/cc236650%28v=prot.20%29.aspx
- protected static final int FLAG_REQUEST_UNICODE_ENCODING = 0x00000001; // Unicode string encoding requested
- protected static final int FLAG_REQUEST_TARGET = 0x00000004; // Requests target field
- protected static final int FLAG_REQUEST_SIGN = 0x00000010; // Requests all messages have a signature attached, in NEGOTIATE message.
- protected static final int FLAG_REQUEST_SEAL = 0x00000020; // Request key exchange for message confidentiality in NEGOTIATE message. MUST be used in conjunction with 56BIT.
- protected static final int FLAG_REQUEST_LAN_MANAGER_KEY = 0x00000080; // Request Lan Manager key instead of user session key
- protected static final int FLAG_REQUEST_NTLMv1 = 0x00000200; // Request NTLMv1 security. MUST be set in NEGOTIATE and CHALLENGE both
- protected static final int FLAG_DOMAIN_PRESENT = 0x00001000; // Domain is present in message
- protected static final int FLAG_WORKSTATION_PRESENT = 0x00002000; // Workstation is present in message
- protected static final int FLAG_REQUEST_ALWAYS_SIGN = 0x00008000; // Requests a signature block on all messages. Overridden by REQUEST_SIGN and REQUEST_SEAL.
- protected static final int FLAG_REQUEST_NTLM2_SESSION = 0x00080000; // From server in challenge, requesting NTLM2 session security
- protected static final int FLAG_REQUEST_VERSION = 0x02000000; // Request protocol version
- protected static final int FLAG_TARGETINFO_PRESENT = 0x00800000; // From server in challenge message, indicating targetinfo is present
- protected static final int FLAG_REQUEST_128BIT_KEY_EXCH = 0x20000000; // Request explicit 128-bit key exchange
- protected static final int FLAG_REQUEST_EXPLICIT_KEY_EXCH = 0x40000000; // Request explicit key exchange
- protected static final int FLAG_REQUEST_56BIT_ENCRYPTION = 0x80000000; // Must be used in conjunction with SEAL
-
-
- /** Secure random generator */
- private static final java.security.SecureRandom RND_GEN;
- static {
- java.security.SecureRandom rnd = null;
- try {
- rnd = java.security.SecureRandom.getInstance("SHA1PRNG");
- } catch (final Exception ignore) {
- }
- RND_GEN = rnd;
- }
-
- /** Character encoding */
- static final String DEFAULT_CHARSET = "ASCII";
-
- /** The character set to use for encoding the credentials */
- private String credentialCharset = DEFAULT_CHARSET;
-
- /** The signature string as bytes in the default encoding */
- private static final byte[] SIGNATURE;
-
- static {
- final byte[] bytesWithoutNull = EncodingUtils.getBytes("NTLMSSP", "ASCII");
- SIGNATURE = new byte[bytesWithoutNull.length + 1];
- System.arraycopy(bytesWithoutNull, 0, SIGNATURE, 0, bytesWithoutNull.length);
- SIGNATURE[bytesWithoutNull.length] = (byte) 0x00;
- }
-
- /**
- * Returns the response for the given message.
- *
- * @param message
- * the message that was received from the server.
- * @param username
- * the username to authenticate with.
- * @param password
- * the password to authenticate with.
- * @param host
- * The host.
- * @param domain
- * the NT domain to authenticate in.
- * @return The response.
- * @throws org.apache.http.HttpException
- * If the messages cannot be retrieved.
- */
- final String getResponseFor(final String message, final String username, final String password,
- final String host, final String domain) throws NTLMEngineException {
-
- final String response;
- if (message == null || message.trim().equals("")) {
- response = getType1Message(host, domain);
- } else {
- final Type2Message t2m = new Type2Message(message);
- response = getType3Message(username, password, host, domain, t2m.getChallenge(), t2m
- .getFlags(), t2m.getTarget(), t2m.getTargetInfo());
- }
- return response;
- }
-
- /**
- * Creates the first message (type 1 message) in the NTLM authentication
- * sequence. This message includes the user name, domain and host for the
- * authentication session.
- *
- * @param host
- * the computer name of the host requesting authentication.
- * @param domain
- * The domain to authenticate with.
- * @return String the message to add to the HTTP request header.
- */
- String getType1Message(final String host, final String domain) throws NTLMEngineException {
- return new Type1Message(domain, host).getResponse();
- }
-
- /**
- * Creates the type 3 message using the given server nonce. The type 3
- * message includes all the information for authentication, host, domain,
- * username and the result of encrypting the nonce sent by the server using
- * the user's password as the key.
- *
- * @param user
- * The user name. This should not include the domain name.
- * @param password
- * The password.
- * @param host
- * The host that is originating the authentication request.
- * @param domain
- * The domain to authenticate within.
- * @param nonce
- * the 8 byte array the server sent.
- * @return The type 3 message.
- * @throws NTLMEngineException
- * If {@link #RC4(byte[],byte[])} fails.
- */
- String getType3Message(final String user, final String password, final String host, final String domain,
- final byte[] nonce, final int type2Flags, final String target, final byte[] targetInformation)
- throws NTLMEngineException {
- return new Type3Message(domain, host, user, password, nonce, type2Flags, target,
- targetInformation).getResponse();
- }
-
- /**
- * @return Returns the credentialCharset.
- */
- String getCredentialCharset() {
- return credentialCharset;
- }
-
- /**
- * @param credentialCharset
- * The credentialCharset to set.
- */
- void setCredentialCharset(final String credentialCharset) {
- this.credentialCharset = credentialCharset;
- }
-
- /** Strip dot suffix from a name */
- private static String stripDotSuffix(final String value) {
- if (value == null) {
- return null;
- }
- final int index = value.indexOf(".");
- if (index != -1) {
- return value.substring(0, index);
- }
- return value;
- }
-
- /** Convert host to standard form */
- private static String convertHost(final String host) {
- return stripDotSuffix(host);
- }
-
- /** Convert domain to standard form */
- private static String convertDomain(final String domain) {
- return stripDotSuffix(domain);
- }
-
- private static int readULong(final byte[] src, final int index) throws NTLMEngineException {
- if (src.length < index + 4) {
- throw new NTLMEngineException("NTLM authentication - buffer too small for DWORD");
- }
- return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8)
- | ((src[index + 2] & 0xff) << 16) | ((src[index + 3] & 0xff) << 24);
- }
-
- private static int readUShort(final byte[] src, final int index) throws NTLMEngineException {
- if (src.length < index + 2) {
- throw new NTLMEngineException("NTLM authentication - buffer too small for WORD");
- }
- return (src[index] & 0xff) | ((src[index + 1] & 0xff) << 8);
- }
-
- private static byte[] readSecurityBuffer(final byte[] src, final int index) throws NTLMEngineException {
- final int length = readUShort(src, index);
- final int offset = readULong(src, index + 4);
- if (src.length < offset + length) {
- throw new NTLMEngineException(
- "NTLM authentication - buffer too small for data item");
- }
- final byte[] buffer = new byte[length];
- System.arraycopy(src, offset, buffer, 0, length);
- return buffer;
- }
-
- /** Calculate a challenge block */
- private static byte[] makeRandomChallenge() throws NTLMEngineException {
- if (RND_GEN == null) {
- throw new NTLMEngineException("Random generator not available");
- }
- final byte[] rval = new byte[8];
- synchronized (RND_GEN) {
- RND_GEN.nextBytes(rval);
- }
- return rval;
- }
-
- /** Calculate a 16-byte secondary key */
- private static byte[] makeSecondaryKey() throws NTLMEngineException {
- if (RND_GEN == null) {
- throw new NTLMEngineException("Random generator not available");
- }
- final byte[] rval = new byte[16];
- synchronized (RND_GEN) {
- RND_GEN.nextBytes(rval);
- }
- return rval;
- }
-
- protected static class CipherGen {
-
- protected final String domain;
- protected final String user;
- protected final String password;
- protected final byte[] challenge;
- protected final String target;
- protected final byte[] targetInformation;
-
- // Information we can generate but may be passed in (for testing)
- protected byte[] clientChallenge;
- protected byte[] clientChallenge2;
- protected byte[] secondaryKey;
- protected byte[] timestamp;
-
- // Stuff we always generate
- protected byte[] lmHash = null;
- protected byte[] lmResponse = null;
- protected byte[] ntlmHash = null;
- protected byte[] ntlmResponse = null;
- protected byte[] ntlmv2Hash = null;
- protected byte[] lmv2Hash = null;
- protected byte[] lmv2Response = null;
- protected byte[] ntlmv2Blob = null;
- protected byte[] ntlmv2Response = null;
- protected byte[] ntlm2SessionResponse = null;
- protected byte[] lm2SessionResponse = null;
- protected byte[] lmUserSessionKey = null;
- protected byte[] ntlmUserSessionKey = null;
- protected byte[] ntlmv2UserSessionKey = null;
- protected byte[] ntlm2SessionResponseUserSessionKey = null;
- protected byte[] lanManagerSessionKey = null;
-
- public CipherGen(final String domain, final String user, final String password,
- final byte[] challenge, final String target, final byte[] targetInformation,
- final byte[] clientChallenge, final byte[] clientChallenge2,
- final byte[] secondaryKey, final byte[] timestamp) {
- this.domain = domain;
- this.target = target;
- this.user = user;
- this.password = password;
- this.challenge = challenge;
- this.targetInformation = targetInformation;
- this.clientChallenge = clientChallenge;
- this.clientChallenge2 = clientChallenge2;
- this.secondaryKey = secondaryKey;
- this.timestamp = timestamp;
- }
-
- public CipherGen(final String domain, final String user, final String password,
- final byte[] challenge, final String target, final byte[] targetInformation) {
- this(domain, user, password, challenge, target, targetInformation, null, null, null, null);
- }
-
- /** Calculate and return client challenge */
- public byte[] getClientChallenge()
- throws NTLMEngineException {
- if (clientChallenge == null) {
- clientChallenge = makeRandomChallenge();
- }
- return clientChallenge;
- }
-
- /** Calculate and return second client challenge */
- public byte[] getClientChallenge2()
- throws NTLMEngineException {
- if (clientChallenge2 == null) {
- clientChallenge2 = makeRandomChallenge();
- }
- return clientChallenge2;
- }
-
- /** Calculate and return random secondary key */
- public byte[] getSecondaryKey()
- throws NTLMEngineException {
- if (secondaryKey == null) {
- secondaryKey = makeSecondaryKey();
- }
- return secondaryKey;
- }
-
- /** Calculate and return the LMHash */
- public byte[] getLMHash()
- throws NTLMEngineException {
- if (lmHash == null) {
- lmHash = lmHash(password);
- }
- return lmHash;
- }
-
- /** Calculate and return the LMResponse */
- public byte[] getLMResponse()
- throws NTLMEngineException {
- if (lmResponse == null) {
- lmResponse = lmResponse(getLMHash(),challenge);
- }
- return lmResponse;
- }
-
- /** Calculate and return the NTLMHash */
- public byte[] getNTLMHash()
- throws NTLMEngineException {
- if (ntlmHash == null) {
- ntlmHash = ntlmHash(password);
- }
- return ntlmHash;
- }
-
- /** Calculate and return the NTLMResponse */
- public byte[] getNTLMResponse()
- throws NTLMEngineException {
- if (ntlmResponse == null) {
- ntlmResponse = lmResponse(getNTLMHash(),challenge);
- }
- return ntlmResponse;
- }
-
- /** Calculate the LMv2 hash */
- public byte[] getLMv2Hash()
- throws NTLMEngineException {
- if (lmv2Hash == null) {
- lmv2Hash = lmv2Hash(domain, user, getNTLMHash());
- }
- return lmv2Hash;
- }
-
- /** Calculate the NTLMv2 hash */
- public byte[] getNTLMv2Hash()
- throws NTLMEngineException {
- if (ntlmv2Hash == null) {
- ntlmv2Hash = ntlmv2Hash(domain, user, getNTLMHash());
- }
- return ntlmv2Hash;
- }
-
- /** Calculate a timestamp */
- public byte[] getTimestamp() {
- if (timestamp == null) {
- long time = System.currentTimeMillis();
- time += 11644473600000l; // milliseconds from January 1, 1601 -> epoch.
- time *= 10000; // tenths of a microsecond.
- // convert to little-endian byte array.
- timestamp = new byte[8];
- for (int i = 0; i < 8; i++) {
- timestamp[i] = (byte) time;
- time >>>= 8;
- }
- }
- return timestamp;
- }
-
- /** Calculate the NTLMv2Blob */
- public byte[] getNTLMv2Blob()
- throws NTLMEngineException {
- if (ntlmv2Blob == null) {
- ntlmv2Blob = createBlob(getClientChallenge2(), targetInformation, getTimestamp());
- }
- return ntlmv2Blob;
- }
-
- /** Calculate the NTLMv2Response */
- public byte[] getNTLMv2Response()
- throws NTLMEngineException {
- if (ntlmv2Response == null) {
- ntlmv2Response = lmv2Response(getNTLMv2Hash(),challenge,getNTLMv2Blob());
- }
- return ntlmv2Response;
- }
-
- /** Calculate the LMv2Response */
- public byte[] getLMv2Response()
- throws NTLMEngineException {
- if (lmv2Response == null) {
- lmv2Response = lmv2Response(getLMv2Hash(),challenge,getClientChallenge());
- }
- return lmv2Response;
- }
-
- /** Get NTLM2SessionResponse */
- public byte[] getNTLM2SessionResponse()
- throws NTLMEngineException {
- if (ntlm2SessionResponse == null) {
- ntlm2SessionResponse = ntlm2SessionResponse(getNTLMHash(),challenge,getClientChallenge());
- }
- return ntlm2SessionResponse;
- }
-
- /** Calculate and return LM2 session response */
- public byte[] getLM2SessionResponse()
- throws NTLMEngineException {
- if (lm2SessionResponse == null) {
- final byte[] clChallenge = getClientChallenge();
- lm2SessionResponse = new byte[24];
- System.arraycopy(clChallenge, 0, lm2SessionResponse, 0, clChallenge.length);
- Arrays.fill(lm2SessionResponse, clChallenge.length, lm2SessionResponse.length, (byte) 0x00);
- }
- return lm2SessionResponse;
- }
-
- /** Get LMUserSessionKey */
- public byte[] getLMUserSessionKey()
- throws NTLMEngineException {
- if (lmUserSessionKey == null) {
- lmUserSessionKey = new byte[16];
- System.arraycopy(getLMHash(), 0, lmUserSessionKey, 0, 8);
- Arrays.fill(lmUserSessionKey, 8, 16, (byte) 0x00);
- }
- return lmUserSessionKey;
- }
-
- /** Get NTLMUserSessionKey */
- public byte[] getNTLMUserSessionKey()
- throws NTLMEngineException {
- if (ntlmUserSessionKey == null) {
- final MD4 md4 = new MD4();
- md4.update(getNTLMHash());
- ntlmUserSessionKey = md4.getOutput();
- }
- return ntlmUserSessionKey;
- }
-
- /** GetNTLMv2UserSessionKey */
- public byte[] getNTLMv2UserSessionKey()
- throws NTLMEngineException {
- if (ntlmv2UserSessionKey == null) {
- final byte[] ntlmv2hash = getNTLMv2Hash();
- final byte[] truncatedResponse = new byte[16];
- System.arraycopy(getNTLMv2Response(), 0, truncatedResponse, 0, 16);
- ntlmv2UserSessionKey = hmacMD5(truncatedResponse, ntlmv2hash);
- }
- return ntlmv2UserSessionKey;
- }
-
- /** Get NTLM2SessionResponseUserSessionKey */
- public byte[] getNTLM2SessionResponseUserSessionKey()
- throws NTLMEngineException {
- if (ntlm2SessionResponseUserSessionKey == null) {
- final byte[] ntlm2SessionResponseNonce = getLM2SessionResponse();
- final byte[] sessionNonce = new byte[challenge.length + ntlm2SessionResponseNonce.length];
- System.arraycopy(challenge, 0, sessionNonce, 0, challenge.length);
- System.arraycopy(ntlm2SessionResponseNonce, 0, sessionNonce, challenge.length, ntlm2SessionResponseNonce.length);
- ntlm2SessionResponseUserSessionKey = hmacMD5(sessionNonce,getNTLMUserSessionKey());
- }
- return ntlm2SessionResponseUserSessionKey;
- }
-
- /** Get LAN Manager session key */
- public byte[] getLanManagerSessionKey()
- throws NTLMEngineException {
- if (lanManagerSessionKey == null) {
- try {
- final byte[] keyBytes = new byte[14];
- System.arraycopy(getLMHash(), 0, keyBytes, 0, 8);
- Arrays.fill(keyBytes, 8, keyBytes.length, (byte)0xbd);
- final Key lowKey = createDESKey(keyBytes, 0);
- final Key highKey = createDESKey(keyBytes, 7);
- final byte[] truncatedResponse = new byte[8];
- System.arraycopy(getLMResponse(), 0, truncatedResponse, 0, truncatedResponse.length);
- Cipher des = Cipher.getInstance("DES/ECB/NoPadding");
- des.init(Cipher.ENCRYPT_MODE, lowKey);
- final byte[] lowPart = des.doFinal(truncatedResponse);
- des = Cipher.getInstance("DES/ECB/NoPadding");
- des.init(Cipher.ENCRYPT_MODE, highKey);
- final byte[] highPart = des.doFinal(truncatedResponse);
- lanManagerSessionKey = new byte[16];
- System.arraycopy(lowPart, 0, lanManagerSessionKey, 0, lowPart.length);
- System.arraycopy(highPart, 0, lanManagerSessionKey, lowPart.length, highPart.length);
- } catch (final Exception e) {
- throw new NTLMEngineException(e.getMessage(), e);
- }
- }
- return lanManagerSessionKey;
- }
- }
-
- /** Calculates HMAC-MD5 */
- static byte[] hmacMD5(final byte[] value, final byte[] key)
- throws NTLMEngineException {
- final HMACMD5 hmacMD5 = new HMACMD5(key);
- hmacMD5.update(value);
- return hmacMD5.getOutput();
- }
-
- /** Calculates RC4 */
- static byte[] RC4(final byte[] value, final byte[] key)
- throws NTLMEngineException {
- try {
- final Cipher rc4 = Cipher.getInstance("RC4");
- rc4.init(Cipher.ENCRYPT_MODE, new SecretKeySpec(key, "RC4"));
- return rc4.doFinal(value);
- } catch (final Exception e) {
- throw new NTLMEngineException(e.getMessage(), e);
- }
- }
-
- /**
- * Calculates the NTLM2 Session Response for the given challenge, using the
- * specified password and client challenge.
- *
- * @return The NTLM2 Session Response. This is placed in the NTLM response
- * field of the Type 3 message; the LM response field contains the
- * client challenge, null-padded to 24 bytes.
- */
- static byte[] ntlm2SessionResponse(final byte[] ntlmHash, final byte[] challenge,
- final byte[] clientChallenge) throws NTLMEngineException {
- try {
- // Look up MD5 algorithm (was necessary on jdk 1.4.2)
- // This used to be needed, but java 1.5.0_07 includes the MD5
- // algorithm (finally)
- // Class x = Class.forName("gnu.crypto.hash.MD5");
- // Method updateMethod = x.getMethod("update",new
- // Class[]{byte[].class});
- // Method digestMethod = x.getMethod("digest",new Class[0]);
- // Object mdInstance = x.newInstance();
- // updateMethod.invoke(mdInstance,new Object[]{challenge});
- // updateMethod.invoke(mdInstance,new Object[]{clientChallenge});
- // byte[] digest = (byte[])digestMethod.invoke(mdInstance,new
- // Object[0]);
-
- final MessageDigest md5 = MessageDigest.getInstance("MD5");
- md5.update(challenge);
- md5.update(clientChallenge);
- final byte[] digest = md5.digest();
-
- final byte[] sessionHash = new byte[8];
- System.arraycopy(digest, 0, sessionHash, 0, 8);
- return lmResponse(ntlmHash, sessionHash);
- } catch (final Exception e) {
- if (e instanceof NTLMEngineException) {
- throw (NTLMEngineException) e;
- }
- throw new NTLMEngineException(e.getMessage(), e);
- }
- }
-
- /**
- * Creates the LM Hash of the user's password.
- *
- * @param password
- * The password.
- *
- * @return The LM Hash of the given password, used in the calculation of the
- * LM Response.
- */
- private static byte[] lmHash(final String password) throws NTLMEngineException {
- try {
- final byte[] oemPassword = password.toUpperCase(Locale.ENGLISH).getBytes("US-ASCII");
- final int length = Math.min(oemPassword.length, 14);
- final byte[] keyBytes = new byte[14];
- System.arraycopy(oemPassword, 0, keyBytes, 0, length);
- final Key lowKey = createDESKey(keyBytes, 0);
- final Key highKey = createDESKey(keyBytes, 7);
- final byte[] magicConstant = "KGS!@#$%".getBytes("US-ASCII");
- final Cipher des = Cipher.getInstance("DES/ECB/NoPadding");
- des.init(Cipher.ENCRYPT_MODE, lowKey);
- final byte[] lowHash = des.doFinal(magicConstant);
- des.init(Cipher.ENCRYPT_MODE, highKey);
- final byte[] highHash = des.doFinal(magicConstant);
- final byte[] lmHash = new byte[16];
- System.arraycopy(lowHash, 0, lmHash, 0, 8);
- System.arraycopy(highHash, 0, lmHash, 8, 8);
- return lmHash;
- } catch (final Exception e) {
- throw new NTLMEngineException(e.getMessage(), e);
- }
- }
-
- /**
- * Creates the NTLM Hash of the user's password.
- *
- * @param password
- * The password.
- *
- * @return The NTLM Hash of the given password, used in the calculation of
- * the NTLM Response and the NTLMv2 and LMv2 Hashes.
- */
- private static byte[] ntlmHash(final String password) throws NTLMEngineException {
- try {
- final byte[] unicodePassword = password.getBytes("UnicodeLittleUnmarked");
- final MD4 md4 = new MD4();
- md4.update(unicodePassword);
- return md4.getOutput();
- } catch (final UnsupportedEncodingException e) {
- throw new NTLMEngineException("Unicode not supported: " + e.getMessage(), e);
- }
- }
-
- /**
- * Creates the LMv2 Hash of the user's password.
- *
- * @return The LMv2 Hash, used in the calculation of the NTLMv2 and LMv2
- * Responses.
- */
- private static byte[] lmv2Hash(final String domain, final String user, final byte[] ntlmHash)
- throws NTLMEngineException {
- try {
- final HMACMD5 hmacMD5 = new HMACMD5(ntlmHash);
- // Upper case username, upper case domain!
- hmacMD5.update(user.toUpperCase(Locale.ENGLISH).getBytes("UnicodeLittleUnmarked"));
- if (domain != null) {
- hmacMD5.update(domain.toUpperCase(Locale.ENGLISH).getBytes("UnicodeLittleUnmarked"));
- }
- return hmacMD5.getOutput();
- } catch (final UnsupportedEncodingException e) {
- throw new NTLMEngineException("Unicode not supported! " + e.getMessage(), e);
- }
- }
-
- /**
- * Creates the NTLMv2 Hash of the user's password.
- *
- * @return The NTLMv2 Hash, used in the calculation of the NTLMv2 and LMv2
- * Responses.
- */
- private static byte[] ntlmv2Hash(final String domain, final String user, final byte[] ntlmHash)
- throws NTLMEngineException {
- try {
- final HMACMD5 hmacMD5 = new HMACMD5(ntlmHash);
- // Upper case username, mixed case target!!
- hmacMD5.update(user.toUpperCase(Locale.ENGLISH).getBytes("UnicodeLittleUnmarked"));
- if (domain != null) {
- hmacMD5.update(domain.getBytes("UnicodeLittleUnmarked"));
- }
- return hmacMD5.getOutput();
- } catch (final UnsupportedEncodingException e) {
- throw new NTLMEngineException("Unicode not supported! " + e.getMessage(), e);
- }
- }
-
- /**
- * Creates the LM Response from the given hash and Type 2 challenge.
- *
- * @param hash
- * The LM or NTLM Hash.
- * @param challenge
- * The server challenge from the Type 2 message.
- *
- * @return The response (either LM or NTLM, depending on the provided hash).
- */
- private static byte[] lmResponse(final byte[] hash, final byte[] challenge) throws NTLMEngineException {
- try {
- final byte[] keyBytes = new byte[21];
- System.arraycopy(hash, 0, keyBytes, 0, 16);
- final Key lowKey = createDESKey(keyBytes, 0);
- final Key middleKey = createDESKey(keyBytes, 7);
- final Key highKey = createDESKey(keyBytes, 14);
- final Cipher des = Cipher.getInstance("DES/ECB/NoPadding");
- des.init(Cipher.ENCRYPT_MODE, lowKey);
- final byte[] lowResponse = des.doFinal(challenge);
- des.init(Cipher.ENCRYPT_MODE, middleKey);
- final byte[] middleResponse = des.doFinal(challenge);
- des.init(Cipher.ENCRYPT_MODE, highKey);
- final byte[] highResponse = des.doFinal(challenge);
- final byte[] lmResponse = new byte[24];
- System.arraycopy(lowResponse, 0, lmResponse, 0, 8);
- System.arraycopy(middleResponse, 0, lmResponse, 8, 8);
- System.arraycopy(highResponse, 0, lmResponse, 16, 8);
- return lmResponse;
- } catch (final Exception e) {
- throw new NTLMEngineException(e.getMessage(), e);
- }
- }
-
- /**
- * Creates the LMv2 Response from the given hash, client data, and Type 2
- * challenge.
- *
- * @param hash
- * The NTLMv2 Hash.
- * @param clientData
- * The client data (blob or client challenge).
- * @param challenge
- * The server challenge from the Type 2 message.
- *
- * @return The response (either NTLMv2 or LMv2, depending on the client
- * data).
- */
- private static byte[] lmv2Response(final byte[] hash, final byte[] challenge, final byte[] clientData)
- throws NTLMEngineException {
- final HMACMD5 hmacMD5 = new HMACMD5(hash);
- hmacMD5.update(challenge);
- hmacMD5.update(clientData);
- final byte[] mac = hmacMD5.getOutput();
- final byte[] lmv2Response = new byte[mac.length + clientData.length];
- System.arraycopy(mac, 0, lmv2Response, 0, mac.length);
- System.arraycopy(clientData, 0, lmv2Response, mac.length, clientData.length);
- return lmv2Response;
- }
-
- /**
- * Creates the NTLMv2 blob from the given target information block and
- * client challenge.
- *
- * @param targetInformation
- * The target information block from the Type 2 message.
- * @param clientChallenge
- * The random 8-byte client challenge.
- *
- * @return The blob, used in the calculation of the NTLMv2 Response.
- */
- private static byte[] createBlob(final byte[] clientChallenge, final byte[] targetInformation, final byte[] timestamp) {
- final byte[] blobSignature = new byte[] { (byte) 0x01, (byte) 0x01, (byte) 0x00, (byte) 0x00 };
- final byte[] reserved = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
- final byte[] unknown1 = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
- final byte[] unknown2 = new byte[] { (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 };
- final byte[] blob = new byte[blobSignature.length + reserved.length + timestamp.length + 8
- + unknown1.length + targetInformation.length + unknown2.length];
- int offset = 0;
- System.arraycopy(blobSignature, 0, blob, offset, blobSignature.length);
- offset += blobSignature.length;
- System.arraycopy(reserved, 0, blob, offset, reserved.length);
- offset += reserved.length;
- System.arraycopy(timestamp, 0, blob, offset, timestamp.length);
- offset += timestamp.length;
- System.arraycopy(clientChallenge, 0, blob, offset, 8);
- offset += 8;
- System.arraycopy(unknown1, 0, blob, offset, unknown1.length);
- offset += unknown1.length;
- System.arraycopy(targetInformation, 0, blob, offset, targetInformation.length);
- offset += targetInformation.length;
- System.arraycopy(unknown2, 0, blob, offset, unknown2.length);
- offset += unknown2.length;
- return blob;
- }
-
- /**
- * Creates a DES encryption key from the given key material.
- *
- * @param bytes
- * A byte array containing the DES key material.
- * @param offset
- * The offset in the given byte array at which the 7-byte key
- * material starts.
- *
- * @return A DES encryption key created from the key material starting at
- * the specified offset in the given byte array.
- */
- private static Key createDESKey(final byte[] bytes, final int offset) {
- final byte[] keyBytes = new byte[7];
- System.arraycopy(bytes, offset, keyBytes, 0, 7);
- final byte[] material = new byte[8];
- material[0] = keyBytes[0];
- material[1] = (byte) (keyBytes[0] << 7 | (keyBytes[1] & 0xff) >>> 1);
- material[2] = (byte) (keyBytes[1] << 6 | (keyBytes[2] & 0xff) >>> 2);
- material[3] = (byte) (keyBytes[2] << 5 | (keyBytes[3] & 0xff) >>> 3);
- material[4] = (byte) (keyBytes[3] << 4 | (keyBytes[4] & 0xff) >>> 4);
- material[5] = (byte) (keyBytes[4] << 3 | (keyBytes[5] & 0xff) >>> 5);
- material[6] = (byte) (keyBytes[5] << 2 | (keyBytes[6] & 0xff) >>> 6);
- material[7] = (byte) (keyBytes[6] << 1);
- oddParity(material);
- return new SecretKeySpec(material, "DES");
- }
-
- /**
- * Applies odd parity to the given byte array.
- *
- * @param bytes
- * The data whose parity bits are to be adjusted for odd parity.
- */
- private static void oddParity(final byte[] bytes) {
- for (int i = 0; i < bytes.length; i++) {
- final byte b = bytes[i];
- final boolean needsParity = (((b >>> 7) ^ (b >>> 6) ^ (b >>> 5) ^ (b >>> 4) ^ (b >>> 3)
- ^ (b >>> 2) ^ (b >>> 1)) & 0x01) == 0;
- if (needsParity) {
- bytes[i] |= (byte) 0x01;
- } else {
- bytes[i] &= (byte) 0xfe;
- }
- }
- }
-
- /** NTLM message generation, base class */
- static class NTLMMessage {
- /** The current response */
- private byte[] messageContents = null;
-
- /** The current output position */
- private int currentOutputPosition = 0;
-
- /** Constructor to use when message contents are not yet known */
- NTLMMessage() {
- }
-
- /** Constructor to use when message contents are known */
- NTLMMessage(final String messageBody, final int expectedType) throws NTLMEngineException {
- messageContents = Base64.decode(EncodingUtils.getBytes(messageBody, DEFAULT_CHARSET),
- Base64.NO_WRAP);
- // Look for NTLM message
- if (messageContents.length < SIGNATURE.length) {
- throw new NTLMEngineException("NTLM message decoding error - packet too short");
- }
- int i = 0;
- while (i < SIGNATURE.length) {
- if (messageContents[i] != SIGNATURE[i]) {
- throw new NTLMEngineException(
- "NTLM message expected - instead got unrecognized bytes");
- }
- i++;
- }
-
- // Check to be sure there's a type 2 message indicator next
- final int type = readULong(SIGNATURE.length);
- if (type != expectedType) {
- throw new NTLMEngineException("NTLM type " + Integer.toString(expectedType)
- + " message expected - instead got type " + Integer.toString(type));
- }
-
- currentOutputPosition = messageContents.length;
- }
-
- /**
- * Get the length of the signature and flags, so calculations can adjust
- * offsets accordingly.
- */
- protected int getPreambleLength() {
- return SIGNATURE.length + 4;
- }
-
- /** Get the message length */
- protected int getMessageLength() {
- return currentOutputPosition;
- }
-
- /** Read a byte from a position within the message buffer */
- protected byte readByte(final int position) throws NTLMEngineException {
- if (messageContents.length < position + 1) {
- throw new NTLMEngineException("NTLM: Message too short");
- }
- return messageContents[position];
- }
-
- /** Read a bunch of bytes from a position in the message buffer */
- protected void readBytes(final byte[] buffer, final int position) throws NTLMEngineException {
- if (messageContents.length < position + buffer.length) {
- throw new NTLMEngineException("NTLM: Message too short");
- }
- System.arraycopy(messageContents, position, buffer, 0, buffer.length);
- }
-
- /** Read a ushort from a position within the message buffer */
- protected int readUShort(final int position) throws NTLMEngineException {
- return NTLMEngineImpl.readUShort(messageContents, position);
- }
-
- /** Read a ulong from a position within the message buffer */
- protected int readULong(final int position) throws NTLMEngineException {
- return NTLMEngineImpl.readULong(messageContents, position);
- }
-
- /** Read a security buffer from a position within the message buffer */
- protected byte[] readSecurityBuffer(final int position) throws NTLMEngineException {
- return NTLMEngineImpl.readSecurityBuffer(messageContents, position);
- }
-
- /**
- * Prepares the object to create a response of the given length.
- *
- * @param maxlength
- * the maximum length of the response to prepare, not
- * including the type and the signature (which this method
- * adds).
- */
- protected void prepareResponse(final int maxlength, final int messageType) {
- messageContents = new byte[maxlength];
- currentOutputPosition = 0;
- addBytes(SIGNATURE);
- addULong(messageType);
- }
-
- /**
- * Adds the given byte to the response.
- *
- * @param b
- * the byte to add.
- */
- protected void addByte(final byte b) {
- messageContents[currentOutputPosition] = b;
- currentOutputPosition++;
- }
-
- /**
- * Adds the given bytes to the response.
- *
- * @param bytes
- * the bytes to add.
- */
- protected void addBytes(final byte[] bytes) {
- if (bytes == null) {
- return;
- }
- for (final byte b : bytes) {
- messageContents[currentOutputPosition] = b;
- currentOutputPosition++;
- }
- }
-
- /** Adds a USHORT to the response */
- protected void addUShort(final int value) {
- addByte((byte) (value & 0xff));
- addByte((byte) (value >> 8 & 0xff));
- }
-
- /** Adds a ULong to the response */
- protected void addULong(final int value) {
- addByte((byte) (value & 0xff));
- addByte((byte) (value >> 8 & 0xff));
- addByte((byte) (value >> 16 & 0xff));
- addByte((byte) (value >> 24 & 0xff));
- }
-
- /**
- * Returns the response that has been generated after shrinking the
- * array if required and base64 encodes the response.
- *
- * @return The response as above.
- */
- String getResponse() {
- final byte[] resp;
- if (messageContents.length > currentOutputPosition) {
- final byte[] tmp = new byte[currentOutputPosition];
- System.arraycopy(messageContents, 0, tmp, 0, currentOutputPosition);
- resp = tmp;
- } else {
- resp = messageContents;
- }
- return EncodingUtils.getAsciiString(Base64.encode(resp, Base64.NO_WRAP));
- }
-
- }
-
- /** Type 1 message assembly class */
- static class Type1Message extends NTLMMessage {
- protected byte[] hostBytes;
- protected byte[] domainBytes;
-
- /** Constructor. Include the arguments the message will need */
- Type1Message(final String domain, final String host) throws NTLMEngineException {
- super();
- try {
- // Strip off domain name from the host!
- final String unqualifiedHost = convertHost(host);
- // Use only the base domain name!
- final String unqualifiedDomain = convertDomain(domain);
-
- hostBytes = unqualifiedHost != null? unqualifiedHost.getBytes("ASCII") : null;
- domainBytes = unqualifiedDomain != null ? unqualifiedDomain
- .toUpperCase(Locale.ENGLISH).getBytes("ASCII") : null;
- } catch (final UnsupportedEncodingException e) {
- throw new NTLMEngineException("Unicode unsupported: " + e.getMessage(), e);
- }
- }
-
- /**
- * Getting the response involves building the message before returning
- * it
- */
- @Override
- String getResponse() {
- // Now, build the message. Calculate its length first, including
- // signature or type.
- final int finalLength = 32 + 8 /*+ hostBytes.length + domainBytes.length */;
-
- // Set up the response. This will initialize the signature, message
- // type, and flags.
- prepareResponse(finalLength, 1);
-
- // Flags. These are the complete set of flags we support.
- addULong(
- //FLAG_WORKSTATION_PRESENT |
- //FLAG_DOMAIN_PRESENT |
-
- // Required flags
- //FLAG_REQUEST_LAN_MANAGER_KEY |
- FLAG_REQUEST_NTLMv1 |
- FLAG_REQUEST_NTLM2_SESSION |
-
- // Protocol version request
- FLAG_REQUEST_VERSION |
-
- // Recommended privacy settings
- FLAG_REQUEST_ALWAYS_SIGN |
- //FLAG_REQUEST_SEAL |
- //FLAG_REQUEST_SIGN |
-
- // These must be set according to documentation, based on use of SEAL above
- FLAG_REQUEST_128BIT_KEY_EXCH |
- FLAG_REQUEST_56BIT_ENCRYPTION |
- //FLAG_REQUEST_EXPLICIT_KEY_EXCH |
-
- FLAG_REQUEST_UNICODE_ENCODING);
-
- // Domain length (two times).
- addUShort(/*domainBytes.length*/0);
- addUShort(/*domainBytes.length*/0);
-
- // Domain offset.
- addULong(/*hostBytes.length +*/ 32 + 8);
-
- // Host length (two times).
- addUShort(/*hostBytes.length*/0);
- addUShort(/*hostBytes.length*/0);
-
- // Host offset (always 32 + 8).
- addULong(32 + 8);
-
- // Version
- addUShort(0x0105);
- // Build
- addULong(2600);
- // NTLM revision
- addUShort(0x0f00);
-
-
- // Host (workstation) String.
- //addBytes(hostBytes);
-
- // Domain String.
- //addBytes(domainBytes);
-
-
- return super.getResponse();
- }
-
- }
-
- /** Type 2 message class */
- static class Type2Message extends NTLMMessage {
- protected byte[] challenge;
- protected String target;
- protected byte[] targetInfo;
- protected int flags;
-
- Type2Message(final String message) throws NTLMEngineException {
- super(message, 2);
-
- // Type 2 message is laid out as follows:
- // First 8 bytes: NTLMSSP[0]
- // Next 4 bytes: Ulong, value 2
- // Next 8 bytes, starting at offset 12: target field (2 ushort lengths, 1 ulong offset)
- // Next 4 bytes, starting at offset 20: Flags, e.g. 0x22890235
- // Next 8 bytes, starting at offset 24: Challenge
- // Next 8 bytes, starting at offset 32: ??? (8 bytes of zeros)
- // Next 8 bytes, starting at offset 40: targetinfo field (2 ushort lengths, 1 ulong offset)
- // Next 2 bytes, major/minor version number (e.g. 0x05 0x02)
- // Next 8 bytes, build number
- // Next 2 bytes, protocol version number (e.g. 0x00 0x0f)
- // Next, various text fields, and a ushort of value 0 at the end
-
- // Parse out the rest of the info we need from the message
- // The nonce is the 8 bytes starting from the byte in position 24.
- challenge = new byte[8];
- readBytes(challenge, 24);
-
- flags = readULong(20);
-
- if ((flags & FLAG_REQUEST_UNICODE_ENCODING) == 0) {
- throw new NTLMEngineException(
- "NTLM type 2 message has flags that make no sense: "
- + Integer.toString(flags));
- }
-
- // Do the target!
- target = null;
- // The TARGET_DESIRED flag is said to not have understood semantics
- // in Type2 messages, so use the length of the packet to decide
- // how to proceed instead
- if (getMessageLength() >= 12 + 8) {
- final byte[] bytes = readSecurityBuffer(12);
- if (bytes.length != 0) {
- try {
- target = new String(bytes, "UnicodeLittleUnmarked");
- } catch (final UnsupportedEncodingException e) {
- throw new NTLMEngineException(e.getMessage(), e);
- }
- }
- }
-
- // Do the target info!
- targetInfo = null;
- // TARGET_DESIRED flag cannot be relied on, so use packet length
- if (getMessageLength() >= 40 + 8) {
- final byte[] bytes = readSecurityBuffer(40);
- if (bytes.length != 0) {
- targetInfo = bytes;
- }
- }
- }
-
- /** Retrieve the challenge */
- byte[] getChallenge() {
- return challenge;
- }
-
- /** Retrieve the target */
- String getTarget() {
- return target;
- }
-
- /** Retrieve the target info */
- byte[] getTargetInfo() {
- return targetInfo;
- }
-
- /** Retrieve the response flags */
- int getFlags() {
- return flags;
- }
-
- }
-
- /** Type 3 message assembly class */
- static class Type3Message extends NTLMMessage {
- // Response flags from the type2 message
- protected int type2Flags;
-
- protected byte[] domainBytes;
- protected byte[] hostBytes;
- protected byte[] userBytes;
-
- protected byte[] lmResp;
- protected byte[] ntResp;
- protected byte[] sessionKey;
-
-
- /** Constructor. Pass the arguments we will need */
- Type3Message(final String domain, final String host, final String user, final String password, final byte[] nonce,
- final int type2Flags, final String target, final byte[] targetInformation)
- throws NTLMEngineException {
- // Save the flags
- this.type2Flags = type2Flags;
-
- // Strip off domain name from the host!
- final String unqualifiedHost = convertHost(host);
- // Use only the base domain name!
- final String unqualifiedDomain = convertDomain(domain);
-
- // Create a cipher generator class. Use domain BEFORE it gets modified!
- final CipherGen gen = new CipherGen(unqualifiedDomain, user, password, nonce, target, targetInformation);
-
- // Use the new code to calculate the responses, including v2 if that
- // seems warranted.
- byte[] userSessionKey;
- try {
- // This conditional may not work on Windows Server 2008 R2 and above, where it has not yet
- // been tested
- if (((type2Flags & FLAG_TARGETINFO_PRESENT) != 0) &&
- targetInformation != null && target != null) {
- // NTLMv2
- ntResp = gen.getNTLMv2Response();
- lmResp = gen.getLMv2Response();
- if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0) {
- userSessionKey = gen.getLanManagerSessionKey();
- } else {
- userSessionKey = gen.getNTLMv2UserSessionKey();
- }
- } else {
- // NTLMv1
- if ((type2Flags & FLAG_REQUEST_NTLM2_SESSION) != 0) {
- // NTLM2 session stuff is requested
- ntResp = gen.getNTLM2SessionResponse();
- lmResp = gen.getLM2SessionResponse();
- if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0) {
- userSessionKey = gen.getLanManagerSessionKey();
- } else {
- userSessionKey = gen.getNTLM2SessionResponseUserSessionKey();
- }
- } else {
- ntResp = gen.getNTLMResponse();
- lmResp = gen.getLMResponse();
- if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0) {
- userSessionKey = gen.getLanManagerSessionKey();
- } else {
- userSessionKey = gen.getNTLMUserSessionKey();
- }
- }
- }
- } catch (final NTLMEngineException e) {
- // This likely means we couldn't find the MD4 hash algorithm -
- // fail back to just using LM
- ntResp = new byte[0];
- lmResp = gen.getLMResponse();
- if ((type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) != 0) {
- userSessionKey = gen.getLanManagerSessionKey();
- } else {
- userSessionKey = gen.getLMUserSessionKey();
- }
- }
-
- if ((type2Flags & FLAG_REQUEST_SIGN) != 0) {
- if ((type2Flags & FLAG_REQUEST_EXPLICIT_KEY_EXCH) != 0) {
- sessionKey = RC4(gen.getSecondaryKey(), userSessionKey);
- } else {
- sessionKey = userSessionKey;
- }
- } else {
- sessionKey = null;
- }
-
- try {
- hostBytes = unqualifiedHost != null ? unqualifiedHost
- .getBytes("UnicodeLittleUnmarked") : null;
- domainBytes = unqualifiedDomain != null ? unqualifiedDomain
- .toUpperCase(Locale.ENGLISH).getBytes("UnicodeLittleUnmarked") : null;
- userBytes = user.getBytes("UnicodeLittleUnmarked");
- } catch (final UnsupportedEncodingException e) {
- throw new NTLMEngineException("Unicode not supported: " + e.getMessage(), e);
- }
- }
-
- /** Assemble the response */
- @Override
- String getResponse() {
- final int ntRespLen = ntResp.length;
- final int lmRespLen = lmResp.length;
-
- final int domainLen = domainBytes != null ? domainBytes.length : 0;
- final int hostLen = hostBytes != null ? hostBytes.length: 0;
- final int userLen = userBytes.length;
- final int sessionKeyLen;
- if (sessionKey != null) {
- sessionKeyLen = sessionKey.length;
- } else {
- sessionKeyLen = 0;
- }
-
- // Calculate the layout within the packet
- final int lmRespOffset = 72; // allocate space for the version
- final int ntRespOffset = lmRespOffset + lmRespLen;
- final int domainOffset = ntRespOffset + ntRespLen;
- final int userOffset = domainOffset + domainLen;
- final int hostOffset = userOffset + userLen;
- final int sessionKeyOffset = hostOffset + hostLen;
- final int finalLength = sessionKeyOffset + sessionKeyLen;
-
- // Start the response. Length includes signature and type
- prepareResponse(finalLength, 3);
-
- // LM Resp Length (twice)
- addUShort(lmRespLen);
- addUShort(lmRespLen);
-
- // LM Resp Offset
- addULong(lmRespOffset);
-
- // NT Resp Length (twice)
- addUShort(ntRespLen);
- addUShort(ntRespLen);
-
- // NT Resp Offset
- addULong(ntRespOffset);
-
- // Domain length (twice)
- addUShort(domainLen);
- addUShort(domainLen);
-
- // Domain offset.
- addULong(domainOffset);
-
- // User Length (twice)
- addUShort(userLen);
- addUShort(userLen);
-
- // User offset
- addULong(userOffset);
-
- // Host length (twice)
- addUShort(hostLen);
- addUShort(hostLen);
-
- // Host offset
- addULong(hostOffset);
-
- // Session key length (twice)
- addUShort(sessionKeyLen);
- addUShort(sessionKeyLen);
-
- // Session key offset
- addULong(sessionKeyOffset);
-
- // Flags.
- addULong(
- //FLAG_WORKSTATION_PRESENT |
- //FLAG_DOMAIN_PRESENT |
-
- // Required flags
- (type2Flags & FLAG_REQUEST_LAN_MANAGER_KEY) |
- (type2Flags & FLAG_REQUEST_NTLMv1) |
- (type2Flags & FLAG_REQUEST_NTLM2_SESSION) |
-
- // Protocol version request
- FLAG_REQUEST_VERSION |
-
- // Recommended privacy settings
- (type2Flags & FLAG_REQUEST_ALWAYS_SIGN) |
- (type2Flags & FLAG_REQUEST_SEAL) |
- (type2Flags & FLAG_REQUEST_SIGN) |
-
- // These must be set according to documentation, based on use of SEAL above
- (type2Flags & FLAG_REQUEST_128BIT_KEY_EXCH) |
- (type2Flags & FLAG_REQUEST_56BIT_ENCRYPTION) |
- (type2Flags & FLAG_REQUEST_EXPLICIT_KEY_EXCH) |
-
- (type2Flags & FLAG_TARGETINFO_PRESENT) |
- (type2Flags & FLAG_REQUEST_UNICODE_ENCODING) |
- (type2Flags & FLAG_REQUEST_TARGET)
- );
-
- // Version
- addUShort(0x0105);
- // Build
- addULong(2600);
- // NTLM revision
- addUShort(0x0f00);
-
- // Add the actual data
- addBytes(lmResp);
- addBytes(ntResp);
- addBytes(domainBytes);
- addBytes(userBytes);
- addBytes(hostBytes);
- if (sessionKey != null) {
- addBytes(sessionKey);
- }
-
- return super.getResponse();
- }
- }
-
- static void writeULong(final byte[] buffer, final int value, final int offset) {
- buffer[offset] = (byte) (value & 0xff);
- buffer[offset + 1] = (byte) (value >> 8 & 0xff);
- buffer[offset + 2] = (byte) (value >> 16 & 0xff);
- buffer[offset + 3] = (byte) (value >> 24 & 0xff);
- }
-
- static int F(final int x, final int y, final int z) {
- return ((x & y) | (~x & z));
- }
-
- static int G(final int x, final int y, final int z) {
- return ((x & y) | (x & z) | (y & z));
- }
-
- static int H(final int x, final int y, final int z) {
- return (x ^ y ^ z);
- }
-
- static int rotintlft(final int val, final int numbits) {
- return ((val << numbits) | (val >>> (32 - numbits)));
- }
-
- /**
- * Cryptography support - MD4. The following class was based loosely on the
- * RFC and on code found at http://www.cs.umd.edu/~harry/jotp/src/md.java.
- * Code correctness was verified by looking at MD4.java from the jcifs
- * library (http://jcifs.samba.org). It was massaged extensively to the
- * final form found here by Karl Wright (kwright@metacarta.com).
- */
- static class MD4 {
- protected int A = 0x67452301;
- protected int B = 0xefcdab89;
- protected int C = 0x98badcfe;
- protected int D = 0x10325476;
- protected long count = 0L;
- protected byte[] dataBuffer = new byte[64];
-
- MD4() {
- }
-
- void update(final byte[] input) {
- // We always deal with 512 bits at a time. Correspondingly, there is
- // a buffer 64 bytes long that we write data into until it gets
- // full.
- int curBufferPos = (int) (count & 63L);
- int inputIndex = 0;
- while (input.length - inputIndex + curBufferPos >= dataBuffer.length) {
- // We have enough data to do the next step. Do a partial copy
- // and a transform, updating inputIndex and curBufferPos
- // accordingly
- final int transferAmt = dataBuffer.length - curBufferPos;
- System.arraycopy(input, inputIndex, dataBuffer, curBufferPos, transferAmt);
- count += transferAmt;
- curBufferPos = 0;
- inputIndex += transferAmt;
- processBuffer();
- }
-
- // If there's anything left, copy it into the buffer and leave it.
- // We know there's not enough left to process.
- if (inputIndex < input.length) {
- final int transferAmt = input.length - inputIndex;
- System.arraycopy(input, inputIndex, dataBuffer, curBufferPos, transferAmt);
- count += transferAmt;
- curBufferPos += transferAmt;
- }
- }
-
- byte[] getOutput() {
- // Feed pad/length data into engine. This must round out the input
- // to a multiple of 512 bits.
- final int bufferIndex = (int) (count & 63L);
- final int padLen = (bufferIndex < 56) ? (56 - bufferIndex) : (120 - bufferIndex);
- final byte[] postBytes = new byte[padLen + 8];
- // Leading 0x80, specified amount of zero padding, then length in
- // bits.
- postBytes[0] = (byte) 0x80;
- // Fill out the last 8 bytes with the length
- for (int i = 0; i < 8; i++) {
- postBytes[padLen + i] = (byte) ((count * 8) >>> (8 * i));
- }
-
- // Update the engine
- update(postBytes);
-
- // Calculate final result
- final byte[] result = new byte[16];
- writeULong(result, A, 0);
- writeULong(result, B, 4);
- writeULong(result, C, 8);
- writeULong(result, D, 12);
- return result;
- }
-
- protected void processBuffer() {
- // Convert current buffer to 16 ulongs
- final int[] d = new int[16];
-
- for (int i = 0; i < 16; i++) {
- d[i] = (dataBuffer[i * 4] & 0xff) + ((dataBuffer[i * 4 + 1] & 0xff) << 8)
- + ((dataBuffer[i * 4 + 2] & 0xff) << 16)
- + ((dataBuffer[i * 4 + 3] & 0xff) << 24);
- }
-
- // Do a round of processing
- final int AA = A;
- final int BB = B;
- final int CC = C;
- final int DD = D;
- round1(d);
- round2(d);
- round3(d);
- A += AA;
- B += BB;
- C += CC;
- D += DD;
-
- }
-
- protected void round1(final int[] d) {
- A = rotintlft((A + F(B, C, D) + d[0]), 3);
- D = rotintlft((D + F(A, B, C) + d[1]), 7);
- C = rotintlft((C + F(D, A, B) + d[2]), 11);
- B = rotintlft((B + F(C, D, A) + d[3]), 19);
-
- A = rotintlft((A + F(B, C, D) + d[4]), 3);
- D = rotintlft((D + F(A, B, C) + d[5]), 7);
- C = rotintlft((C + F(D, A, B) + d[6]), 11);
- B = rotintlft((B + F(C, D, A) + d[7]), 19);
-
- A = rotintlft((A + F(B, C, D) + d[8]), 3);
- D = rotintlft((D + F(A, B, C) + d[9]), 7);
- C = rotintlft((C + F(D, A, B) + d[10]), 11);
- B = rotintlft((B + F(C, D, A) + d[11]), 19);
-
- A = rotintlft((A + F(B, C, D) + d[12]), 3);
- D = rotintlft((D + F(A, B, C) + d[13]), 7);
- C = rotintlft((C + F(D, A, B) + d[14]), 11);
- B = rotintlft((B + F(C, D, A) + d[15]), 19);
- }
-
- protected void round2(final int[] d) {
- A = rotintlft((A + G(B, C, D) + d[0] + 0x5a827999), 3);
- D = rotintlft((D + G(A, B, C) + d[4] + 0x5a827999), 5);
- C = rotintlft((C + G(D, A, B) + d[8] + 0x5a827999), 9);
- B = rotintlft((B + G(C, D, A) + d[12] + 0x5a827999), 13);
-
- A = rotintlft((A + G(B, C, D) + d[1] + 0x5a827999), 3);
- D = rotintlft((D + G(A, B, C) + d[5] + 0x5a827999), 5);
- C = rotintlft((C + G(D, A, B) + d[9] + 0x5a827999), 9);
- B = rotintlft((B + G(C, D, A) + d[13] + 0x5a827999), 13);
-
- A = rotintlft((A + G(B, C, D) + d[2] + 0x5a827999), 3);
- D = rotintlft((D + G(A, B, C) + d[6] + 0x5a827999), 5);
- C = rotintlft((C + G(D, A, B) + d[10] + 0x5a827999), 9);
- B = rotintlft((B + G(C, D, A) + d[14] + 0x5a827999), 13);
-
- A = rotintlft((A + G(B, C, D) + d[3] + 0x5a827999), 3);
- D = rotintlft((D + G(A, B, C) + d[7] + 0x5a827999), 5);
- C = rotintlft((C + G(D, A, B) + d[11] + 0x5a827999), 9);
- B = rotintlft((B + G(C, D, A) + d[15] + 0x5a827999), 13);
-
- }
-
- protected void round3(final int[] d) {
- A = rotintlft((A + H(B, C, D) + d[0] + 0x6ed9eba1), 3);
- D = rotintlft((D + H(A, B, C) + d[8] + 0x6ed9eba1), 9);
- C = rotintlft((C + H(D, A, B) + d[4] + 0x6ed9eba1), 11);
- B = rotintlft((B + H(C, D, A) + d[12] + 0x6ed9eba1), 15);
-
- A = rotintlft((A + H(B, C, D) + d[2] + 0x6ed9eba1), 3);
- D = rotintlft((D + H(A, B, C) + d[10] + 0x6ed9eba1), 9);
- C = rotintlft((C + H(D, A, B) + d[6] + 0x6ed9eba1), 11);
- B = rotintlft((B + H(C, D, A) + d[14] + 0x6ed9eba1), 15);
-
- A = rotintlft((A + H(B, C, D) + d[1] + 0x6ed9eba1), 3);
- D = rotintlft((D + H(A, B, C) + d[9] + 0x6ed9eba1), 9);
- C = rotintlft((C + H(D, A, B) + d[5] + 0x6ed9eba1), 11);
- B = rotintlft((B + H(C, D, A) + d[13] + 0x6ed9eba1), 15);
-
- A = rotintlft((A + H(B, C, D) + d[3] + 0x6ed9eba1), 3);
- D = rotintlft((D + H(A, B, C) + d[11] + 0x6ed9eba1), 9);
- C = rotintlft((C + H(D, A, B) + d[7] + 0x6ed9eba1), 11);
- B = rotintlft((B + H(C, D, A) + d[15] + 0x6ed9eba1), 15);
-
- }
-
- }
-
- /**
- * Cryptography support - HMACMD5 - algorithmically based on various web
- * resources by Karl Wright
- */
- static class HMACMD5 {
- protected byte[] ipad;
- protected byte[] opad;
- protected MessageDigest md5;
-
- HMACMD5(final byte[] input) throws NTLMEngineException {
- byte[] key = input;
- try {
- md5 = MessageDigest.getInstance("MD5");
- } catch (final Exception ex) {
- // Umm, the algorithm doesn't exist - throw an
- // NTLMEngineException!
- throw new NTLMEngineException(
- "Error getting md5 message digest implementation: " + ex.getMessage(), ex);
- }
-
- // Initialize the pad buffers with the key
- ipad = new byte[64];
- opad = new byte[64];
-
- int keyLength = key.length;
- if (keyLength > 64) {
- // Use MD5 of the key instead, as described in RFC 2104
- md5.update(key);
- key = md5.digest();
- keyLength = key.length;
- }
- int i = 0;
- while (i < keyLength) {
- ipad[i] = (byte) (key[i] ^ (byte) 0x36);
- opad[i] = (byte) (key[i] ^ (byte) 0x5c);
- i++;
- }
- while (i < 64) {
- ipad[i] = (byte) 0x36;
- opad[i] = (byte) 0x5c;
- i++;
- }
-
- // Very important: update the digest with the ipad buffer
- md5.reset();
- md5.update(ipad);
-
- }
-
- /** Grab the current digest. This is the "answer". */
- byte[] getOutput() {
- final byte[] digest = md5.digest();
- md5.update(opad);
- return md5.digest(digest);
- }
-
- /** Update by adding a complete array */
- void update(final byte[] input) {
- md5.update(input);
- }
-
- /** Update the algorithm */
- void update(final byte[] input, final int offset, final int length) {
- md5.update(input, offset, length);
- }
-
- }
-
- public String generateType1Msg(
- final String domain,
- final String workstation) throws NTLMEngineException {
- return getType1Message(workstation, domain);
- }
-
- public String generateType3Msg(
- final String username,
- final String password,
- final String domain,
- final String workstation,
- final String challenge) throws NTLMEngineException {
- final Type2Message t2m = new Type2Message(challenge);
- return getType3Message(
- username,
- password,
- workstation,
- domain,
- t2m.getChallenge(),
- t2m.getFlags(),
- t2m.getTarget(),
- t2m.getTargetInfo());
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/NTLMSchemeFactory.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/NTLMSchemeFactory.java
deleted file mode 100644
index 06e001b0..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/NTLMSchemeFactory.java
+++ /dev/null
@@ -1,56 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.auth;
-
-import org.apache.http.annotation.Immutable;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthSchemeFactory;
-import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * {@link AuthSchemeProvider} implementation that creates and initializes
- * {@link NTLMScheme} instances configured to use the default {@link NTLMEngine}
- * implementation.
- *
- * @since 4.1
- */
-@Immutable
-@SuppressWarnings("deprecation")
-public class NTLMSchemeFactory implements AuthSchemeFactory, AuthSchemeProvider {
-
- public AuthScheme newInstance(final HttpParams params) {
- return new NTLMSchemeHC4();
- }
-
- public AuthScheme create(final HttpContext context) {
- return new NTLMSchemeHC4();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/NTLMSchemeHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/NTLMSchemeHC4.java
deleted file mode 100644
index f540392d..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/NTLMSchemeHC4.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.auth;
-
-import org.apache.http.Header;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.AuthenticationException;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.InvalidCredentialsException;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.auth.NTCredentials;
-import org.apache.http.message.BufferedHeader;
-import org.apache.http.util.Args;
-import org.apache.http.util.CharArrayBuffer;
-
-/**
- * NTLM is a proprietary authentication scheme developed by Microsoft
- * and optimized for Windows platforms.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class NTLMSchemeHC4 extends AuthSchemeBaseHC4 {
-
- enum State {
- UNINITIATED,
- CHALLENGE_RECEIVED,
- MSG_TYPE1_GENERATED,
- MSG_TYPE2_RECEVIED,
- MSG_TYPE3_GENERATED,
- FAILED,
- }
-
- private final NTLMEngine engine;
-
- private State state;
- private String challenge;
-
- public NTLMSchemeHC4(final NTLMEngine engine) {
- super();
- Args.notNull(engine, "NTLM engine");
- this.engine = engine;
- this.state = State.UNINITIATED;
- this.challenge = null;
- }
-
- /**
- * @since 4.3
- */
- public NTLMSchemeHC4() {
- this(new NTLMEngineImpl());
- }
-
- public String getSchemeName() {
- return "ntlm";
- }
-
- public String getParameter(final String name) {
- // String parameters not supported
- return null;
- }
-
- public String getRealm() {
- // NTLM does not support the concept of an authentication realm
- return null;
- }
-
- public boolean isConnectionBased() {
- return true;
- }
-
- @Override
- protected void parseChallenge(
- final CharArrayBuffer buffer,
- final int beginIndex, final int endIndex) throws MalformedChallengeException {
- this.challenge = buffer.substringTrimmed(beginIndex, endIndex);
- if (this.challenge.length() == 0) {
- if (this.state == State.UNINITIATED) {
- this.state = State.CHALLENGE_RECEIVED;
- } else {
- this.state = State.FAILED;
- }
- } else {
- if (this.state.compareTo(State.MSG_TYPE1_GENERATED) < 0) {
- this.state = State.FAILED;
- throw new MalformedChallengeException("Out of sequence NTLM response message");
- } else if (this.state == State.MSG_TYPE1_GENERATED) {
- this.state = State.MSG_TYPE2_RECEVIED;
- }
- }
- }
-
- public Header authenticate(
- final Credentials credentials,
- final HttpRequest request) throws AuthenticationException {
- NTCredentials ntcredentials = null;
- try {
- ntcredentials = (NTCredentials) credentials;
- } catch (final ClassCastException e) {
- throw new InvalidCredentialsException(
- "Credentials cannot be used for NTLM authentication: "
- + credentials.getClass().getName());
- }
- String response = null;
- if (this.state == State.FAILED) {
- throw new AuthenticationException("NTLM authentication failed");
- } else if (this.state == State.CHALLENGE_RECEIVED) {
- response = this.engine.generateType1Msg(
- ntcredentials.getDomain(),
- ntcredentials.getWorkstation());
- this.state = State.MSG_TYPE1_GENERATED;
- } else if (this.state == State.MSG_TYPE2_RECEVIED) {
- response = this.engine.generateType3Msg(
- ntcredentials.getUserName(),
- ntcredentials.getPassword(),
- ntcredentials.getDomain(),
- ntcredentials.getWorkstation(),
- this.challenge);
- this.state = State.MSG_TYPE3_GENERATED;
- } else {
- throw new AuthenticationException("Unexpected state: " + this.state);
- }
- final CharArrayBuffer buffer = new CharArrayBuffer(32);
- if (isProxy()) {
- buffer.append(AUTH.PROXY_AUTH_RESP);
- } else {
- buffer.append(AUTH.WWW_AUTH_RESP);
- }
- buffer.append(": NTLM ");
- buffer.append(response);
- return new BufferedHeader(buffer);
- }
-
- public boolean isComplete() {
- return this.state == State.MSG_TYPE3_GENERATED || this.state == State.FAILED;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/RFC2617SchemeHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/RFC2617SchemeHC4.java
deleted file mode 100644
index 4c620606..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/RFC2617SchemeHC4.java
+++ /dev/null
@@ -1,151 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.auth;
-
-import java.nio.charset.Charset;
-import java.util.HashMap;
-import java.util.Locale;
-import java.util.Map;
-
-import org.apache.http.Consts;
-import org.apache.http.HeaderElement;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.auth.ChallengeState;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.auth.params.AuthPNames;
-import org.apache.http.message.BasicHeaderValueParserHC4;
-import org.apache.http.message.HeaderValueParser;
-import org.apache.http.message.ParserCursor;
-import org.apache.http.util.CharArrayBuffer;
-
-/**
- * Abstract authentication scheme class that lays foundation for all
- * RFC 2617 compliant authentication schemes and provides capabilities common
- * to all authentication schemes defined in RFC 2617.
- *
- * @since 4.0
- */
-@SuppressWarnings("deprecation")
-@NotThreadSafe // AuthSchemeBase, params
-public abstract class RFC2617SchemeHC4 extends AuthSchemeBaseHC4 {
-
- private final Map params;
- private final Charset credentialsCharset;
-
- /**
- * Creates an instance of RFC2617Scheme with the given challenge
- * state.
- *
- * @since 4.2
- *
- * @deprecated (4.3) do not use.
- */
- @Deprecated
- public RFC2617SchemeHC4(final ChallengeState challengeState) {
- super(challengeState);
- this.params = new HashMap();
- this.credentialsCharset = Consts.ASCII;
- }
-
- /**
- * @since 4.3
- */
- public RFC2617SchemeHC4(final Charset credentialsCharset) {
- super();
- this.params = new HashMap();
- this.credentialsCharset = credentialsCharset != null ? credentialsCharset : Consts.ASCII;
- }
-
- public RFC2617SchemeHC4() {
- this(Consts.ASCII);
- }
-
-
- /**
- * @since 4.3
- */
- public Charset getCredentialsCharset() {
- return credentialsCharset;
- }
-
- String getCredentialsCharset(final HttpRequest request) {
- String charset = (String) request.getParams().getParameter(AuthPNames.CREDENTIAL_CHARSET);
- if (charset == null) {
- charset = getCredentialsCharset().name();
- }
- return charset;
- }
-
- @Override
- protected void parseChallenge(
- final CharArrayBuffer buffer, final int pos, final int len) throws MalformedChallengeException {
- final HeaderValueParser parser = BasicHeaderValueParserHC4.INSTANCE;
- final ParserCursor cursor = new ParserCursor(pos, buffer.length());
- final HeaderElement[] elements = parser.parseElements(buffer, cursor);
- if (elements.length == 0) {
- throw new MalformedChallengeException("Authentication challenge is empty");
- }
- this.params.clear();
- for (final HeaderElement element : elements) {
- this.params.put(element.getName().toLowerCase(Locale.ENGLISH), element.getValue());
- }
- }
-
- /**
- * Returns authentication parameters map. Keys in the map are lower-cased.
- *
- * @return the map of authentication parameters
- */
- protected Map getParameters() {
- return this.params;
- }
-
- /**
- * Returns authentication parameter with the given name, if available.
- *
- * @param name The name of the parameter to be returned
- *
- * @return the parameter with the given name
- */
- public String getParameter(final String name) {
- if (name == null) {
- return null;
- }
- return this.params.get(name.toLowerCase(Locale.ENGLISH));
- }
-
- /**
- * Returns authentication realm. The realm may not be null.
- *
- * @return the authentication realm
- */
- public String getRealm() {
- return getParameter("realm");
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/package-info.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/package-info.java
deleted file mode 100644
index 9e50a027..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/auth/package-info.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- * ====================================================================
- * 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
- * .
- *
- */
-
-/**
- * Default implementations of standard and common HTTP authentication
- * schemes.
- */
-package org.apache.http.impl.auth;
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java
deleted file mode 100644
index 2ce22652..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/AIMDBackoffManager.java
+++ /dev/null
@@ -1,164 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import java.util.HashMap;
-import java.util.Map;
-
-import org.apache.http.client.BackoffManager;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.pool.ConnPoolControl;
-import org.apache.http.util.Args;
-
-/**
- *
The AIMDBackoffManager applies an additive increase,
- * multiplicative decrease (AIMD) to managing a dynamic limit to
- * the number of connections allowed to a given host. You may want
- * to experiment with the settings for the cooldown periods and the
- * backoff factor to get the adaptive behavior you want.
- *
- *
Generally speaking, shorter cooldowns will lead to more steady-state
- * variability but faster reaction times, while longer cooldowns
- * will lead to more stable equilibrium behavior but slower reaction
- * times.
- *
- *
Similarly, higher backoff factors promote greater
- * utilization of available capacity at the expense of fairness
- * among clients. Lower backoff factors allow equal distribution of
- * capacity among clients (fairness) to happen faster, at the
- * expense of having more server capacity unused in the short term.
- *
- * @since 4.2
- */
-public class AIMDBackoffManager implements BackoffManager {
-
- private final ConnPoolControl connPerRoute;
- private final Clock clock;
- private final Map lastRouteProbes;
- private final Map lastRouteBackoffs;
- private long coolDown = 5 * 1000L;
- private double backoffFactor = 0.5;
- private int cap = 2; // Per RFC 2616 sec 8.1.4
-
- /**
- * Creates an AIMDBackoffManager to manage
- * per-host connection pool sizes represented by the
- * given {@link ConnPoolControl}.
- * @param connPerRoute per-host routing maximums to
- * be managed
- */
- public AIMDBackoffManager(final ConnPoolControl connPerRoute) {
- this(connPerRoute, new SystemClock());
- }
-
- AIMDBackoffManager(final ConnPoolControl connPerRoute, final Clock clock) {
- this.clock = clock;
- this.connPerRoute = connPerRoute;
- this.lastRouteProbes = new HashMap();
- this.lastRouteBackoffs = new HashMap();
- }
-
- public void backOff(final HttpRoute route) {
- synchronized(connPerRoute) {
- final int curr = connPerRoute.getMaxPerRoute(route);
- final Long lastUpdate = getLastUpdate(lastRouteBackoffs, route);
- final long now = clock.getCurrentTime();
- if (now - lastUpdate.longValue() < coolDown) {
- return;
- }
- connPerRoute.setMaxPerRoute(route, getBackedOffPoolSize(curr));
- lastRouteBackoffs.put(route, Long.valueOf(now));
- }
- }
-
- private int getBackedOffPoolSize(final int curr) {
- if (curr <= 1) {
- return 1;
- }
- return (int)(Math.floor(backoffFactor * curr));
- }
-
- public void probe(final HttpRoute route) {
- synchronized(connPerRoute) {
- final int curr = connPerRoute.getMaxPerRoute(route);
- final int max = (curr >= cap) ? cap : curr + 1;
- final Long lastProbe = getLastUpdate(lastRouteProbes, route);
- final Long lastBackoff = getLastUpdate(lastRouteBackoffs, route);
- final long now = clock.getCurrentTime();
- if (now - lastProbe.longValue() < coolDown || now - lastBackoff.longValue() < coolDown) {
- return;
- }
- connPerRoute.setMaxPerRoute(route, max);
- lastRouteProbes.put(route, Long.valueOf(now));
- }
- }
-
- private Long getLastUpdate(final Map updates, final HttpRoute route) {
- Long lastUpdate = updates.get(route);
- if (lastUpdate == null) {
- lastUpdate = Long.valueOf(0L);
- }
- return lastUpdate;
- }
-
- /**
- * Sets the factor to use when backing off; the new
- * per-host limit will be roughly the current max times
- * this factor. Math.floor is applied in the
- * case of non-integer outcomes to ensure we actually
- * decrease the pool size. Pool sizes are never decreased
- * below 1, however. Defaults to 0.5.
- * @param d must be between 0.0 and 1.0, exclusive.
- */
- public void setBackoffFactor(final double d) {
- Args.check(d > 0.0 && d < 1.0, "Backoff factor must be 0.0 < f < 1.0");
- backoffFactor = d;
- }
-
- /**
- * Sets the amount of time, in milliseconds, to wait between
- * adjustments in pool sizes for a given host, to allow
- * enough time for the adjustments to take effect. Defaults
- * to 5000L (5 seconds).
- * @param l must be positive
- */
- public void setCooldownMillis(final long l) {
- Args.positive(coolDown, "Cool down");
- coolDown = l;
- }
-
- /**
- * Sets the absolute maximum per-host connection pool size to
- * probe up to; defaults to 2 (the default per-host max).
- * @param cap must be >= 1
- */
- public void setPerHostConnectionCap(final int cap) {
- Args.positive(cap, "Per host connection cap");
- this.cap = cap;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java
deleted file mode 100644
index 0640a03a..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/AuthenticationStrategyImpl.java
+++ /dev/null
@@ -1,249 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.Queue;
-
-import android.util.Log;
-
-import org.apache.http.FormattedHeader;
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.auth.AuthOption;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.auth.MalformedChallengeException;
-import org.apache.http.client.AuthCache;
-import org.apache.http.client.AuthenticationStrategy;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.config.AuthSchemes;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.Lookup;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.CharArrayBuffer;
-
-@Immutable
-abstract class AuthenticationStrategyImpl implements AuthenticationStrategy {
-
- private final static String TAG = "HttpClient";
-
- private static final List DEFAULT_SCHEME_PRIORITY =
- Collections.unmodifiableList(Arrays.asList(AuthSchemes.SPNEGO,
- AuthSchemes.KERBEROS,
- AuthSchemes.NTLM,
- AuthSchemes.DIGEST,
- AuthSchemes.BASIC));
-
- private final int challengeCode;
- private final String headerName;
-
- AuthenticationStrategyImpl(final int challengeCode, final String headerName) {
- super();
- this.challengeCode = challengeCode;
- this.headerName = headerName;
- }
-
- public boolean isAuthenticationRequested(
- final HttpHost authhost,
- final HttpResponse response,
- final HttpContext context) {
- Args.notNull(response, "HTTP response");
- final int status = response.getStatusLine().getStatusCode();
- return status == this.challengeCode;
- }
-
- public Map getChallenges(
- final HttpHost authhost,
- final HttpResponse response,
- final HttpContext context) throws MalformedChallengeException {
- Args.notNull(response, "HTTP response");
- final Header[] headers = response.getHeaders(this.headerName);
- final Map map = new HashMap(headers.length);
- for (final Header header : headers) {
- final CharArrayBuffer buffer;
- int pos;
- if (header instanceof FormattedHeader) {
- buffer = ((FormattedHeader) header).getBuffer();
- pos = ((FormattedHeader) header).getValuePos();
- } else {
- final String s = header.getValue();
- if (s == null) {
- throw new MalformedChallengeException("Header value is null");
- }
- buffer = new CharArrayBuffer(s.length());
- buffer.append(s);
- pos = 0;
- }
- while (pos < buffer.length() && HTTP.isWhitespace(buffer.charAt(pos))) {
- pos++;
- }
- final int beginIndex = pos;
- while (pos < buffer.length() && !HTTP.isWhitespace(buffer.charAt(pos))) {
- pos++;
- }
- final int endIndex = pos;
- final String s = buffer.substring(beginIndex, endIndex);
- map.put(s.toLowerCase(Locale.ENGLISH), header);
- }
- return map;
- }
-
- abstract Collection getPreferredAuthSchemes(RequestConfig config);
-
- public Queue select(
- final Map challenges,
- final HttpHost authhost,
- final HttpResponse response,
- final HttpContext context) throws MalformedChallengeException {
- Args.notNull(challenges, "Map of auth challenges");
- Args.notNull(authhost, "Host");
- Args.notNull(response, "HTTP response");
- Args.notNull(context, "HTTP context");
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
-
- final Queue options = new LinkedList();
- final Lookup registry = clientContext.getAuthSchemeRegistry();
- if (registry == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Auth scheme registry not set in the context");
- }
- return options;
- }
- final CredentialsProvider credsProvider = clientContext.getCredentialsProvider();
- if (credsProvider == null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Credentials provider not set in the context");
- }
- return options;
- }
- final RequestConfig config = clientContext.getRequestConfig();
- Collection authPrefs = getPreferredAuthSchemes(config);
- if (authPrefs == null) {
- authPrefs = DEFAULT_SCHEME_PRIORITY;
- }
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Authentication schemes in the order of preference: " + authPrefs);
- }
-
- for (final String id: authPrefs) {
- final Header challenge = challenges.get(id.toLowerCase(Locale.ENGLISH));
- if (challenge != null) {
- final AuthSchemeProvider authSchemeProvider = registry.lookup(id);
- if (authSchemeProvider == null) {
- if (Log.isLoggable(TAG, Log.WARN)) {
- Log.w(TAG, "Authentication scheme " + id + " not supported");
- // Try again
- }
- continue;
- }
- final AuthScheme authScheme = authSchemeProvider.create(context);
- authScheme.processChallenge(challenge);
-
- final AuthScope authScope = new AuthScope(
- authhost.getHostName(),
- authhost.getPort(),
- authScheme.getRealm(),
- authScheme.getSchemeName());
-
- final Credentials credentials = credsProvider.getCredentials(authScope);
- if (credentials != null) {
- options.add(new AuthOption(authScheme, credentials));
- }
- } else {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Challenge for " + id + " authentication scheme not available");
- // Try again
- }
- }
- }
- return options;
- }
-
- public void authSucceeded(
- final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
- Args.notNull(authhost, "Host");
- Args.notNull(authScheme, "Auth scheme");
- Args.notNull(context, "HTTP context");
-
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
-
- if (isCachable(authScheme)) {
- AuthCache authCache = clientContext.getAuthCache();
- if (authCache == null) {
- authCache = new BasicAuthCache();
- clientContext.setAuthCache(authCache);
- }
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Caching '" + authScheme.getSchemeName() +
- "' auth scheme for " + authhost);
- }
- authCache.put(authhost, authScheme);
- }
- }
-
- protected boolean isCachable(final AuthScheme authScheme) {
- if (authScheme == null || !authScheme.isComplete()) {
- return false;
- }
- final String schemeName = authScheme.getSchemeName();
- return schemeName.equalsIgnoreCase(AuthSchemes.BASIC) ||
- schemeName.equalsIgnoreCase(AuthSchemes.DIGEST);
- }
-
- public void authFailed(
- final HttpHost authhost, final AuthScheme authScheme, final HttpContext context) {
- Args.notNull(authhost, "Host");
- Args.notNull(context, "HTTP context");
-
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
-
- final AuthCache authCache = clientContext.getAuthCache();
- if (authCache != null) {
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Clearing cached auth scheme for " + authhost);
- }
- authCache.remove(authhost);
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/BasicAuthCache.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
deleted file mode 100644
index bf3a2cfa..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/BasicAuthCache.java
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import java.util.HashMap;
-
-import org.apache.http.HttpHost;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.client.AuthCache;
-import org.apache.http.conn.SchemePortResolver;
-import org.apache.http.conn.UnsupportedSchemeException;
-import org.apache.http.impl.conn.DefaultSchemePortResolver;
-import org.apache.http.util.Args;
-
-/**
- * Default implementation of {@link AuthCache}.
- *
- * @since 4.0
- */
-@NotThreadSafe
-public class BasicAuthCache implements AuthCache {
-
- private final HashMap map;
- private final SchemePortResolver schemePortResolver;
-
- /**
- * Default constructor.
- *
- * @since 4.3
- */
- public BasicAuthCache(final SchemePortResolver schemePortResolver) {
- super();
- this.map = new HashMap();
- this.schemePortResolver = schemePortResolver != null ? schemePortResolver :
- DefaultSchemePortResolver.INSTANCE;
- }
-
- public BasicAuthCache() {
- this(null);
- }
-
- protected HttpHost getKey(final HttpHost host) {
- if (host.getPort() <= 0) {
- final int port;
- try {
- port = schemePortResolver.resolve(host);
- } catch (final UnsupportedSchemeException ignore) {
- return host;
- }
- return new HttpHost(host.getHostName(), port, host.getSchemeName());
- } else {
- return host;
- }
- }
-
- public void put(final HttpHost host, final AuthScheme authScheme) {
- Args.notNull(host, "HTTP host");
- this.map.put(getKey(host), authScheme);
- }
-
- public AuthScheme get(final HttpHost host) {
- Args.notNull(host, "HTTP host");
- return this.map.get(getKey(host));
- }
-
- public void remove(final HttpHost host) {
- Args.notNull(host, "HTTP host");
- this.map.remove(getKey(host));
- }
-
- public void clear() {
- this.map.clear();
- }
-
- @Override
- public String toString() {
- return this.map.toString();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/BasicCookieStoreHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/BasicCookieStoreHC4.java
deleted file mode 100644
index 9533a272..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/BasicCookieStoreHC4.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import java.io.Serializable;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.TreeSet;
-
-import org.apache.http.annotation.GuardedBy;
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.client.CookieStore;
-import org.apache.http.cookie.Cookie;
-import org.apache.http.cookie.CookieIdentityComparator;
-
-/**
- * Default implementation of {@link CookieStore}
- *
- *
- * @since 4.0
- */
-@ThreadSafe
-public class BasicCookieStoreHC4 implements CookieStore, Serializable {
-
- private static final long serialVersionUID = -7581093305228232025L;
-
- @GuardedBy("this")
- private final TreeSet cookies;
-
- public BasicCookieStoreHC4() {
- super();
- this.cookies = new TreeSet(new CookieIdentityComparator());
- }
-
- /**
- * Adds an {@link Cookie HTTP cookie}, replacing any existing equivalent cookies.
- * If the given cookie has already expired it will not be added, but existing
- * values will still be removed.
- *
- * @param cookie the {@link Cookie cookie} to be added
- *
- * @see #addCookies(Cookie[])
- *
- */
- public synchronized void addCookie(final Cookie cookie) {
- if (cookie != null) {
- // first remove any old cookie that is equivalent
- cookies.remove(cookie);
- if (!cookie.isExpired(new Date())) {
- cookies.add(cookie);
- }
- }
- }
-
- /**
- * Adds an array of {@link Cookie HTTP cookies}. Cookies are added individually and
- * in the given array order. If any of the given cookies has already expired it will
- * not be added, but existing values will still be removed.
- *
- * @param cookies the {@link Cookie cookies} to be added
- *
- * @see #addCookie(Cookie)
- *
- */
- public synchronized void addCookies(final Cookie[] cookies) {
- if (cookies != null) {
- for (final Cookie cooky : cookies) {
- this.addCookie(cooky);
- }
- }
- }
-
- /**
- * Returns an immutable array of {@link Cookie cookies} that this HTTP
- * state currently contains.
- *
- * @return an array of {@link Cookie cookies}.
- */
- public synchronized List getCookies() {
- //create defensive copy so it won't be concurrently modified
- return new ArrayList(cookies);
- }
-
- /**
- * Removes all of {@link Cookie cookies} in this HTTP state
- * that have expired by the specified {@link java.util.Date date}.
- *
- * @return true if any cookies were purged.
- *
- * @see Cookie#isExpired(Date)
- */
- public synchronized boolean clearExpired(final Date date) {
- if (date == null) {
- return false;
- }
- boolean removed = false;
- for (final Iterator it = cookies.iterator(); it.hasNext();) {
- if (it.next().isExpired(date)) {
- it.remove();
- removed = true;
- }
- }
- return removed;
- }
-
- /**
- * Clears all cookies.
- */
- public synchronized void clear() {
- cookies.clear();
- }
-
- @Override
- public synchronized String toString() {
- return cookies.toString();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/BasicCredentialsProviderHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/BasicCredentialsProviderHC4.java
deleted file mode 100644
index e65cb32e..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/BasicCredentialsProviderHC4.java
+++ /dev/null
@@ -1,109 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.Credentials;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.util.Args;
-
-/**
- * Default implementation of {@link CredentialsProvider}.
- *
- * @since 4.0
- */
-@ThreadSafe
-public class BasicCredentialsProviderHC4 implements CredentialsProvider {
-
- private final ConcurrentHashMap credMap;
-
- /**
- * Default constructor.
- */
- public BasicCredentialsProviderHC4() {
- super();
- this.credMap = new ConcurrentHashMap();
- }
-
- public void setCredentials(
- final AuthScope authscope,
- final Credentials credentials) {
- Args.notNull(authscope, "Authentication scope");
- credMap.put(authscope, credentials);
- }
-
- /**
- * Find matching {@link Credentials credentials} for the given authentication scope.
- *
- * @param map the credentials hash map
- * @param authscope the {@link AuthScope authentication scope}
- * @return the credentials
- *
- */
- private static Credentials matchCredentials(
- final Map map,
- final AuthScope authscope) {
- // see if we get a direct hit
- Credentials creds = map.get(authscope);
- if (creds == null) {
- // Nope.
- // Do a full scan
- int bestMatchFactor = -1;
- AuthScope bestMatch = null;
- for (final AuthScope current: map.keySet()) {
- final int factor = authscope.match(current);
- if (factor > bestMatchFactor) {
- bestMatchFactor = factor;
- bestMatch = current;
- }
- }
- if (bestMatch != null) {
- creds = map.get(bestMatch);
- }
- }
- return creds;
- }
-
- public Credentials getCredentials(final AuthScope authscope) {
- Args.notNull(authscope, "Authentication scope");
- return matchCredentials(this.credMap, authscope);
- }
-
- public void clear() {
- this.credMap.clear();
- }
-
- @Override
- public String toString() {
- return credMap.toString();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/BasicResponseHandlerHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/BasicResponseHandlerHC4.java
deleted file mode 100644
index 69dc9815..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/BasicResponseHandlerHC4.java
+++ /dev/null
@@ -1,73 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.io.IOException;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.StatusLine;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.client.HttpResponseException;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.util.EntityUtilsHC4;
-
-/**
- * A {@link ResponseHandler} that returns the response body as a String
- * for successful (2xx) responses. If the response code was >= 300, the response
- * body is consumed and an {@link HttpResponseException} is thrown.
- *
- * If this is used with
- * {@link org.apache.http.client.HttpClient#execute(
- * org.apache.http.client.methods.HttpUriRequest, ResponseHandler)},
- * HttpClient may handle redirects (3xx responses) internally.
- *
- * @since 4.0
- */
-@Immutable
-public class BasicResponseHandlerHC4 implements ResponseHandler {
-
- /**
- * Returns the response body as a String if the response was successful (a
- * 2xx status code). If no response body exists, this returns null. If the
- * response was unsuccessful (>= 300 status code), throws an
- * {@link HttpResponseException}.
- */
- public String handleResponse(final HttpResponse response)
- throws HttpResponseException, IOException {
- final StatusLine statusLine = response.getStatusLine();
- final HttpEntity entity = response.getEntity();
- if (statusLine.getStatusCode() >= 300) {
- EntityUtilsHC4.consume(entity);
- throw new HttpResponseException(statusLine.getStatusCode(),
- statusLine.getReasonPhrase());
- }
- return entity == null ? null : EntityUtilsHC4.toString(entity);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/Clock.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/Clock.java
deleted file mode 100644
index 012a0bec..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/Clock.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-/**
- * Interface used to enable easier testing of time-related behavior.
- *
- * @since 4.2
- *
- */
-interface Clock {
-
- /**
- * Returns the current time, expressed as the number of
- * milliseconds since the epoch.
- * @return current time
- */
- long getCurrentTime();
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java
deleted file mode 100644
index 1e06885e..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/CloseableHttpClient.java
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.lang.reflect.UndeclaredThrowableException;
-import java.net.URI;
-
-import android.util.Log;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.utils.URIUtilsHC4;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.EntityUtilsHC4;
-
-/**
- * Base implementation of {@link HttpClient} that also implements {@link Closeable}.
- *
- * @since 4.3
- */
-@ThreadSafe
-public abstract class CloseableHttpClient implements HttpClient, Closeable {
-
- private final static String TAG = "HttpClient";
-
- protected abstract CloseableHttpResponse doExecute(HttpHost target, HttpRequest request,
- HttpContext context) throws IOException, ClientProtocolException;
-
- /**
- * {@inheritDoc}
- */
- public CloseableHttpResponse execute(
- final HttpHost target,
- final HttpRequest request,
- final HttpContext context) throws IOException, ClientProtocolException {
- return doExecute(target, request, context);
- }
-
- /**
- * {@inheritDoc}
- */
- public CloseableHttpResponse execute(
- final HttpUriRequest request,
- final HttpContext context) throws IOException, ClientProtocolException {
- Args.notNull(request, "HTTP request");
- return doExecute(determineTarget(request), request, context);
- }
-
- private static HttpHost determineTarget(final HttpUriRequest request) throws ClientProtocolException {
- // A null target may be acceptable if there is a default target.
- // Otherwise, the null target is detected in the director.
- HttpHost target = null;
-
- final URI requestURI = request.getURI();
- if (requestURI.isAbsolute()) {
- target = URIUtilsHC4.extractHost(requestURI);
- if (target == null) {
- throw new ClientProtocolException("URI does not specify a valid host name: "
- + requestURI);
- }
- }
- return target;
- }
-
- /**
- * {@inheritDoc}
- */
- public CloseableHttpResponse execute(
- final HttpUriRequest request) throws IOException, ClientProtocolException {
- return execute(request, (HttpContext) null);
- }
-
- /**
- * {@inheritDoc}
- */
- public CloseableHttpResponse execute(
- final HttpHost target,
- final HttpRequest request) throws IOException, ClientProtocolException {
- return doExecute(target, request, (HttpContext) null);
- }
-
- /**
- * Executes a request using the default context and processes the
- * response using the given response handler. 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
- *
- * @return the response object as generated by the response handler.
- * @throws IOException in case of a problem or the connection was aborted
- * @throws ClientProtocolException in case of an http protocol error
- */
- public T execute(final HttpUriRequest request,
- final ResponseHandler extends T> responseHandler) throws IOException,
- ClientProtocolException {
- return execute(request, responseHandler, null);
- }
-
- /**
- * Executes a request using the default context and processes the
- * response using the given response handler. 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
- * null to use the default context
- *
- * @return the response object as generated by the response handler.
- * @throws IOException in case of a problem or the connection was aborted
- * @throws ClientProtocolException in case of an http protocol error
- */
- public T execute(final HttpUriRequest request,
- final ResponseHandler extends T> responseHandler, final HttpContext context)
- throws IOException, ClientProtocolException {
- final HttpHost target = determineTarget(request);
- return execute(target, request, responseHandler, context);
- }
-
- /**
- * Executes a request using the default context and processes the
- * response using the given response handler. 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 null
- * if they can still determine a route, for example
- * to a default target or by inspecting the request.
- * @param request the request to execute
- * @param responseHandler the response handler
- *
- * @return the response object as generated by the response handler.
- * @throws IOException in case of a problem or the connection was aborted
- * @throws ClientProtocolException in case of an http protocol error
- */
- public T execute(final HttpHost target, final HttpRequest request,
- final ResponseHandler extends T> responseHandler) throws IOException,
- ClientProtocolException {
- return execute(target, request, responseHandler, null);
- }
-
- /**
- * Executes a request using the default context and processes the
- * response using the given response handler. 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 null
- * if they can still determine a route, for example
- * to a default target or by inspecting the request.
- * @param request the request to execute
- * @param responseHandler the response handler
- * @param context the context to use for the execution, or
- * null to use the default context
- *
- * @return the response object as generated by the response handler.
- * @throws IOException in case of a problem or the connection was aborted
- * @throws ClientProtocolException in case of an http protocol error
- */
- public T execute(final HttpHost target, final HttpRequest request,
- final ResponseHandler extends T> responseHandler, final HttpContext context)
- throws IOException, ClientProtocolException {
- Args.notNull(responseHandler, "Response handler");
-
- final HttpResponse response = execute(target, request, context);
-
- final T result;
- try {
- result = responseHandler.handleResponse(response);
- } catch (final Exception t) {
- final HttpEntity entity = response.getEntity();
- try {
- EntityUtilsHC4.consume(entity);
- } catch (final Exception t2) {
- // Log this exception. The original exception is more
- // important and will be thrown to the caller.
- if (Log.isLoggable(TAG, Log.WARN)) {
- Log.w(TAG, "Error consuming content after an exception.", t2);
- }
- }
- if (t instanceof RuntimeException) {
- throw (RuntimeException) t;
- }
- if (t instanceof IOException) {
- throw (IOException) t;
- }
- throw new UndeclaredThrowableException(t);
- }
-
- // Handling the response was successful. Ensure that the content has
- // been fully consumed.
- final HttpEntity entity = response.getEntity();
- EntityUtilsHC4.consume(entity);
- return result;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/CloseableHttpResponseProxy.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/CloseableHttpResponseProxy.java
deleted file mode 100644
index 25e78263..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/CloseableHttpResponseProxy.java
+++ /dev/null
@@ -1,87 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.io.IOException;
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.util.EntityUtilsHC4;
-
-/**
- * @since 4.3
- */
-@NotThreadSafe
-class CloseableHttpResponseProxy implements InvocationHandler {
-
- private final HttpResponse original;
-
- CloseableHttpResponseProxy(final HttpResponse original) {
- super();
- this.original = original;
- }
-
- public void close() throws IOException {
- final HttpEntity entity = this.original.getEntity();
- EntityUtilsHC4.consume(entity);
- }
-
- public Object invoke(
- final Object proxy, final Method method, final Object[] args) throws Throwable {
- final String mname = method.getName();
- if (mname.equals("close")) {
- close();
- return null;
- } else {
- try {
- return method.invoke(original, args);
- } catch (final InvocationTargetException ex) {
- final Throwable cause = ex.getCause();
- if (cause != null) {
- throw cause;
- } else {
- throw ex;
- }
- }
- }
- }
-
- public static CloseableHttpResponse newProxy(final HttpResponse original) {
- return (CloseableHttpResponse) Proxy.newProxyInstance(
- CloseableHttpResponseProxy.class.getClassLoader(),
- new Class>[] { CloseableHttpResponse.class },
- new CloseableHttpResponseProxy(original));
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultBackoffStrategy.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultBackoffStrategy.java
deleted file mode 100644
index 3d79034b..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultBackoffStrategy.java
+++ /dev/null
@@ -1,54 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import java.net.ConnectException;
-import java.net.SocketTimeoutException;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.client.ConnectionBackoffStrategy;
-
-/**
- * This {@link ConnectionBackoffStrategy} backs off either for a raw
- * network socket or connection timeout or if the server explicitly
- * sends a 503 (Service Unavailable) response.
- *
- * @since 4.2
- */
-public class DefaultBackoffStrategy implements ConnectionBackoffStrategy {
-
- public boolean shouldBackoff(final Throwable t) {
- return (t instanceof SocketTimeoutException
- || t instanceof ConnectException);
- }
-
- public boolean shouldBackoff(final HttpResponse resp) {
- return (resp.getStatusLine().getStatusCode() == HttpStatus.SC_SERVICE_UNAVAILABLE);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategyHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategyHC4.java
deleted file mode 100644
index b9f47560..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultConnectionKeepAliveStrategyHC4.java
+++ /dev/null
@@ -1,71 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import org.apache.http.HeaderElement;
-import org.apache.http.HeaderElementIterator;
-import org.apache.http.HttpResponse;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.conn.ConnectionKeepAliveStrategy;
-import org.apache.http.message.BasicHeaderElementIterator;
-import org.apache.http.protocol.HTTP;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-
-/**
- * Default implementation of a strategy deciding duration
- * that a connection can remain idle.
- *
- * The default implementation looks solely at the 'Keep-Alive'
- * header's timeout token.
- *
- * @since 4.0
- */
-@Immutable
-public class DefaultConnectionKeepAliveStrategyHC4 implements ConnectionKeepAliveStrategy {
-
- public static final DefaultConnectionKeepAliveStrategyHC4 INSTANCE = new DefaultConnectionKeepAliveStrategyHC4();
-
- public long getKeepAliveDuration(final HttpResponse response, final HttpContext context) {
- Args.notNull(response, "HTTP response");
- final HeaderElementIterator it = new BasicHeaderElementIterator(
- response.headerIterator(HTTP.CONN_KEEP_ALIVE));
- while (it.hasNext()) {
- final HeaderElement he = it.nextElement();
- final String param = he.getName();
- final String value = he.getValue();
- if (value != null && param.equalsIgnoreCase("timeout")) {
- try {
- return Long.parseLong(value) * 1000;
- } catch(final NumberFormatException ignore) {
- }
- }
- }
- return -1;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandlerHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandlerHC4.java
deleted file mode 100644
index 14ffe296..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultHttpRequestRetryHandlerHC4.java
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.io.IOException;
-import java.io.InterruptedIOException;
-import java.net.ConnectException;
-import java.net.UnknownHostException;
-import java.util.Arrays;
-import java.util.Collection;
-import java.util.HashSet;
-import java.util.Set;
-
-import javax.net.ssl.SSLException;
-
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.client.HttpRequestRetryHandler;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-
-/**
- * The default {@link HttpRequestRetryHandler} used by request executors.
- *
- * @since 4.0
- */
-@Immutable
-public class DefaultHttpRequestRetryHandlerHC4 implements HttpRequestRetryHandler {
-
- public static final DefaultHttpRequestRetryHandlerHC4 INSTANCE = new DefaultHttpRequestRetryHandlerHC4();
-
- /** the number of times a method will be retried */
- private final int retryCount;
-
- /** Whether or not methods that have successfully sent their request will be retried */
- private final boolean requestSentRetryEnabled;
-
- private final Set> nonRetriableClasses;
-
- /**
- * Create the request retry handler using the specified IOException classes
- *
- * @param retryCount how many times to retry; 0 means no retries
- * @param requestSentRetryEnabled true if it's OK to retry requests that have been sent
- * @param clazzes the IOException types that should not be retried
- * @since 4.3
- */
- protected DefaultHttpRequestRetryHandlerHC4(
- final int retryCount,
- final boolean requestSentRetryEnabled,
- final Collection> clazzes) {
- super();
- this.retryCount = retryCount;
- this.requestSentRetryEnabled = requestSentRetryEnabled;
- this.nonRetriableClasses = new HashSet>();
- for (final Class extends IOException> clazz: clazzes) {
- this.nonRetriableClasses.add(clazz);
- }
- }
-
- /**
- * Create the request retry handler using the following list of
- * non-retriable IOException classes:
- *
- *
InterruptedIOException
- *
UnknownHostException
- *
ConnectException
- *
SSLException
- *
- * @param retryCount how many times to retry; 0 means no retries
- * @param requestSentRetryEnabled true if it's OK to retry requests that have been sent
- */
- @SuppressWarnings("unchecked")
- public DefaultHttpRequestRetryHandlerHC4(final int retryCount, final boolean requestSentRetryEnabled) {
- this(retryCount, requestSentRetryEnabled, Arrays.asList(
- InterruptedIOException.class,
- UnknownHostException.class,
- ConnectException.class,
- SSLException.class));
- }
-
- /**
- * Create the request retry handler with a retry count of 3, requestSentRetryEnabled false
- * and using the following list of non-retriable IOException classes:
- *
- *
InterruptedIOException
- *
UnknownHostException
- *
ConnectException
- *
SSLException
- *
- */
- public DefaultHttpRequestRetryHandlerHC4() {
- this(3, false);
- }
- /**
- * Used retryCount and requestSentRetryEnabled to determine
- * if the given method should be retried.
- */
- public boolean retryRequest(
- final IOException exception,
- final int executionCount,
- final HttpContext context) {
- Args.notNull(exception, "Exception parameter");
- Args.notNull(context, "HTTP context");
- if (executionCount > this.retryCount) {
- // Do not retry if over max retry count
- return false;
- }
- if (this.nonRetriableClasses.contains(exception.getClass())) {
- return false;
- } else {
- for (final Class extends IOException> rejectException : this.nonRetriableClasses) {
- if (rejectException.isInstance(exception)) {
- return false;
- }
- }
- }
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
- final HttpRequest request = clientContext.getRequest();
-
- if(requestIsAborted(request)){
- return false;
- }
-
- if (handleAsIdempotent(request)) {
- // Retry if the request is considered idempotent
- return true;
- }
-
- if (!clientContext.isRequestSent() || this.requestSentRetryEnabled) {
- // Retry if the request has not been sent fully or
- // if it's OK to retry methods that have been sent
- return true;
- }
- // otherwise do not retry
- return false;
- }
-
- /**
- * @return true if this handler will retry methods that have
- * successfully sent their request, false otherwise
- */
- public boolean isRequestSentRetryEnabled() {
- return requestSentRetryEnabled;
- }
-
- /**
- * @return the maximum number of times a method will be retried
- */
- public int getRetryCount() {
- return retryCount;
- }
-
- /**
- * @since 4.2
- */
- protected boolean handleAsIdempotent(final HttpRequest request) {
- return !(request instanceof HttpEntityEnclosingRequest);
- }
-
- /**
- * @since 4.2
- *
- * @deprecated (4.3)
- */
- @Deprecated
- protected boolean requestIsAborted(final HttpRequest request) {
- HttpRequest req = request;
- if (request instanceof RequestWrapper) { // does not forward request to original
- req = ((RequestWrapper) request).getOriginal();
- }
- return (req instanceof HttpUriRequest && ((HttpUriRequest)req).isAborted());
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
deleted file mode 100644
index 4cd2fb70..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultRedirectStrategy.java
+++ /dev/null
@@ -1,233 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.net.URI;
-import java.net.URISyntaxException;
-import java.util.Locale;
-
-import android.util.Log;
-
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.ProtocolException;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.client.CircularRedirectException;
-import org.apache.http.client.RedirectStrategy;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.HttpGetHC4;
-import org.apache.http.client.methods.HttpHeadHC4;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.client.methods.RequestBuilder;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.client.utils.URIBuilder;
-import org.apache.http.client.utils.URIUtilsHC4;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-import org.apache.http.util.Asserts;
-import org.apache.http.util.TextUtils;
-
-/**
- * Default implementation of {@link RedirectStrategy}. This strategy honors the restrictions
- * on automatic redirection of entity enclosing methods such as POST and PUT imposed by the
- * HTTP specification. 302 Moved Temporarily, 301 Moved Permanently and
- * 307 Temporary Redirect status codes will result in an automatic redirect of
- * HEAD and GET methods only. POST and PUT methods will not be automatically redirected
- * as requiring user confirmation.
- *
- * The restriction on automatic redirection of POST methods can be relaxed by using
- * {@link LaxRedirectStrategy} instead of {@link DefaultRedirectStrategy}.
- *
- * @see LaxRedirectStrategy
- * @since 4.1
- */
-@Immutable
-public class DefaultRedirectStrategy implements RedirectStrategy {
-
- private final static String TAG = "HttpClient";
-
- /**
- * @deprecated (4.3) use {@link org.apache.http.client.protocol.HttpClientContext#REDIRECT_LOCATIONS}.
- */
- @Deprecated
- public static final String REDIRECT_LOCATIONS = "http.protocol.redirect-locations";
-
- public static final DefaultRedirectStrategy INSTANCE = new DefaultRedirectStrategy();
-
- /**
- * Redirectable methods.
- */
- private static final String[] REDIRECT_METHODS = new String[] {
- HttpGetHC4.METHOD_NAME,
- HttpHeadHC4.METHOD_NAME
- };
-
- public DefaultRedirectStrategy() {
- super();
- }
-
- public boolean isRedirected(
- final HttpRequest request,
- final HttpResponse response,
- final HttpContext context) throws ProtocolException {
- Args.notNull(request, "HTTP request");
- Args.notNull(response, "HTTP response");
-
- final int statusCode = response.getStatusLine().getStatusCode();
- final String method = request.getRequestLine().getMethod();
- final Header locationHeader = response.getFirstHeader("location");
- switch (statusCode) {
- case HttpStatus.SC_MOVED_TEMPORARILY:
- return isRedirectable(method) && locationHeader != null;
- case HttpStatus.SC_MOVED_PERMANENTLY:
- case HttpStatus.SC_TEMPORARY_REDIRECT:
- return isRedirectable(method);
- case HttpStatus.SC_SEE_OTHER:
- return true;
- default:
- return false;
- } //end of switch
- }
-
- public URI getLocationURI(
- final HttpRequest request,
- final HttpResponse response,
- final HttpContext context) throws ProtocolException {
- Args.notNull(request, "HTTP request");
- Args.notNull(response, "HTTP response");
- Args.notNull(context, "HTTP context");
-
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
-
- //get the location header to find out where to redirect to
- final Header locationHeader = response.getFirstHeader("location");
- if (locationHeader == null) {
- // got a redirect response, but no location header
- throw new ProtocolException(
- "Received redirect response " + response.getStatusLine()
- + " but no location header");
- }
- final String location = locationHeader.getValue();
- if (Log.isLoggable(TAG, Log.DEBUG)) {
- Log.d(TAG, "Redirect requested to location '" + location + "'");
- }
-
- final RequestConfig config = clientContext.getRequestConfig();
-
- URI uri = createLocationURI(location);
-
- // rfc2616 demands the location value be a complete URI
- // Location = "Location" ":" absoluteURI
- try {
- if (!uri.isAbsolute()) {
- if (!config.isRelativeRedirectsAllowed()) {
- throw new ProtocolException("Relative redirect location '"
- + uri + "' not allowed");
- }
- // Adjust location URI
- final HttpHost target = clientContext.getTargetHost();
- Asserts.notNull(target, "Target host");
- final URI requestURI = new URI(request.getRequestLine().getUri());
- final URI absoluteRequestURI = URIUtilsHC4.rewriteURI(requestURI, target, false);
- uri = URIUtilsHC4.resolve(absoluteRequestURI, uri);
- }
- } catch (final URISyntaxException ex) {
- throw new ProtocolException(ex.getMessage(), ex);
- }
-
- RedirectLocationsHC4 redirectLocations = (RedirectLocationsHC4) clientContext.getAttribute(
- HttpClientContext.REDIRECT_LOCATIONS);
- if (redirectLocations == null) {
- redirectLocations = new RedirectLocationsHC4();
- context.setAttribute(HttpClientContext.REDIRECT_LOCATIONS, redirectLocations);
- }
- if (!config.isCircularRedirectsAllowed()) {
- if (redirectLocations.contains(uri)) {
- throw new CircularRedirectException("Circular redirect to '" + uri + "'");
- }
- }
- redirectLocations.add(uri);
- return uri;
- }
-
- /**
- * @since 4.1
- */
- protected URI createLocationURI(final String location) throws ProtocolException {
- try {
- final URIBuilder b = new URIBuilder(new URI(location).normalize());
- final String host = b.getHost();
- if (host != null) {
- b.setHost(host.toLowerCase(Locale.ENGLISH));
- }
- final String path = b.getPath();
- if (TextUtils.isEmpty(path)) {
- b.setPath("/");
- }
- return b.build();
- } catch (final URISyntaxException ex) {
- throw new ProtocolException("Invalid redirect URI: " + location, ex);
- }
- }
-
- /**
- * @since 4.2
- */
- protected boolean isRedirectable(final String method) {
- for (final String m: REDIRECT_METHODS) {
- if (m.equalsIgnoreCase(method)) {
- return true;
- }
- }
- return false;
- }
-
- public HttpUriRequest getRedirect(
- final HttpRequest request,
- final HttpResponse response,
- final HttpContext context) throws ProtocolException {
- final URI uri = getLocationURI(request, response, context);
- final String method = request.getRequestLine().getMethod();
- if (method.equalsIgnoreCase(HttpHeadHC4.METHOD_NAME)) {
- return new HttpHeadHC4(uri);
- } else if (method.equalsIgnoreCase(HttpGetHC4.METHOD_NAME)) {
- return new HttpGetHC4(uri);
- } else {
- final int status = response.getStatusLine().getStatusCode();
- if (status == HttpStatus.SC_TEMPORARY_REDIRECT) {
- return RequestBuilder.copy(request).setUri(uri).build();
- } else {
- return new HttpGetHC4(uri);
- }
- }
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java
deleted file mode 100644
index b5d76ea5..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultServiceUnavailableRetryStrategy.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpStatus;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.client.ServiceUnavailableRetryStrategy;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-
-/**
- * Default implementation of the {@link ServiceUnavailableRetryStrategy} interface.
- * that retries 503 (Service Unavailable) responses for a fixed number of times
- * at a fixed interval.
- *
- * @since 4.2
- */
-@Immutable
-public class DefaultServiceUnavailableRetryStrategy implements ServiceUnavailableRetryStrategy {
-
- /**
- * Maximum number of allowed retries if the server responds with a HTTP code
- * in our retry code list. Default value is 1.
- */
- private final int maxRetries;
-
- /**
- * Retry interval between subsequent requests, in milliseconds. Default
- * value is 1 second.
- */
- private final long retryInterval;
-
- public DefaultServiceUnavailableRetryStrategy(final int maxRetries, final int retryInterval) {
- super();
- Args.positive(maxRetries, "Max retries");
- Args.positive(retryInterval, "Retry interval");
- this.maxRetries = maxRetries;
- this.retryInterval = retryInterval;
- }
-
- public DefaultServiceUnavailableRetryStrategy() {
- this(1, 1000);
- }
-
- public boolean retryRequest(final HttpResponse response, final int executionCount, final HttpContext context) {
- return executionCount <= maxRetries &&
- response.getStatusLine().getStatusCode() == HttpStatus.SC_SERVICE_UNAVAILABLE;
- }
-
- public long getRetryInterval() {
- return retryInterval;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandlerHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandlerHC4.java
deleted file mode 100644
index 299f2592..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/DefaultUserTokenHandlerHC4.java
+++ /dev/null
@@ -1,101 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import java.security.Principal;
-
-import javax.net.ssl.SSLSession;
-
-import org.apache.http.HttpConnection;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.auth.AuthScheme;
-import org.apache.http.auth.AuthStateHC4;
-import org.apache.http.auth.Credentials;
-import org.apache.http.client.UserTokenHandler;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.conn.ManagedHttpClientConnection;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * Default implementation of {@link UserTokenHandler}. This class will use
- * an instance of {@link Principal} as a state object for HTTP connections,
- * if it can be obtained from the given execution context. This helps ensure
- * persistent connections created with a particular user identity within
- * a particular security context can be reused by the same user only.
- *
- * DefaultUserTokenHandlerHC4 will use the user principle of connection
- * based authentication schemes such as NTLM or that of the SSL session
- * with the client authentication turned on. If both are unavailable,
- * null token will be returned.
- *
- * @since 4.0
- */
-@Immutable
-public class DefaultUserTokenHandlerHC4 implements UserTokenHandler {
-
- public static final DefaultUserTokenHandlerHC4 INSTANCE = new DefaultUserTokenHandlerHC4();
-
- public Object getUserToken(final HttpContext context) {
-
- final HttpClientContext clientContext = HttpClientContext.adapt(context);
-
- Principal userPrincipal = null;
-
- final AuthStateHC4 targetAuthState = clientContext.getTargetAuthState();
- if (targetAuthState != null) {
- userPrincipal = getAuthPrincipal(targetAuthState);
- if (userPrincipal == null) {
- final AuthStateHC4 proxyAuthState = clientContext.getProxyAuthState();
- userPrincipal = getAuthPrincipal(proxyAuthState);
- }
- }
-
- if (userPrincipal == null) {
- final HttpConnection conn = clientContext.getConnection();
- if (conn.isOpen() && conn instanceof ManagedHttpClientConnection) {
- final SSLSession sslsession = ((ManagedHttpClientConnection) conn).getSSLSession();
- if (sslsession != null) {
- userPrincipal = sslsession.getLocalPrincipal();
- }
- }
- }
-
- return userPrincipal;
- }
-
- private static Principal getAuthPrincipal(final AuthStateHC4 authState) {
- final AuthScheme scheme = authState.getAuthScheme();
- if (scheme != null && scheme.isComplete() && scheme.isConnectionBased()) {
- final Credentials creds = authState.getCredentials();
- if (creds != null) {
- return creds.getUserPrincipal();
- }
- }
- return null;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapperHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapperHC4.java
deleted file mode 100644
index a17dcabf..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/EntityEnclosingRequestWrapperHC4.java
+++ /dev/null
@@ -1,113 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.apache.http.Header;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpEntityEnclosingRequest;
-import org.apache.http.ProtocolException;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.entity.HttpEntityWrapperHC4;
-import org.apache.http.protocol.HTTP;
-
-/**
- * A wrapper class for {@link HttpEntityEnclosingRequest}s that can
- * be used to change properties of the current request without
- * modifying the original object.
- *
- * This class is also capable of resetting the request headers to
- * the state of the original request.
- *
- * @since 4.0
- *
- * @deprecated (4.3) do not use.
- */
-@Deprecated
-@NotThreadSafe // e.g. [gs]etEntity()
-public class EntityEnclosingRequestWrapperHC4 extends RequestWrapper
- implements HttpEntityEnclosingRequest {
-
- private HttpEntity entity;
- private boolean consumed;
-
- public EntityEnclosingRequestWrapperHC4(final HttpEntityEnclosingRequest request)
- throws ProtocolException {
- super(request);
- setEntity(request.getEntity());
- }
-
- public HttpEntity getEntity() {
- return this.entity;
- }
-
- public void setEntity(final HttpEntity entity) {
- this.entity = entity != null ? new EntityWrapper(entity) : null;
- this.consumed = false;
- }
-
- public boolean expectContinue() {
- final Header expect = getFirstHeader(HTTP.EXPECT_DIRECTIVE);
- return expect != null && HTTP.EXPECT_CONTINUE.equalsIgnoreCase(expect.getValue());
- }
-
- @Override
- public boolean isRepeatable() {
- return this.entity == null || this.entity.isRepeatable() || !this.consumed;
- }
-
- class EntityWrapper extends HttpEntityWrapperHC4 {
-
- EntityWrapper(final HttpEntity entity) {
- super(entity);
- }
-
- @Override
- public void consumeContent() throws IOException {
- consumed = true;
- super.consumeContent();
- }
-
- @Override
- public InputStream getContent() throws IOException {
- consumed = true;
- return super.getContent();
- }
-
- @Override
- public void writeTo(final OutputStream outstream) throws IOException {
- consumed = true;
- super.writeTo(outstream);
- }
-
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/FutureRequestExecutionMetrics.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/FutureRequestExecutionMetrics.java
deleted file mode 100644
index 6428e388..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/FutureRequestExecutionMetrics.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * Collection of different counters used to gather metrics for {@link FutureRequestExecutionService}.
- */
-public final class FutureRequestExecutionMetrics {
-
- private final AtomicLong activeConnections = new AtomicLong();
- private final AtomicLong scheduledConnections = new AtomicLong();
- private final DurationCounter successfulConnections = new DurationCounter();
- private final DurationCounter failedConnections = new DurationCounter();
- private final DurationCounter requests = new DurationCounter();
- private final DurationCounter tasks = new DurationCounter();
-
- FutureRequestExecutionMetrics() {
- }
-
- AtomicLong getActiveConnections() {
- return activeConnections;
- }
-
- AtomicLong getScheduledConnections() {
- return scheduledConnections;
- }
-
- DurationCounter getSuccessfulConnections() {
- return successfulConnections;
- }
-
- DurationCounter getFailedConnections() {
- return failedConnections;
- }
-
- DurationCounter getRequests() {
- return requests;
- }
-
- DurationCounter getTasks() {
- return tasks;
- }
-
- public long getActiveConnectionCount() {
- return activeConnections.get();
- }
-
- public long getScheduledConnectionCount() {
- return scheduledConnections.get();
- }
-
- public long getSuccessfulConnectionCount() {
- return successfulConnections.count();
- }
-
- public long getSuccessfulConnectionAverageDuration() {
- return successfulConnections.averageDuration();
- }
-
- public long getFailedConnectionCount() {
- return failedConnections.count();
- }
-
- public long getFailedConnectionAverageDuration() {
- return failedConnections.averageDuration();
- }
-
- public long getRequestCount() {
- return requests.count();
- }
-
- public long getRequestAverageDuration() {
- return requests.averageDuration();
- }
-
- public long getTaskCount() {
- return tasks.count();
- }
-
- public long getTaskAverageDuration() {
- return tasks.averageDuration();
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("[activeConnections=").append(activeConnections)
- .append(", scheduledConnections=").append(scheduledConnections)
- .append(", successfulConnections=").append(successfulConnections)
- .append(", failedConnections=").append(failedConnections)
- .append(", requests=").append(requests)
- .append(", tasks=").append(tasks)
- .append("]");
- return builder.toString();
- }
-
- /**
- * A counter that can measure duration and number of events.
- */
- static class DurationCounter {
-
- private final AtomicLong count = new AtomicLong(0);
- private final AtomicLong cumulativeDuration = new AtomicLong(0);
-
- public void increment(final long startTime) {
- count.incrementAndGet();
- cumulativeDuration.addAndGet(System.currentTimeMillis() - startTime);
- }
-
- public long count() {
- return count.get();
- }
-
- public long averageDuration() {
- final long counter = count.get();
- return counter > 0 ? cumulativeDuration.get() / counter : 0;
- }
-
- @Override
- public String toString() {
- final StringBuilder builder = new StringBuilder();
- builder.append("[count=").append(count())
- .append(", averageDuration=").append(averageDuration())
- .append("]");
- return builder.toString();
- }
-
- }
-
-}
\ No newline at end of file
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java
deleted file mode 100644
index 8e03fa3b..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/FutureRequestExecutionService.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.concurrent.FutureCallback;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * HttpAsyncClientWithFuture wraps calls to execute with a {@link HttpRequestFutureTask}
- * and schedules them using the provided executor service. Scheduled calls may be cancelled.
- */
-@ThreadSafe
-public class FutureRequestExecutionService implements Closeable {
-
- private final HttpClient httpclient;
- private final ExecutorService executorService;
- private final FutureRequestExecutionMetrics metrics = new FutureRequestExecutionMetrics();
- private final AtomicBoolean closed = new AtomicBoolean(false);
-
- /**
- * Create a new FutureRequestExecutionService.
- *
- * @param httpclient
- * you should tune your httpclient instance to match your needs. You should
- * align the max number of connections in the pool and the number of threads
- * in the executor; it doesn't make sense to have more threads than connections
- * and if you have less connections than threads, the threads will just end up
- * blocking on getting a connection from the pool.
- * @param executorService
- * any executorService will do here. E.g.
- * {@link java.util.concurrent.Executors#newFixedThreadPool(int)}
- */
- public FutureRequestExecutionService(
- final HttpClient httpclient,
- final ExecutorService executorService) {
- this.httpclient = httpclient;
- this.executorService = executorService;
- }
-
- /**
- * Schedule a request for execution.
- *
- * @param
- *
- * @param request
- * request to execute
- * @param responseHandler
- * handler that will process the response.
- * @return HttpAsyncClientFutureTask for the scheduled request.
- * @throws InterruptedException
- */
- public HttpRequestFutureTask execute(
- final HttpUriRequest request,
- final HttpContext context,
- final ResponseHandler responseHandler) {
- return execute(request, context, responseHandler, null);
- }
-
- /**
- * Schedule a request for execution.
- *
- * @param
- *
- * @param request
- * request to execute
- * @param context
- * optional context; use null if not needed.
- * @param responseHandler
- * handler that will process the response.
- * @param callback
- * callback handler that will be called when the request is scheduled,
- * started, completed, failed, or cancelled.
- * @return HttpAsyncClientFutureTask for the scheduled request.
- * @throws InterruptedException
- */
- public HttpRequestFutureTask execute(
- final HttpUriRequest request,
- final HttpContext context,
- final ResponseHandler responseHandler,
- final FutureCallback callback) {
- if(closed.get()) {
- throw new IllegalStateException("Close has been called on this httpclient instance.");
- }
- metrics.getScheduledConnections().incrementAndGet();
- final HttpRequestTaskCallable callable = new HttpRequestTaskCallable(
- httpclient, request, context, responseHandler, callback, metrics);
- final HttpRequestFutureTask httpRequestFutureTask = new HttpRequestFutureTask(
- request, callable);
- executorService.execute(httpRequestFutureTask);
-
- return httpRequestFutureTask;
- }
-
- /**
- * @return metrics gathered for this instance.
- * @see FutureRequestExecutionMetrics
- */
- public FutureRequestExecutionMetrics metrics() {
- return metrics;
- }
-
- public void close() throws IOException {
- closed.set(true);
- executorService.shutdownNow();
- if (httpclient instanceof Closeable) {
- ((Closeable) httpclient).close();
- }
- }
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
deleted file mode 100644
index 94d9df59..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/HttpClientBuilder.java
+++ /dev/null
@@ -1,951 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import android.net.SSLCertificateSocketFactory;
-
-import java.io.Closeable;
-import java.net.ProxySelector;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.List;
-
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
-
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.Header;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponseInterceptor;
-import org.apache.http.annotation.NotThreadSafe;
-import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.client.AuthenticationStrategy;
-import org.apache.http.client.BackoffManager;
-import org.apache.http.client.ConnectionBackoffStrategy;
-import org.apache.http.client.CookieStore;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.HttpRequestRetryHandler;
-import org.apache.http.client.RedirectStrategy;
-import org.apache.http.client.ServiceUnavailableRetryStrategy;
-import org.apache.http.client.UserTokenHandler;
-import org.apache.http.client.config.AuthSchemes;
-import org.apache.http.client.config.CookieSpecs;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.protocol.RequestAcceptEncoding;
-import org.apache.http.client.protocol.RequestAddCookiesHC4;
-import org.apache.http.client.protocol.RequestAuthCache;
-import org.apache.http.client.protocol.RequestClientConnControl;
-import org.apache.http.client.protocol.RequestDefaultHeadersHC4;
-import org.apache.http.client.protocol.RequestExpectContinue;
-import org.apache.http.client.protocol.ResponseContentEncoding;
-import org.apache.http.client.protocol.ResponseProcessCookiesHC4;
-import org.apache.http.config.ConnectionConfig;
-import org.apache.http.config.Lookup;
-import org.apache.http.config.RegistryBuilder;
-import org.apache.http.config.SocketConfig;
-import org.apache.http.conn.ConnectionKeepAliveStrategy;
-import org.apache.http.conn.HttpClientConnectionManager;
-import org.apache.http.conn.SchemePortResolver;
-import org.apache.http.conn.routing.HttpRoutePlanner;
-import org.apache.http.conn.socket.ConnectionSocketFactory;
-import org.apache.http.conn.socket.LayeredConnectionSocketFactory;
-import org.apache.http.conn.socket.PlainConnectionSocketFactory;
-import org.apache.http.conn.ssl.SSLConnectionSocketFactory;
-import org.apache.http.conn.ssl.X509HostnameVerifier;
-import org.apache.http.cookie.CookieSpecProvider;
-import org.apache.http.impl.DefaultConnectionReuseStrategyHC4;
-import org.apache.http.impl.NoConnectionReuseStrategyHC4;
-import org.apache.http.impl.auth.BasicSchemeFactoryHC4;
-import org.apache.http.impl.auth.DigestSchemeFactoryHC4;
-import org.apache.http.impl.auth.NTLMSchemeFactory;
-import org.apache.http.impl.conn.DefaultProxyRoutePlanner;
-import org.apache.http.impl.conn.DefaultRoutePlanner;
-import org.apache.http.impl.conn.DefaultSchemePortResolver;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-import org.apache.http.impl.conn.SystemDefaultRoutePlanner;
-import org.apache.http.impl.cookie.BestMatchSpecFactoryHC4;
-import org.apache.http.impl.cookie.BrowserCompatSpecFactoryHC4;
-import org.apache.http.impl.cookie.IgnoreSpecFactory;
-import org.apache.http.impl.cookie.NetscapeDraftSpecFactoryHC4;
-import org.apache.http.impl.cookie.RFC2109SpecFactoryHC4;
-import org.apache.http.impl.cookie.RFC2965SpecFactoryHC4;
-import org.apache.http.impl.execchain.BackoffStrategyExec;
-import org.apache.http.impl.execchain.ClientExecChain;
-import org.apache.http.impl.execchain.MainClientExec;
-import org.apache.http.impl.execchain.ProtocolExec;
-import org.apache.http.impl.execchain.RedirectExec;
-import org.apache.http.impl.execchain.RetryExec;
-import org.apache.http.impl.execchain.ServiceUnavailableRetryExec;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpProcessorBuilder;
-import org.apache.http.protocol.HttpRequestExecutor;
-import org.apache.http.protocol.RequestContentHC4;
-import org.apache.http.protocol.RequestTargetHostHC4;
-import org.apache.http.protocol.RequestUserAgentHC4;
-import org.apache.http.util.TextUtils;
-import org.apache.http.util.VersionInfoHC4;
-
-/**
- * Builder for {@link CloseableHttpClient} instances.
- *
- * When a particular component is not explicitly this class will
- * use its default implementation. System properties will be taken
- * into account when configuring the default implementations when
- * {@link #useSystemProperties()} method is called prior to calling
- * {@link #build()}.
- *
- *
ssl.TrustManagerFactory.algorithm
- *
javax.net.ssl.trustStoreType
- *
javax.net.ssl.trustStore
- *
javax.net.ssl.trustStoreProvider
- *
javax.net.ssl.trustStorePassword
- *
ssl.KeyManagerFactory.algorithm
- *
javax.net.ssl.keyStoreType
- *
javax.net.ssl.keyStore
- *
javax.net.ssl.keyStoreProvider
- *
javax.net.ssl.keyStorePassword
- *
https.protocols
- *
https.cipherSuites
- *
http.proxyHost
- *
http.proxyPort
- *
http.nonProxyHosts
- *
http.keepAlive
- *
http.maxConnections
- *
http.agent
- *
- *
- * Please note that some settings used by this class can be mutually
- * exclusive and may not apply when building {@link CloseableHttpClient}
- * instances.
- *
- * @since 4.3
- */
-@NotThreadSafe
-public class HttpClientBuilder {
-
- private HttpRequestExecutor requestExec;
- private X509HostnameVerifier hostnameVerifier;
- private LayeredConnectionSocketFactory sslSocketFactory;
- private SSLContext sslcontext;
- private HttpClientConnectionManager connManager;
- private SchemePortResolver schemePortResolver;
- private ConnectionReuseStrategy reuseStrategy;
- private ConnectionKeepAliveStrategy keepAliveStrategy;
- private AuthenticationStrategy targetAuthStrategy;
- private AuthenticationStrategy proxyAuthStrategy;
- private UserTokenHandler userTokenHandler;
- private HttpProcessor httpprocessor;
-
- private LinkedList requestFirst;
- private LinkedList requestLast;
- private LinkedList responseFirst;
- private LinkedList responseLast;
-
- private HttpRequestRetryHandler retryHandler;
- private HttpRoutePlanner routePlanner;
- private RedirectStrategy redirectStrategy;
- private ConnectionBackoffStrategy connectionBackoffStrategy;
- private BackoffManager backoffManager;
- private ServiceUnavailableRetryStrategy serviceUnavailStrategy;
- private Lookup authSchemeRegistry;
- private Lookup cookieSpecRegistry;
- private CookieStore cookieStore;
- private CredentialsProvider credentialsProvider;
- private String userAgent;
- private HttpHost proxy;
- private Collection extends Header> defaultHeaders;
- private SocketConfig defaultSocketConfig;
- private ConnectionConfig defaultConnectionConfig;
- private RequestConfig defaultRequestConfig;
-
- private boolean systemProperties;
- private boolean redirectHandlingDisabled;
- private boolean automaticRetriesDisabled;
- private boolean contentCompressionDisabled;
- private boolean cookieManagementDisabled;
- private boolean authCachingDisabled;
- private boolean connectionStateDisabled;
-
- private int maxConnTotal = 0;
- private int maxConnPerRoute = 0;
-
- private List closeables;
-
- static final String DEFAULT_USER_AGENT;
- static {
- final VersionInfoHC4 vi = VersionInfoHC4.loadVersionInfo
- ("org.apache.http.client", HttpClientBuilder.class.getClassLoader());
- final String release = (vi != null) ?
- vi.getRelease() : VersionInfoHC4.UNAVAILABLE;
- DEFAULT_USER_AGENT = "Apache-HttpClient/" + release + " (java 1.5)";
- }
-
- public static HttpClientBuilder create() {
- return new HttpClientBuilder();
- }
-
- protected HttpClientBuilder() {
- super();
- }
-
- /**
- * Assigns {@link HttpRequestExecutor} instance.
- */
- public final HttpClientBuilder setRequestExecutor(final HttpRequestExecutor requestExec) {
- this.requestExec = requestExec;
- return this;
- }
-
- /**
- * Assigns {@link X509HostnameVerifier} instance.
- *
- * Please note this value can be overridden by the {@link #setConnectionManager(
- * org.apache.http.conn.HttpClientConnectionManager)} and the {@link #setSSLSocketFactory(
- * org.apache.http.conn.socket.LayeredConnectionSocketFactory)} methods.
- */
- public final HttpClientBuilder setHostnameVerifier(final X509HostnameVerifier hostnameVerifier) {
- this.hostnameVerifier = hostnameVerifier;
- return this;
- }
-
- /**
- * Assigns {@link SSLContext} instance.
- *
- *
- * Please note this value can be overridden by the {@link #setConnectionManager(
- * org.apache.http.conn.HttpClientConnectionManager)} and the {@link #setSSLSocketFactory(
- * org.apache.http.conn.socket.LayeredConnectionSocketFactory)} methods.
- */
- public final HttpClientBuilder setSslcontext(final SSLContext sslcontext) {
- this.sslcontext = sslcontext;
- return this;
- }
-
- /**
- * Assigns {@link LayeredConnectionSocketFactory} instance.
- *
- * Please note this value can be overridden by the {@link #setConnectionManager(
- * org.apache.http.conn.HttpClientConnectionManager)} method.
- */
- public final HttpClientBuilder setSSLSocketFactory(
- final LayeredConnectionSocketFactory sslSocketFactory) {
- this.sslSocketFactory = sslSocketFactory;
- return this;
- }
-
- /**
- * Assigns maximum total connection value.
- *
- * Please note this value can be overridden by the {@link #setConnectionManager(
- * org.apache.http.conn.HttpClientConnectionManager)} method.
- */
- public final HttpClientBuilder setMaxConnTotal(final int maxConnTotal) {
- this.maxConnTotal = maxConnTotal;
- return this;
- }
-
- /**
- * Assigns maximum connection per route value.
- *
- * Please note this value can be overridden by the {@link #setConnectionManager(
- * org.apache.http.conn.HttpClientConnectionManager)} method.
- */
- public final HttpClientBuilder setMaxConnPerRoute(final int maxConnPerRoute) {
- this.maxConnPerRoute = maxConnPerRoute;
- return this;
- }
-
- /**
- * Assigns default {@link SocketConfig}.
- *
- * Please note this value can be overridden by the {@link #setConnectionManager(
- * org.apache.http.conn.HttpClientConnectionManager)} method.
- */
- public final HttpClientBuilder setDefaultSocketConfig(final SocketConfig config) {
- this.defaultSocketConfig = config;
- return this;
- }
-
- /**
- * Assigns default {@link ConnectionConfig}.
- *
- * Please note this value can be overridden by the {@link #setConnectionManager(
- * org.apache.http.conn.HttpClientConnectionManager)} method.
- */
- public final HttpClientBuilder setDefaultConnectionConfig(final ConnectionConfig config) {
- this.defaultConnectionConfig = config;
- return this;
- }
-
- /**
- * Assigns {@link HttpClientConnectionManager} instance.
- */
- public final HttpClientBuilder setConnectionManager(
- final HttpClientConnectionManager connManager) {
- this.connManager = connManager;
- return this;
- }
-
- /**
- * Assigns {@link ConnectionReuseStrategy} instance.
- */
- public final HttpClientBuilder setConnectionReuseStrategy(
- final ConnectionReuseStrategy reuseStrategy) {
- this.reuseStrategy = reuseStrategy;
- return this;
- }
-
- /**
- * Assigns {@link ConnectionKeepAliveStrategy} instance.
- */
- public final HttpClientBuilder setKeepAliveStrategy(
- final ConnectionKeepAliveStrategy keepAliveStrategy) {
- this.keepAliveStrategy = keepAliveStrategy;
- return this;
- }
-
- /**
- * Assigns {@link AuthenticationStrategy} instance for proxy
- * authentication.
- */
- public final HttpClientBuilder setTargetAuthenticationStrategy(
- final AuthenticationStrategy targetAuthStrategy) {
- this.targetAuthStrategy = targetAuthStrategy;
- return this;
- }
-
- /**
- * Assigns {@link AuthenticationStrategy} instance for target
- * host authentication.
- */
- public final HttpClientBuilder setProxyAuthenticationStrategy(
- final AuthenticationStrategy proxyAuthStrategy) {
- this.proxyAuthStrategy = proxyAuthStrategy;
- return this;
- }
-
- /**
- * Assigns {@link UserTokenHandler} instance.
- *
- * Please note this value can be overridden by the {@link #disableConnectionState()}
- * method.
- */
- public final HttpClientBuilder setUserTokenHandler(final UserTokenHandler userTokenHandler) {
- this.userTokenHandler = userTokenHandler;
- return this;
- }
-
- /**
- * Disables connection state tracking.
- */
- public final HttpClientBuilder disableConnectionState() {
- connectionStateDisabled = true;
- return this;
- }
-
- /**
- * Assigns {@link SchemePortResolver} instance.
- */
- public final HttpClientBuilder setSchemePortResolver(
- final SchemePortResolver schemePortResolver) {
- this.schemePortResolver = schemePortResolver;
- return this;
- }
-
- /**
- * Assigns User-Agent value.
- *
- * Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
- */
- public final HttpClientBuilder setUserAgent(final String userAgent) {
- this.userAgent = userAgent;
- return this;
- }
-
- /**
- * Assigns default request header values.
- *
- * Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
- */
- public final HttpClientBuilder setDefaultHeaders(final Collection extends Header> defaultHeaders) {
- this.defaultHeaders = defaultHeaders;
- return this;
- }
-
- /**
- * Adds this protocol interceptor to the head of the protocol processing list.
- *
- * Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
- */
- public final HttpClientBuilder addInterceptorFirst(final HttpResponseInterceptor itcp) {
- if (itcp == null) {
- return this;
- }
- if (responseFirst == null) {
- responseFirst = new LinkedList();
- }
- responseFirst.addFirst(itcp);
- return this;
- }
-
- /**
- * Adds this protocol interceptor to the tail of the protocol processing list.
- *
- * Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
- */
- public final HttpClientBuilder addInterceptorLast(final HttpResponseInterceptor itcp) {
- if (itcp == null) {
- return this;
- }
- if (responseLast == null) {
- responseLast = new LinkedList();
- }
- responseLast.addLast(itcp);
- return this;
- }
-
- /**
- * Adds this protocol interceptor to the head of the protocol processing list.
- *
- * Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
- */
- public final HttpClientBuilder addInterceptorFirst(final HttpRequestInterceptor itcp) {
- if (itcp == null) {
- return this;
- }
- if (requestFirst == null) {
- requestFirst = new LinkedList();
- }
- requestFirst.addFirst(itcp);
- return this;
- }
-
- /**
- * Adds this protocol interceptor to the tail of the protocol processing list.
- *
- * Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
- */
- public final HttpClientBuilder addInterceptorLast(final HttpRequestInterceptor itcp) {
- if (itcp == null) {
- return this;
- }
- if (requestLast == null) {
- requestLast = new LinkedList();
- }
- requestLast.addLast(itcp);
- return this;
- }
-
- /**
- * Disables state (cookie) management.
- *
- * Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
- */
- public final HttpClientBuilder disableCookieManagement() {
- this.cookieManagementDisabled = true;
- return this;
- }
-
- /**
- * Disables automatic content decompression.
- *
- * Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
- */
- public final HttpClientBuilder disableContentCompression() {
- contentCompressionDisabled = true;
- return this;
- }
-
- /**
- * Disables authentication scheme caching.
- *
- * Please note this value can be overridden by the {@link #setHttpProcessor(
- * org.apache.http.protocol.HttpProcessor)} method.
- */
- public final HttpClientBuilder disableAuthCaching() {
- this.authCachingDisabled = true;
- return this;
- }
-
- /**
- * Assigns {@link HttpProcessor} instance.
- */
- public final HttpClientBuilder setHttpProcessor(final HttpProcessor httpprocessor) {
- this.httpprocessor = httpprocessor;
- return this;
- }
-
- /**
- * Assigns {@link HttpRequestRetryHandler} instance.
- *
- * Please note this value can be overridden by the {@link #disableAutomaticRetries()}
- * method.
- */
- public final HttpClientBuilder setRetryHandler(final HttpRequestRetryHandler retryHandler) {
- this.retryHandler = retryHandler;
- return this;
- }
-
- /**
- * Disables automatic request recovery and re-execution.
- */
- public final HttpClientBuilder disableAutomaticRetries() {
- automaticRetriesDisabled = true;
- return this;
- }
-
- /**
- * Assigns default proxy value.
- *
- * Please note this value can be overridden by the {@link #setRoutePlanner(
- * org.apache.http.conn.routing.HttpRoutePlanner)} method.
- */
- public final HttpClientBuilder setProxy(final HttpHost proxy) {
- this.proxy = proxy;
- return this;
- }
-
- /**
- * Assigns {@link HttpRoutePlanner} instance.
- */
- public final HttpClientBuilder setRoutePlanner(final HttpRoutePlanner routePlanner) {
- this.routePlanner = routePlanner;
- return this;
- }
-
- /**
- * Assigns {@link RedirectStrategy} instance.
- *
- * Please note this value can be overridden by the {@link #disableRedirectHandling()}
- * method.
-` */
- public final HttpClientBuilder setRedirectStrategy(final RedirectStrategy redirectStrategy) {
- this.redirectStrategy = redirectStrategy;
- return this;
- }
-
- /**
- * Disables automatic redirect handling.
- */
- public final HttpClientBuilder disableRedirectHandling() {
- redirectHandlingDisabled = true;
- return this;
- }
-
- /**
- * Assigns {@link ConnectionBackoffStrategy} instance.
- */
- public final HttpClientBuilder setConnectionBackoffStrategy(
- final ConnectionBackoffStrategy connectionBackoffStrategy) {
- this.connectionBackoffStrategy = connectionBackoffStrategy;
- return this;
- }
-
- /**
- * Assigns {@link BackoffManager} instance.
- */
- public final HttpClientBuilder setBackoffManager(final BackoffManager backoffManager) {
- this.backoffManager = backoffManager;
- return this;
- }
-
- /**
- * Assigns {@link ServiceUnavailableRetryStrategy} instance.
- */
- public final HttpClientBuilder setServiceUnavailableRetryStrategy(
- final ServiceUnavailableRetryStrategy serviceUnavailStrategy) {
- this.serviceUnavailStrategy = serviceUnavailStrategy;
- return this;
- }
-
- /**
- * Assigns default {@link CookieStore} instance which will be used for
- * request execution if not explicitly set in the client execution context.
- */
- public final HttpClientBuilder setDefaultCookieStore(final CookieStore cookieStore) {
- this.cookieStore = cookieStore;
- return this;
- }
-
- /**
- * Assigns default {@link CredentialsProvider} instance which will be used
- * for request execution if not explicitly set in the client execution
- * context.
- */
- public final HttpClientBuilder setDefaultCredentialsProvider(
- final CredentialsProvider credentialsProvider) {
- this.credentialsProvider = credentialsProvider;
- return this;
- }
-
- /**
- * Assigns default {@link org.apache.http.auth.AuthScheme} registry which will
- * be used for request execution if not explicitly set in the client execution
- * context.
- */
- public final HttpClientBuilder setDefaultAuthSchemeRegistry(
- final Lookup authSchemeRegistry) {
- this.authSchemeRegistry = authSchemeRegistry;
- return this;
- }
-
- /**
- * Assigns default {@link org.apache.http.cookie.CookieSpec} registry which will
- * be used for request execution if not explicitly set in the client execution
- * context.
- */
- public final HttpClientBuilder setDefaultCookieSpecRegistry(
- final Lookup cookieSpecRegistry) {
- this.cookieSpecRegistry = cookieSpecRegistry;
- return this;
- }
-
- /**
- * Assigns default {@link RequestConfig} instance which will be used
- * for request execution if not explicitly set in the client execution
- * context.
- */
- public final HttpClientBuilder setDefaultRequestConfig(final RequestConfig config) {
- this.defaultRequestConfig = config;
- return this;
- }
-
- /**
- * Use system properties when creating and configuring default
- * implementations.
- */
- public final HttpClientBuilder useSystemProperties() {
- systemProperties = true;
- return this;
- }
-
- /**
- * For internal use.
- */
- protected ClientExecChain decorateMainExec(final ClientExecChain mainExec) {
- return mainExec;
- }
-
- /**
- * For internal use.
- */
- protected ClientExecChain decorateProtocolExec(final ClientExecChain protocolExec) {
- return protocolExec;
- }
-
- /**
- * For internal use.
- */
- protected void addCloseable(final Closeable closeable) {
- if (closeable == null) {
- return;
- }
- if (closeables == null) {
- closeables = new ArrayList();
- }
- closeables.add(closeable);
- }
-
- private static String[] split(final String s) {
- if (TextUtils.isBlank(s)) {
- return null;
- }
- return s.split(" *, *");
- }
-
- public CloseableHttpClient build() {
- // Create main request executor
- HttpRequestExecutor requestExec = this.requestExec;
- if (requestExec == null) {
- requestExec = new HttpRequestExecutor();
- }
- HttpClientConnectionManager connManager = this.connManager;
- if (connManager == null) {
- LayeredConnectionSocketFactory sslSocketFactory = this.sslSocketFactory;
- if (sslSocketFactory == null) {
- final String[] supportedProtocols = systemProperties ? split(
- System.getProperty("https.protocols")) : null;
- final String[] supportedCipherSuites = systemProperties ? split(
- System.getProperty("https.cipherSuites")) : null;
- X509HostnameVerifier hostnameVerifier = this.hostnameVerifier;
- if (hostnameVerifier == null) {
- hostnameVerifier = SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER;
- }
- if (sslcontext != null) {
- sslSocketFactory = new SSLConnectionSocketFactory(
- sslcontext, supportedProtocols, supportedCipherSuites, hostnameVerifier);
- } else {
- if (systemProperties) {
- sslSocketFactory = new SSLConnectionSocketFactory(
- (SSLSocketFactory) SSLCertificateSocketFactory.getDefault(0),
- supportedProtocols, supportedCipherSuites, hostnameVerifier);
- } else {
- sslSocketFactory = new SSLConnectionSocketFactory(
- (SSLSocketFactory) SSLCertificateSocketFactory.getDefault(0),
- hostnameVerifier);
- }
- }
- }
- @SuppressWarnings("resource")
- final PoolingHttpClientConnectionManager poolingmgr = new PoolingHttpClientConnectionManager(
- RegistryBuilder.create()
- .register("http", PlainConnectionSocketFactory.getSocketFactory())
- .register("https", sslSocketFactory)
- .build());
- if (defaultSocketConfig != null) {
- poolingmgr.setDefaultSocketConfig(defaultSocketConfig);
- }
- if (defaultConnectionConfig != null) {
- poolingmgr.setDefaultConnectionConfig(defaultConnectionConfig);
- }
- if (systemProperties) {
- String s = System.getProperty("http.keepAlive", "true");
- if ("true".equalsIgnoreCase(s)) {
- s = System.getProperty("http.maxConnections", "5");
- final int max = Integer.parseInt(s);
- poolingmgr.setDefaultMaxPerRoute(max);
- poolingmgr.setMaxTotal(2 * max);
- }
- }
- if (maxConnTotal > 0) {
- poolingmgr.setMaxTotal(maxConnTotal);
- }
- if (maxConnPerRoute > 0) {
- poolingmgr.setDefaultMaxPerRoute(maxConnPerRoute);
- }
- connManager = poolingmgr;
- }
- ConnectionReuseStrategy reuseStrategy = this.reuseStrategy;
- if (reuseStrategy == null) {
- if (systemProperties) {
- final String s = System.getProperty("http.keepAlive", "true");
- if ("true".equalsIgnoreCase(s)) {
- reuseStrategy = DefaultConnectionReuseStrategyHC4.INSTANCE;
- } else {
- reuseStrategy = NoConnectionReuseStrategyHC4.INSTANCE;
- }
- } else {
- reuseStrategy = DefaultConnectionReuseStrategyHC4.INSTANCE;
- }
- }
- ConnectionKeepAliveStrategy keepAliveStrategy = this.keepAliveStrategy;
- if (keepAliveStrategy == null) {
- keepAliveStrategy = DefaultConnectionKeepAliveStrategyHC4.INSTANCE;
- }
- AuthenticationStrategy targetAuthStrategy = this.targetAuthStrategy;
- if (targetAuthStrategy == null) {
- targetAuthStrategy = TargetAuthenticationStrategy.INSTANCE;
- }
- AuthenticationStrategy proxyAuthStrategy = this.proxyAuthStrategy;
- if (proxyAuthStrategy == null) {
- proxyAuthStrategy = ProxyAuthenticationStrategy.INSTANCE;
- }
- UserTokenHandler userTokenHandler = this.userTokenHandler;
- if (userTokenHandler == null) {
- if (!connectionStateDisabled) {
- userTokenHandler = DefaultUserTokenHandlerHC4.INSTANCE;
- } else {
- userTokenHandler = NoopUserTokenHandler.INSTANCE;
- }
- }
- ClientExecChain execChain = new MainClientExec(
- requestExec,
- connManager,
- reuseStrategy,
- keepAliveStrategy,
- targetAuthStrategy,
- proxyAuthStrategy,
- userTokenHandler);
-
- execChain = decorateMainExec(execChain);
-
- HttpProcessor httpprocessor = this.httpprocessor;
- if (httpprocessor == null) {
-
- String userAgent = this.userAgent;
- if (userAgent == null) {
- if (systemProperties) {
- userAgent = System.getProperty("http.agent");
- }
- if (userAgent == null) {
- userAgent = DEFAULT_USER_AGENT;
- }
- }
-
- final HttpProcessorBuilder b = HttpProcessorBuilder.create();
- if (requestFirst != null) {
- for (final HttpRequestInterceptor i: requestFirst) {
- b.addFirst(i);
- }
- }
- if (responseFirst != null) {
- for (final HttpResponseInterceptor i: responseFirst) {
- b.addFirst(i);
- }
- }
- b.addAll(
- new RequestDefaultHeadersHC4(defaultHeaders),
- new RequestContentHC4(),
- new RequestTargetHostHC4(),
- new RequestClientConnControl(),
- new RequestUserAgentHC4(userAgent),
- new RequestExpectContinue());
- if (!cookieManagementDisabled) {
- b.add(new RequestAddCookiesHC4());
- }
- if (!contentCompressionDisabled) {
- b.add(new RequestAcceptEncoding());
- }
- if (!authCachingDisabled) {
- b.add(new RequestAuthCache());
- }
- if (!cookieManagementDisabled) {
- b.add(new ResponseProcessCookiesHC4());
- }
- if (!contentCompressionDisabled) {
- b.add(new ResponseContentEncoding());
- }
- if (requestLast != null) {
- for (final HttpRequestInterceptor i: requestLast) {
- b.addLast(i);
- }
- }
- if (responseLast != null) {
- for (final HttpResponseInterceptor i: responseLast) {
- b.addLast(i);
- }
- }
- httpprocessor = b.build();
- }
- execChain = new ProtocolExec(execChain, httpprocessor);
-
- execChain = decorateProtocolExec(execChain);
-
- // Add request retry executor, if not disabled
- if (!automaticRetriesDisabled) {
- HttpRequestRetryHandler retryHandler = this.retryHandler;
- if (retryHandler == null) {
- retryHandler = DefaultHttpRequestRetryHandlerHC4.INSTANCE;
- }
- execChain = new RetryExec(execChain, retryHandler);
- }
-
- HttpRoutePlanner routePlanner = this.routePlanner;
- if (routePlanner == null) {
- SchemePortResolver schemePortResolver = this.schemePortResolver;
- if (schemePortResolver == null) {
- schemePortResolver = DefaultSchemePortResolver.INSTANCE;
- }
- if (proxy != null) {
- routePlanner = new DefaultProxyRoutePlanner(proxy, schemePortResolver);
- } else if (systemProperties) {
- routePlanner = new SystemDefaultRoutePlanner(
- schemePortResolver, ProxySelector.getDefault());
- } else {
- routePlanner = new DefaultRoutePlanner(schemePortResolver);
- }
- }
- // Add redirect executor, if not disabled
- if (!redirectHandlingDisabled) {
- RedirectStrategy redirectStrategy = this.redirectStrategy;
- if (redirectStrategy == null) {
- redirectStrategy = DefaultRedirectStrategy.INSTANCE;
- }
- execChain = new RedirectExec(execChain, routePlanner, redirectStrategy);
- }
-
- // Optionally, add service unavailable retry executor
- final ServiceUnavailableRetryStrategy serviceUnavailStrategy = this.serviceUnavailStrategy;
- if (serviceUnavailStrategy != null) {
- execChain = new ServiceUnavailableRetryExec(execChain, serviceUnavailStrategy);
- }
- // Optionally, add connection back-off executor
- final BackoffManager backoffManager = this.backoffManager;
- final ConnectionBackoffStrategy connectionBackoffStrategy = this.connectionBackoffStrategy;
- if (backoffManager != null && connectionBackoffStrategy != null) {
- execChain = new BackoffStrategyExec(execChain, connectionBackoffStrategy, backoffManager);
- }
-
- Lookup authSchemeRegistry = this.authSchemeRegistry;
- if (authSchemeRegistry == null) {
- authSchemeRegistry = RegistryBuilder.create()
- .register(AuthSchemes.BASIC, new BasicSchemeFactoryHC4())
- .register(AuthSchemes.DIGEST, new DigestSchemeFactoryHC4())
- .register(AuthSchemes.NTLM, new NTLMSchemeFactory())
- .build();
- }
- Lookup cookieSpecRegistry = this.cookieSpecRegistry;
- if (cookieSpecRegistry == null) {
- cookieSpecRegistry = RegistryBuilder.create()
- .register(CookieSpecs.BEST_MATCH, new BestMatchSpecFactoryHC4())
- .register(CookieSpecs.STANDARD, new RFC2965SpecFactoryHC4())
- .register(CookieSpecs.BROWSER_COMPATIBILITY, new BrowserCompatSpecFactoryHC4())
- .register(CookieSpecs.NETSCAPE, new NetscapeDraftSpecFactoryHC4())
- .register(CookieSpecs.IGNORE_COOKIES, new IgnoreSpecFactory())
- .register("rfc2109", new RFC2109SpecFactoryHC4())
- .register("rfc2965", new RFC2965SpecFactoryHC4())
- .build();
- }
-
- CookieStore defaultCookieStore = this.cookieStore;
- if (defaultCookieStore == null) {
- defaultCookieStore = new BasicCookieStoreHC4();
- }
-
- CredentialsProvider defaultCredentialsProvider = this.credentialsProvider;
- if (defaultCredentialsProvider == null) {
- if (systemProperties) {
- defaultCredentialsProvider = new SystemDefaultCredentialsProvider();
- } else {
- defaultCredentialsProvider = new BasicCredentialsProviderHC4();
- }
- }
-
- return new InternalHttpClient(
- execChain,
- connManager,
- routePlanner,
- cookieSpecRegistry,
- authSchemeRegistry,
- defaultCookieStore,
- defaultCredentialsProvider,
- defaultRequestConfig != null ? defaultRequestConfig : RequestConfig.DEFAULT,
- closeables != null ? new ArrayList(closeables) : null);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/HttpClients.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/HttpClients.java
deleted file mode 100644
index 569b047a..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/HttpClients.java
+++ /dev/null
@@ -1,85 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import org.apache.http.annotation.Immutable;
-import org.apache.http.conn.HttpClientConnectionManager;
-import org.apache.http.impl.conn.PoolingHttpClientConnectionManager;
-
-/**
- * Factory methods for {@link CloseableHttpClient} instances.
- * @since 4.3
- */
-@Immutable
-public class HttpClients {
-
- private HttpClients() {
- super();
- }
-
- /**
- * Creates builder object for construction of custom
- * {@link CloseableHttpClient} instances.
- */
- public static HttpClientBuilder custom() {
- return HttpClientBuilder.create();
- }
-
- /**
- * Creates {@link CloseableHttpClient} instance with default
- * configuration.
- */
- public static CloseableHttpClient createDefault() {
- return HttpClientBuilder.create().build();
- }
-
- /**
- * Creates {@link CloseableHttpClient} instance with default
- * configuration based on ssytem properties.
- */
- public static CloseableHttpClient createSystem() {
- return HttpClientBuilder.create().useSystemProperties().build();
- }
-
- /**
- * Creates {@link CloseableHttpClient} instance that implements
- * the most basic HTTP protocol support.
- */
- public static CloseableHttpClient createMinimal() {
- return new MinimalHttpClient(new PoolingHttpClientConnectionManager());
- }
-
- /**
- * Creates {@link CloseableHttpClient} instance that implements
- * the most basic HTTP protocol support.
- */
- public static CloseableHttpClient createMinimal(final HttpClientConnectionManager connManager) {
- return new MinimalHttpClient(connManager);
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/HttpRequestFutureTask.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/HttpRequestFutureTask.java
deleted file mode 100644
index f37cd7a9..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/HttpRequestFutureTask.java
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import java.util.concurrent.FutureTask;
-
-import org.apache.http.client.methods.HttpUriRequest;
-
-/**
- * FutureTask implementation that wraps a HttpAsyncClientCallable and exposes various task
- * specific metrics.
- *
- * @param
- */
-public class HttpRequestFutureTask extends FutureTask {
-
- private final HttpUriRequest request;
- private final HttpRequestTaskCallable callable;
-
- public HttpRequestFutureTask(
- final HttpUriRequest request,
- final HttpRequestTaskCallable httpCallable) {
- super(httpCallable);
- this.request = request;
- this.callable = httpCallable;
- }
-
- /*
- * (non-Javadoc)
- * @see java.util.concurrent.FutureTask#cancel(boolean)
- */
- @Override
- public boolean cancel(final boolean mayInterruptIfRunning) {
- callable.cancel();
- if (mayInterruptIfRunning) {
- request.abort();
- }
- return super.cancel(mayInterruptIfRunning);
- }
-
- /**
- * @return the time in millis the task was scheduled.
- */
- public long scheduledTime() {
- return callable.getScheduled();
- }
-
- /**
- * @return the time in millis the task was started.
- */
- public long startedTime() {
- return callable.getStarted();
- }
-
- /**
- * @return the time in millis the task was finished/cancelled.
- */
- public long endedTime() {
- if (isDone()) {
- return callable.getEnded();
- } else {
- throw new IllegalStateException("Task is not done yet");
- }
- }
-
- /**
- * @return the time in millis it took to make the request (excluding the time it was
- * scheduled to be executed).
- */
- public long requestDuration() {
- if (isDone()) {
- return endedTime() - startedTime();
- } else {
- throw new IllegalStateException("Task is not done yet");
- }
- }
-
- /**
- * @return the time in millis it took to execute the task from the moment it was scheduled.
- */
- public long taskDuration() {
- if (isDone()) {
- return endedTime() - scheduledTime();
- } else {
- throw new IllegalStateException("Task is not done yet");
- }
- }
-
- @Override
- public String toString() {
- return request.getRequestLine().getUri();
- }
-
-}
\ No newline at end of file
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java
deleted file mode 100644
index a4577b55..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/HttpRequestTaskCallable.java
+++ /dev/null
@@ -1,119 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import java.util.concurrent.Callable;
-import java.util.concurrent.atomic.AtomicBoolean;
-
-import org.apache.http.client.HttpClient;
-import org.apache.http.client.ResponseHandler;
-import org.apache.http.client.methods.HttpUriRequest;
-import org.apache.http.concurrent.FutureCallback;
-import org.apache.http.protocol.HttpContext;
-
-class HttpRequestTaskCallable implements Callable {
-
- private final HttpUriRequest request;
- private final HttpClient httpclient;
- private final AtomicBoolean cancelled = new AtomicBoolean(false);
-
- private final long scheduled = System.currentTimeMillis();
- private long started = -1;
- private long ended = -1;
-
- private final HttpContext context;
- private final ResponseHandler responseHandler;
- private final FutureCallback callback;
-
- private final FutureRequestExecutionMetrics metrics;
-
- HttpRequestTaskCallable(
- final HttpClient httpClient,
- final HttpUriRequest request,
- final HttpContext context,
- final ResponseHandler responseHandler,
- final FutureCallback callback,
- final FutureRequestExecutionMetrics metrics) {
- this.httpclient = httpClient;
- this.responseHandler = responseHandler;
- this.request = request;
- this.context = context;
- this.callback = callback;
- this.metrics = metrics;
- }
-
- public long getScheduled() {
- return scheduled;
- }
-
- public long getStarted() {
- return started;
- }
-
- public long getEnded() {
- return ended;
- }
-
- public V call() throws Exception {
- if (!cancelled.get()) {
- try {
- metrics.getActiveConnections().incrementAndGet();
- started = System.currentTimeMillis();
- try {
- metrics.getScheduledConnections().decrementAndGet();
- final V result = httpclient.execute(request, responseHandler, context);
- ended = System.currentTimeMillis();
- metrics.getSuccessfulConnections().increment(started);
- if (callback != null) {
- callback.completed(result);
- }
- return result;
- } catch (final Exception e) {
- metrics.getFailedConnections().increment(started);
- ended = System.currentTimeMillis();
- if (callback != null) {
- callback.failed(e);
- }
- throw e;
- }
- } finally {
- metrics.getRequests().increment(started);
- metrics.getTasks().increment(started);
- metrics.getActiveConnections().decrementAndGet();
- }
- } else {
- throw new IllegalStateException("call has been cancelled for request " + request.getURI());
- }
- }
-
- public void cancel() {
- cancelled.set(true);
- if (callback != null) {
- callback.cancelled();
- }
- }
-}
\ No newline at end of file
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/InternalHttpClient.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
deleted file mode 100644
index dd1304c9..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/InternalHttpClient.java
+++ /dev/null
@@ -1,236 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.List;
-import java.util.concurrent.TimeUnit;
-
-import android.util.Log;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.auth.AuthSchemeProvider;
-import org.apache.http.auth.AuthStateHC4;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.CookieStore;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.Configurable;
-import org.apache.http.client.methods.HttpExecutionAware;
-import org.apache.http.client.methods.HttpRequestWrapper;
-import org.apache.http.client.params.ClientPNames;
-import org.apache.http.client.params.HttpClientParamConfig;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.config.Lookup;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.ClientConnectionRequest;
-import org.apache.http.conn.HttpClientConnectionManager;
-import org.apache.http.conn.ManagedClientConnection;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.routing.HttpRoutePlanner;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.cookie.CookieSpecProvider;
-import org.apache.http.impl.execchain.ClientExecChain;
-import org.apache.http.params.HttpParams;
-import org.apache.http.params.HttpParamsNames;
-import org.apache.http.protocol.BasicHttpContextHC4;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.util.Args;
-
-/**
- * Internal class.
- *
- * @since 4.3
- */
-@ThreadSafe
-@SuppressWarnings("deprecation")
-class InternalHttpClient extends CloseableHttpClient {
-
- private final static String TAG = "HttpClient";
-
- private final ClientExecChain execChain;
- private final HttpClientConnectionManager connManager;
- private final HttpRoutePlanner routePlanner;
- private final Lookup cookieSpecRegistry;
- private final Lookup authSchemeRegistry;
- private final CookieStore cookieStore;
- private final CredentialsProvider credentialsProvider;
- private final RequestConfig defaultConfig;
- private final List closeables;
-
- public InternalHttpClient(
- final ClientExecChain execChain,
- final HttpClientConnectionManager connManager,
- final HttpRoutePlanner routePlanner,
- final Lookup cookieSpecRegistry,
- final Lookup authSchemeRegistry,
- final CookieStore cookieStore,
- final CredentialsProvider credentialsProvider,
- final RequestConfig defaultConfig,
- final List closeables) {
- super();
- Args.notNull(execChain, "HTTP client exec chain");
- Args.notNull(connManager, "HTTP connection manager");
- Args.notNull(routePlanner, "HTTP route planner");
- this.execChain = execChain;
- this.connManager = connManager;
- this.routePlanner = routePlanner;
- this.cookieSpecRegistry = cookieSpecRegistry;
- this.authSchemeRegistry = authSchemeRegistry;
- this.cookieStore = cookieStore;
- this.credentialsProvider = credentialsProvider;
- this.defaultConfig = defaultConfig;
- this.closeables = closeables;
- }
-
- private HttpRoute determineRoute(
- final HttpHost target,
- final HttpRequest request,
- final HttpContext context) throws HttpException {
- HttpHost host = target;
- if (host == null) {
- host = (HttpHost) request.getParams().getParameter(ClientPNames.DEFAULT_HOST);
- }
- return this.routePlanner.determineRoute(host, request, context);
- }
-
- private void setupContext(final HttpClientContext context) {
- if (context.getAttribute(HttpClientContext.TARGET_AUTH_STATE) == null) {
- context.setAttribute(HttpClientContext.TARGET_AUTH_STATE, new AuthStateHC4());
- }
- if (context.getAttribute(HttpClientContext.PROXY_AUTH_STATE) == null) {
- context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, new AuthStateHC4());
- }
- if (context.getAttribute(HttpClientContext.AUTHSCHEME_REGISTRY) == null) {
- context.setAttribute(HttpClientContext.AUTHSCHEME_REGISTRY, this.authSchemeRegistry);
- }
- if (context.getAttribute(HttpClientContext.COOKIESPEC_REGISTRY) == null) {
- context.setAttribute(HttpClientContext.COOKIESPEC_REGISTRY, this.cookieSpecRegistry);
- }
- if (context.getAttribute(HttpClientContext.COOKIE_STORE) == null) {
- context.setAttribute(HttpClientContext.COOKIE_STORE, this.cookieStore);
- }
- if (context.getAttribute(HttpClientContext.CREDS_PROVIDER) == null) {
- context.setAttribute(HttpClientContext.CREDS_PROVIDER, this.credentialsProvider);
- }
- if (context.getAttribute(HttpClientContext.REQUEST_CONFIG) == null) {
- context.setAttribute(HttpClientContext.REQUEST_CONFIG, this.defaultConfig);
- }
- }
-
- @Override
- protected CloseableHttpResponse doExecute(
- final HttpHost target,
- final HttpRequest request,
- final HttpContext context) throws IOException, ClientProtocolException {
- Args.notNull(request, "HTTP request");
- HttpExecutionAware execAware = null;
- if (request instanceof HttpExecutionAware) {
- execAware = (HttpExecutionAware) request;
- }
- try {
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(request);
- final HttpClientContext localcontext = HttpClientContext.adapt(
- context != null ? context : new BasicHttpContextHC4());
- RequestConfig config = null;
- if (request instanceof Configurable) {
- config = ((Configurable) request).getConfig();
- }
- if (config == null) {
- final HttpParams params = request.getParams();
- config = HttpClientParamConfig.getRequestConfig(params);
- }
- if (config != null) {
- localcontext.setRequestConfig(config);
- }
- setupContext(localcontext);
- final HttpRoute route = determineRoute(target, wrapper, localcontext);
- return this.execChain.execute(route, wrapper, localcontext, execAware);
- } catch (final HttpException httpException) {
- throw new ClientProtocolException(httpException);
- }
- }
-
- public void close() {
- this.connManager.shutdown();
- if (this.closeables != null) {
- for (final Closeable closeable: this.closeables) {
- try {
- closeable.close();
- } catch (final IOException ex) {
- Log.e(TAG, ex.getMessage(), ex);
- }
- }
- }
- }
-
- public HttpParams getParams() {
- throw new UnsupportedOperationException();
- }
-
- public ClientConnectionManager getConnectionManager() {
-
- return new ClientConnectionManager() {
-
- public void shutdown() {
- connManager.shutdown();
- }
-
- public ClientConnectionRequest requestConnection(
- final HttpRoute route, final Object state) {
- throw new UnsupportedOperationException();
- }
-
- public void releaseConnection(
- final ManagedClientConnection conn,
- final long validDuration, final TimeUnit timeUnit) {
- throw new UnsupportedOperationException();
- }
-
- public SchemeRegistry getSchemeRegistry() {
- throw new UnsupportedOperationException();
- }
-
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- connManager.closeIdleConnections(idletime, tunit);
- }
-
- public void closeExpiredConnections() {
- connManager.closeExpiredConnections();
- }
-
- };
-
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/LaxRedirectStrategy.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/LaxRedirectStrategy.java
deleted file mode 100644
index f4585916..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/LaxRedirectStrategy.java
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import org.apache.http.annotation.Immutable;
-import org.apache.http.client.methods.HttpGetHC4;
-import org.apache.http.client.methods.HttpHeadHC4;
-import org.apache.http.client.methods.HttpPostHC4;
-
-/**
- * Lax {@link org.apache.http.client.RedirectStrategy} implementation
- * that automatically redirects all HEAD, GET and POST requests.
- * This strategy relaxes restrictions on automatic redirection of
- * POST methods imposed by the HTTP specification.
- *
- * @since 4.2
- */
-@Immutable
-public class LaxRedirectStrategy extends DefaultRedirectStrategy {
-
- /**
- * Redirectable methods.
- */
- private static final String[] REDIRECT_METHODS = new String[] {
- HttpGetHC4.METHOD_NAME,
- HttpPostHC4.METHOD_NAME,
- HttpHeadHC4.METHOD_NAME
- };
-
- @Override
- protected boolean isRedirectable(final String method) {
- for (final String m: REDIRECT_METHODS) {
- if (m.equalsIgnoreCase(method)) {
- return true;
- }
- }
- return false;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java
deleted file mode 100644
index 48a71c52..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/MinimalHttpClient.java
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.io.IOException;
-import java.util.concurrent.TimeUnit;
-
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.annotation.ThreadSafe;
-import org.apache.http.client.ClientProtocolException;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.methods.CloseableHttpResponse;
-import org.apache.http.client.methods.Configurable;
-import org.apache.http.client.methods.HttpExecutionAware;
-import org.apache.http.client.methods.HttpRequestWrapper;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.conn.ClientConnectionManager;
-import org.apache.http.conn.ClientConnectionRequest;
-import org.apache.http.conn.HttpClientConnectionManager;
-import org.apache.http.conn.ManagedClientConnection;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.scheme.SchemeRegistry;
-import org.apache.http.impl.DefaultConnectionReuseStrategyHC4;
-import org.apache.http.impl.execchain.MinimalClientExec;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.BasicHttpContextHC4;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpRequestExecutor;
-import org.apache.http.util.Args;
-
-/**
- * Internal class.
- *
- * @since 4.3
- */
-@ThreadSafe
-@SuppressWarnings("deprecation")
-class MinimalHttpClient extends CloseableHttpClient {
-
- private final HttpClientConnectionManager connManager;
- private final MinimalClientExec requestExecutor;
- private final HttpParams params;
-
- public MinimalHttpClient(
- final HttpClientConnectionManager connManager) {
- super();
- this.connManager = Args.notNull(connManager, "HTTP connection manager");
- this.requestExecutor = new MinimalClientExec(
- new HttpRequestExecutor(),
- connManager,
- DefaultConnectionReuseStrategyHC4.INSTANCE,
- DefaultConnectionKeepAliveStrategyHC4.INSTANCE);
- this.params = new BasicHttpParams();
- }
-
- @Override
- protected CloseableHttpResponse doExecute(
- final HttpHost target,
- final HttpRequest request,
- final HttpContext context) throws IOException, ClientProtocolException {
- Args.notNull(target, "Target host");
- Args.notNull(request, "HTTP request");
- HttpExecutionAware execAware = null;
- if (request instanceof HttpExecutionAware) {
- execAware = (HttpExecutionAware) request;
- }
- try {
- final HttpRequestWrapper wrapper = HttpRequestWrapper.wrap(request);
- final HttpClientContext localcontext = HttpClientContext.adapt(
- context != null ? context : new BasicHttpContextHC4());
- final HttpRoute route = new HttpRoute(target);
- RequestConfig config = null;
- if (request instanceof Configurable) {
- config = ((Configurable) request).getConfig();
- }
- if (config != null) {
- localcontext.setRequestConfig(config);
- }
- return this.requestExecutor.execute(route, wrapper, localcontext, execAware);
- } catch (final HttpException httpException) {
- throw new ClientProtocolException(httpException);
- }
- }
-
- public HttpParams getParams() {
- return this.params;
- }
-
- public void close() {
- this.connManager.shutdown();
- }
-
- public ClientConnectionManager getConnectionManager() {
-
- return new ClientConnectionManager() {
-
- public void shutdown() {
- connManager.shutdown();
- }
-
- public ClientConnectionRequest requestConnection(
- final HttpRoute route, final Object state) {
- throw new UnsupportedOperationException();
- }
-
- public void releaseConnection(
- final ManagedClientConnection conn,
- final long validDuration, final TimeUnit timeUnit) {
- throw new UnsupportedOperationException();
- }
-
- public SchemeRegistry getSchemeRegistry() {
- throw new UnsupportedOperationException();
- }
-
- public void closeIdleConnections(final long idletime, final TimeUnit tunit) {
- connManager.closeIdleConnections(idletime, tunit);
- }
-
- public void closeExpiredConnections() {
- connManager.closeExpiredConnections();
- }
-
- };
-
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/NoopUserTokenHandler.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/NoopUserTokenHandler.java
deleted file mode 100644
index 62765515..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/NoopUserTokenHandler.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import org.apache.http.annotation.Immutable;
-import org.apache.http.client.UserTokenHandler;
-import org.apache.http.protocol.HttpContext;
-
-/**
- * Noop implementation of {@link UserTokenHandler} that always returns null.
- *
- * @since 4.3
- */
-@Immutable
-public class NoopUserTokenHandler implements UserTokenHandler {
-
- public static final NoopUserTokenHandler INSTANCE = new NoopUserTokenHandler();
-
- public Object getUserToken(final HttpContext context) {
- return null;
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/NullBackoffStrategy.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/NullBackoffStrategy.java
deleted file mode 100644
index 0c7a452e..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/NullBackoffStrategy.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-package org.apache.http.impl.client;
-
-import org.apache.http.HttpResponse;
-import org.apache.http.client.ConnectionBackoffStrategy;
-
-/**
- * This is a {@link ConnectionBackoffStrategy} that never backs off,
- * for compatibility with existing behavior.
- *
- * @since 4.2
- */
-public class NullBackoffStrategy implements ConnectionBackoffStrategy {
-
- public boolean shouldBackoff(final Throwable t) {
- return false;
- }
-
- public boolean shouldBackoff(final HttpResponse resp) {
- return false;
- }
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/ProxyAuthenticationStrategy.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/ProxyAuthenticationStrategy.java
deleted file mode 100644
index 49e6e912..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/ProxyAuthenticationStrategy.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.util.Collection;
-
-import org.apache.http.HttpStatus;
-import org.apache.http.annotation.Immutable;
-import org.apache.http.auth.AUTH;
-import org.apache.http.client.config.RequestConfig;
-
-/**
- * Default {@link org.apache.http.client.AuthenticationStrategy} implementation
- * for proxy host authentication.
- *
- * @since 4.2
- */
-@Immutable
-public class ProxyAuthenticationStrategy extends AuthenticationStrategyImpl {
-
- public static final ProxyAuthenticationStrategy INSTANCE = new ProxyAuthenticationStrategy();
-
- public ProxyAuthenticationStrategy() {
- super(HttpStatus.SC_PROXY_AUTHENTICATION_REQUIRED, AUTH.PROXY_AUTH);
- }
-
- @Override
- Collection getPreferredAuthSchemes(final RequestConfig config) {
- return config.getProxyPreferredAuthSchemes();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/ProxyClient.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/ProxyClient.java
deleted file mode 100644
index 6e8a5ec6..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/ProxyClient.java
+++ /dev/null
@@ -1,250 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.io.IOException;
-import java.net.Socket;
-
-import org.apache.http.ConnectionReuseStrategy;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpResponse;
-import org.apache.http.HttpVersion;
-import org.apache.http.auth.AUTH;
-import org.apache.http.auth.AuthSchemeRegistry;
-import org.apache.http.auth.AuthScope;
-import org.apache.http.auth.AuthStateHC4;
-import org.apache.http.auth.Credentials;
-import org.apache.http.client.config.AuthSchemes;
-import org.apache.http.client.config.RequestConfig;
-import org.apache.http.client.params.HttpClientParamConfig;
-import org.apache.http.client.protocol.HttpClientContext;
-import org.apache.http.client.protocol.RequestClientConnControl;
-import org.apache.http.config.ConnectionConfig;
-import org.apache.http.conn.HttpConnectionFactory;
-import org.apache.http.conn.ManagedHttpClientConnection;
-import org.apache.http.conn.routing.HttpRoute;
-import org.apache.http.conn.routing.RouteInfo.LayerType;
-import org.apache.http.conn.routing.RouteInfo.TunnelType;
-import org.apache.http.entity.BufferedHttpEntityHC4;
-import org.apache.http.impl.DefaultConnectionReuseStrategyHC4;
-import org.apache.http.impl.auth.BasicSchemeFactoryHC4;
-import org.apache.http.impl.auth.DigestSchemeFactoryHC4;
-import org.apache.http.impl.auth.HttpAuthenticator;
-import org.apache.http.impl.auth.NTLMSchemeFactory;
-import org.apache.http.impl.conn.ManagedHttpClientConnectionFactory;
-import org.apache.http.impl.execchain.TunnelRefusedException;
-import org.apache.http.message.BasicHttpRequest;
-import org.apache.http.params.BasicHttpParams;
-import org.apache.http.params.HttpParamConfig;
-import org.apache.http.params.HttpParams;
-import org.apache.http.protocol.BasicHttpContextHC4;
-import org.apache.http.protocol.HttpContext;
-import org.apache.http.protocol.HttpCoreContext;
-import org.apache.http.protocol.HttpProcessor;
-import org.apache.http.protocol.HttpRequestExecutor;
-import org.apache.http.protocol.ImmutableHttpProcessor;
-import org.apache.http.protocol.RequestTargetHostHC4;
-import org.apache.http.protocol.RequestUserAgentHC4;
-import org.apache.http.util.Args;
-import org.apache.http.util.EntityUtilsHC4;
-
-/**
- * ProxyClient can be used to establish a tunnel via an HTTP proxy.
- */
-@SuppressWarnings("deprecation")
-public class ProxyClient {
-
- private final HttpConnectionFactory connFactory;
- private final ConnectionConfig connectionConfig;
- private final RequestConfig requestConfig;
- private final HttpProcessor httpProcessor;
- private final HttpRequestExecutor requestExec;
- private final ProxyAuthenticationStrategy proxyAuthStrategy;
- private final HttpAuthenticator authenticator;
- private final AuthStateHC4 proxyAuthState;
- private final AuthSchemeRegistry authSchemeRegistry;
- private final ConnectionReuseStrategy reuseStrategy;
-
- /**
- * @since 4.3
- */
- public ProxyClient(
- final HttpConnectionFactory connFactory,
- final ConnectionConfig connectionConfig,
- final RequestConfig requestConfig) {
- super();
- this.connFactory = connFactory != null ? connFactory : ManagedHttpClientConnectionFactory.INSTANCE;
- this.connectionConfig = connectionConfig != null ? connectionConfig : ConnectionConfig.DEFAULT;
- this.requestConfig = requestConfig != null ? requestConfig : RequestConfig.DEFAULT;
- this.httpProcessor = new ImmutableHttpProcessor(
- new RequestTargetHostHC4(), new RequestClientConnControl(), new RequestUserAgentHC4());
- this.requestExec = new HttpRequestExecutor();
- this.proxyAuthStrategy = new ProxyAuthenticationStrategy();
- this.authenticator = new HttpAuthenticator();
- this.proxyAuthState = new AuthStateHC4();
- this.authSchemeRegistry = new AuthSchemeRegistry();
- this.authSchemeRegistry.register(AuthSchemes.BASIC, new BasicSchemeFactoryHC4());
- this.authSchemeRegistry.register(AuthSchemes.DIGEST, new DigestSchemeFactoryHC4());
- this.authSchemeRegistry.register(AuthSchemes.NTLM, new NTLMSchemeFactory());
- this.reuseStrategy = new DefaultConnectionReuseStrategyHC4();
- }
-
- /**
- * @deprecated (4.3) use {@link ProxyClient#ProxyClient(HttpConnectionFactory, ConnectionConfig, RequestConfig)}
- */
- @Deprecated
- public ProxyClient(final HttpParams params) {
- this(null,
- HttpParamConfig.getConnectionConfig(params),
- HttpClientParamConfig.getRequestConfig(params));
- }
-
- /**
- * @since 4.3
- */
- public ProxyClient(final RequestConfig requestConfig) {
- this(null, null, requestConfig);
- }
-
- public ProxyClient() {
- this(null, null, null);
- }
-
- /**
- * @deprecated (4.3) do not use.
- */
- @Deprecated
- public HttpParams getParams() {
- return new BasicHttpParams();
- }
-
- /**
- * @deprecated (4.3) do not use.
- */
- @Deprecated
- public AuthSchemeRegistry getAuthSchemeRegistry() {
- return this.authSchemeRegistry;
- }
-
- public Socket tunnel(
- final HttpHost proxy,
- final HttpHost target,
- final Credentials credentials) throws IOException, HttpException {
- Args.notNull(proxy, "Proxy host");
- Args.notNull(target, "Target host");
- Args.notNull(credentials, "Credentials");
- HttpHost host = target;
- if (host.getPort() <= 0) {
- host = new HttpHost(host.getHostName(), 80, host.getSchemeName());
- }
- final HttpRoute route = new HttpRoute(
- host,
- this.requestConfig.getLocalAddress(),
- proxy, false, TunnelType.TUNNELLED, LayerType.PLAIN);
-
- final ManagedHttpClientConnection conn = this.connFactory.create(
- route, this.connectionConfig);
- final HttpContext context = new BasicHttpContextHC4();
- HttpResponse response;
-
- final HttpRequest connect = new BasicHttpRequest(
- "CONNECT", host.toHostString(), HttpVersion.HTTP_1_1);
-
- final BasicCredentialsProviderHC4 credsProvider = new BasicCredentialsProviderHC4();
- credsProvider.setCredentials(new AuthScope(proxy.getHostName(), proxy.getPort()), credentials);
-
- // Populate the execution context
- context.setAttribute(HttpCoreContext.HTTP_TARGET_HOST, target);
- context.setAttribute(HttpCoreContext.HTTP_CONNECTION, conn);
- context.setAttribute(HttpCoreContext.HTTP_REQUEST, connect);
- context.setAttribute(HttpClientContext.HTTP_ROUTE, route);
- context.setAttribute(HttpClientContext.PROXY_AUTH_STATE, this.proxyAuthState);
- context.setAttribute(HttpClientContext.CREDS_PROVIDER, credsProvider);
- context.setAttribute(HttpClientContext.AUTHSCHEME_REGISTRY, this.authSchemeRegistry);
- context.setAttribute(HttpClientContext.REQUEST_CONFIG, this.requestConfig);
-
- this.requestExec.preProcess(connect, this.httpProcessor, context);
-
- for (;;) {
- if (!conn.isOpen()) {
- final Socket socket = new Socket(proxy.getHostName(), proxy.getPort());
- conn.bind(socket);
- }
-
- this.authenticator.generateAuthResponse(connect, this.proxyAuthState, context);
-
- response = this.requestExec.execute(connect, conn, context);
-
- final int status = response.getStatusLine().getStatusCode();
- if (status < 200) {
- throw new HttpException("Unexpected response to CONNECT request: " +
- response.getStatusLine());
- }
- if (this.authenticator.isAuthenticationRequested(proxy, response,
- this.proxyAuthStrategy, this.proxyAuthState, context)) {
- if (this.authenticator.handleAuthChallenge(proxy, response,
- this.proxyAuthStrategy, this.proxyAuthState, context)) {
- // Retry request
- if (this.reuseStrategy.keepAlive(response, context)) {
- // Consume response content
- final HttpEntity entity = response.getEntity();
- EntityUtilsHC4.consume(entity);
- } else {
- conn.close();
- }
- // discard previous auth header
- connect.removeHeaders(AUTH.PROXY_AUTH_RESP);
- } else {
- break;
- }
- } else {
- break;
- }
- }
-
- final int status = response.getStatusLine().getStatusCode();
-
- if (status > 299) {
-
- // Buffer response content
- final HttpEntity entity = response.getEntity();
- if (entity != null) {
- response.setEntity(new BufferedHttpEntityHC4(entity));
- }
-
- conn.close();
- throw new TunnelRefusedException("CONNECT refused by proxy: " +
- response.getStatusLine(), response);
- }
- return conn.getSocket();
- }
-
-}
diff --git a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/RedirectLocationsHC4.java b/lib/httpclient-android/src/main/java/org/apache/http/impl/client/RedirectLocationsHC4.java
deleted file mode 100644
index 6702147e..00000000
--- a/lib/httpclient-android/src/main/java/org/apache/http/impl/client/RedirectLocationsHC4.java
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * ====================================================================
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- * ====================================================================
- *
- * This software consists of voluntary contributions made by many
- * individuals on behalf of the Apache Software Foundation. For more
- * information on the Apache Software Foundation, please see
- * .
- *
- */
-
-package org.apache.http.impl.client;
-
-import java.net.URI;
-import java.util.AbstractList;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Set;
-
-import org.apache.http.annotation.NotThreadSafe;
-
-/**
- * This class represents a collection of {@link java.net.URI}s used
- * as redirect locations.
- *
- * @since 4.0
- */
-@NotThreadSafe // HashSet/ArrayList are not synch.
-public class RedirectLocationsHC4 extends AbstractList