mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-08 08:48:39 +09:00
pt 1 in reviving the android build (copied from pm 28a1, wish me luck)
This commit is contained in:
parent
efa9662725
commit
d7788a6d6d
4249 changed files with 468189 additions and 0 deletions
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ConnectionClosedException.java
vendored
Normal file
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ConnectionClosedException.java
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Signals that the connection has been closed unexpectedly.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class ConnectionClosedException extends IOException {
|
||||
|
||||
private static final long serialVersionUID = 617550366255636674L;
|
||||
|
||||
/**
|
||||
* Creates a new ConnectionClosedException with the specified detail message.
|
||||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public ConnectionClosedException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
70
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ConnectionReuseStrategy.java
vendored
Normal file
70
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ConnectionReuseStrategy.java
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* Interface for deciding whether a connection can be re-used for
|
||||
* subsequent requests and should be kept alive.
|
||||
* <p>
|
||||
* Implementations of this interface must be thread-safe. Access to shared
|
||||
* data must be synchronized as methods of this interface may be executed
|
||||
* from multiple threads.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface ConnectionReuseStrategy {
|
||||
|
||||
/**
|
||||
* Decides whether a connection can be kept open after a request.
|
||||
* If this method returns <code>false</code>, the caller MUST
|
||||
* close the connection to correctly comply with the HTTP protocol.
|
||||
* If it returns <code>true</code>, the caller SHOULD attempt to
|
||||
* keep the connection open for reuse with another request.
|
||||
* <br/>
|
||||
* One can use the HTTP context to retrieve additional objects that
|
||||
* may be relevant for the keep-alive strategy: the actual HTTP
|
||||
* connection, the original HTTP request, target host if known,
|
||||
* number of times the connection has been reused already and so on.
|
||||
* <br/>
|
||||
* If the connection is already closed, <code>false</code> is returned.
|
||||
* The stale connection check MUST NOT be triggered by a
|
||||
* connection reuse strategy.
|
||||
*
|
||||
* @param response
|
||||
* The last response received over that connection.
|
||||
* @param context the context in which the connection is being
|
||||
* used.
|
||||
*
|
||||
* @return <code>true</code> if the connection is allowed to be reused, or
|
||||
* <code>false</code> if it MUST NOT be reused
|
||||
*/
|
||||
boolean keepAlive(HttpResponse response, HttpContext context);
|
||||
|
||||
}
|
||||
51
mobile/android/thirdparty/ch/boye/httpclientandroidlib/Consts.java
vendored
Normal file
51
mobile/android/thirdparty/ch/boye/httpclientandroidlib/Consts.java
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.nio.charset.Charset;
|
||||
|
||||
/**
|
||||
* Commons constants.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public final class Consts {
|
||||
|
||||
public static final int CR = 13; // <US-ASCII CR, carriage return (13)>
|
||||
public static final int LF = 10; // <US-ASCII LF, linefeed (10)>
|
||||
public static final int SP = 32; // <US-ASCII SP, space (32)>
|
||||
public static final int HT = 9; // <US-ASCII HT, horizontal-tab (9)>
|
||||
|
||||
public static final Charset UTF_8 = Charset.forName("UTF-8");
|
||||
public static final Charset ASCII = Charset.forName("US-ASCII");
|
||||
public static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
|
||||
|
||||
private Consts() {
|
||||
}
|
||||
|
||||
}
|
||||
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ContentTooLongException.java
vendored
Normal file
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ContentTooLongException.java
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Signals that HTTP entity content is too long.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public class ContentTooLongException extends IOException {
|
||||
|
||||
private static final long serialVersionUID = -924287689552495383L;
|
||||
|
||||
/**
|
||||
* Creates a new ContentTooLongException with the specified detail message.
|
||||
*
|
||||
* @param message exception message
|
||||
*/
|
||||
public ContentTooLongException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
60
mobile/android/thirdparty/ch/boye/httpclientandroidlib/FormattedHeader.java
vendored
Normal file
60
mobile/android/thirdparty/ch/boye/httpclientandroidlib/FormattedHeader.java
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import ch.boye.httpclientandroidlib.util.CharArrayBuffer;
|
||||
|
||||
/**
|
||||
* An HTTP header which is already formatted.
|
||||
* For example when headers are received, the original formatting
|
||||
* can be preserved. This allows for the header to be sent without
|
||||
* another formatting step.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface FormattedHeader extends Header {
|
||||
|
||||
/**
|
||||
* Obtains the buffer with the formatted header.
|
||||
* The returned buffer MUST NOT be modified.
|
||||
*
|
||||
* @return the formatted header, in a buffer that must not be modified
|
||||
*/
|
||||
CharArrayBuffer getBuffer();
|
||||
|
||||
/**
|
||||
* Obtains the start of the header value in the {@link #getBuffer buffer}.
|
||||
* By accessing the value in the buffer, creation of a temporary string
|
||||
* can be avoided.
|
||||
*
|
||||
* @return index of the first character of the header value
|
||||
* in the buffer returned by {@link #getBuffer getBuffer}.
|
||||
*/
|
||||
int getValuePos();
|
||||
|
||||
}
|
||||
74
mobile/android/thirdparty/ch/boye/httpclientandroidlib/Header.java
vendored
Normal file
74
mobile/android/thirdparty/ch/boye/httpclientandroidlib/Header.java
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* Represents an HTTP header field.
|
||||
*
|
||||
* <p>The HTTP header fields follow the same generic format as
|
||||
* that given in Section 3.1 of RFC 822. Each header field consists
|
||||
* of a name followed by a colon (":") and the field value. Field names
|
||||
* are case-insensitive. The field value MAY be preceded by any amount
|
||||
* of LWS, though a single SP is preferred.
|
||||
*
|
||||
*<pre>
|
||||
* message-header = field-name ":" [ field-value ]
|
||||
* field-name = token
|
||||
* field-value = *( field-content | LWS )
|
||||
* field-content = <the OCTETs making up the field-value
|
||||
* and consisting of either *TEXT or combinations
|
||||
* of token, separators, and quoted-string>
|
||||
*</pre>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface Header {
|
||||
|
||||
/**
|
||||
* Get the name of the Header.
|
||||
*
|
||||
* @return the name of the Header, never {@code null}
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Get the value of the Header.
|
||||
*
|
||||
* @return the value of the Header, may be {@code null}
|
||||
*/
|
||||
String getValue();
|
||||
|
||||
/**
|
||||
* Parses the value.
|
||||
*
|
||||
* @return an array of {@link HeaderElement} entries, may be empty, but is never {@code null}
|
||||
* @throws ParseException
|
||||
*/
|
||||
HeaderElement[] getElements() throws ParseException;
|
||||
|
||||
}
|
||||
108
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HeaderElement.java
vendored
Normal file
108
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HeaderElement.java
vendored
Normal file
|
|
@ -0,0 +1,108 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* One element of an HTTP {@link Header header} value consisting of
|
||||
* a name / value pair and a number of optional name / value parameters.
|
||||
* <p>
|
||||
* Some HTTP headers (such as the set-cookie header) have values that
|
||||
* can be decomposed into multiple elements. Such headers must be in the
|
||||
* following form:
|
||||
* </p>
|
||||
* <pre>
|
||||
* header = [ element ] *( "," [ element ] )
|
||||
* element = name [ "=" [ value ] ] *( ";" [ param ] )
|
||||
* param = name [ "=" [ value ] ]
|
||||
*
|
||||
* name = token
|
||||
* value = ( token | quoted-string )
|
||||
*
|
||||
* token = 1*<any char except "=", ",", ";", <"> and
|
||||
* white space>
|
||||
* quoted-string = <"> *( text | quoted-char ) <">
|
||||
* text = any char except <">
|
||||
* quoted-char = "\" char
|
||||
* </pre>
|
||||
* <p>
|
||||
* Any amount of white space is allowed between any part of the
|
||||
* header, element or param and is ignored. A missing value in any
|
||||
* element or param will be stored as the empty {@link String};
|
||||
* if the "=" is also missing <var>null</var> will be stored instead.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HeaderElement {
|
||||
|
||||
/**
|
||||
* Returns header element name.
|
||||
*
|
||||
* @return header element name
|
||||
*/
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Returns header element value.
|
||||
*
|
||||
* @return header element value
|
||||
*/
|
||||
String getValue();
|
||||
|
||||
/**
|
||||
* Returns an array of name / value pairs.
|
||||
*
|
||||
* @return array of name / value pairs
|
||||
*/
|
||||
NameValuePair[] getParameters();
|
||||
|
||||
/**
|
||||
* Returns the first parameter with the given name.
|
||||
*
|
||||
* @param name parameter name
|
||||
*
|
||||
* @return name / value pair
|
||||
*/
|
||||
NameValuePair getParameterByName(String name);
|
||||
|
||||
/**
|
||||
* Returns the total count of parameters.
|
||||
*
|
||||
* @return parameter count
|
||||
*/
|
||||
int getParameterCount();
|
||||
|
||||
/**
|
||||
* Returns parameter with the given index.
|
||||
*
|
||||
* @param index index
|
||||
* @return name / value pair
|
||||
*/
|
||||
NameValuePair getParameter(int index);
|
||||
|
||||
}
|
||||
|
||||
57
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HeaderElementIterator.java
vendored
Normal file
57
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HeaderElementIterator.java
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* A type-safe iterator for {@link HeaderElement} objects.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HeaderElementIterator extends Iterator<Object> {
|
||||
|
||||
/**
|
||||
* Indicates whether there is another header element in this
|
||||
* iteration.
|
||||
*
|
||||
* @return <code>true</code> if there is another header element,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
boolean hasNext();
|
||||
|
||||
/**
|
||||
* Obtains the next header element from this iteration.
|
||||
* This method should only be called while {@link #hasNext hasNext}
|
||||
* is true.
|
||||
*
|
||||
* @return the next header element in this iteration
|
||||
*/
|
||||
HeaderElement nextElement();
|
||||
|
||||
}
|
||||
56
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HeaderIterator.java
vendored
Normal file
56
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HeaderIterator.java
vendored
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* A type-safe iterator for {@link Header} objects.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HeaderIterator extends Iterator<Object> {
|
||||
|
||||
/**
|
||||
* Indicates whether there is another header in this iteration.
|
||||
*
|
||||
* @return <code>true</code> if there is another header,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
boolean hasNext();
|
||||
|
||||
/**
|
||||
* Obtains the next header from this iteration.
|
||||
* This method should only be called while {@link #hasNext hasNext}
|
||||
* is true.
|
||||
*
|
||||
* @return the next header in this iteration
|
||||
*/
|
||||
Header nextHeader();
|
||||
|
||||
}
|
||||
102
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpClientConnection.java
vendored
Normal file
102
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpClientConnection.java
vendored
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A client-side HTTP connection, which can be used for sending
|
||||
* requests and receiving responses.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpClientConnection extends HttpConnection {
|
||||
|
||||
/**
|
||||
* Checks if response data is available from the connection. May wait for
|
||||
* the specified time until some data becomes available. Note that some
|
||||
* implementations may completely ignore the timeout parameter.
|
||||
*
|
||||
* @param timeout the maximum time in milliseconds to wait for data
|
||||
* @return true if data is available; false if there was no data available
|
||||
* even after waiting for <code>timeout</code> milliseconds.
|
||||
* @throws IOException if an error happens on the connection
|
||||
*/
|
||||
boolean isResponseAvailable(int timeout)
|
||||
throws IOException;
|
||||
|
||||
/**
|
||||
* Sends the request line and all headers over the connection.
|
||||
* @param request the request whose headers to send.
|
||||
* @throws HttpException in case of HTTP protocol violation
|
||||
* @throws IOException in case of an I/O error
|
||||
*/
|
||||
void sendRequestHeader(HttpRequest request)
|
||||
throws HttpException, IOException;
|
||||
|
||||
/**
|
||||
* Sends the request entity over the connection.
|
||||
* @param request the request whose entity to send.
|
||||
* @throws HttpException in case of HTTP protocol violation
|
||||
* @throws IOException in case of an I/O error
|
||||
*/
|
||||
void sendRequestEntity(HttpEntityEnclosingRequest request)
|
||||
throws HttpException, IOException;
|
||||
|
||||
/**
|
||||
* Receives the request line and headers of the next response available from
|
||||
* this connection. The caller should examine the HttpResponse object to
|
||||
* find out if it should try to receive a response entity as well.
|
||||
*
|
||||
* @return a new HttpResponse object with status line and headers
|
||||
* initialized.
|
||||
* @throws HttpException in case of HTTP protocol violation
|
||||
* @throws IOException in case of an I/O error
|
||||
*/
|
||||
HttpResponse receiveResponseHeader()
|
||||
throws HttpException, IOException;
|
||||
|
||||
/**
|
||||
* Receives the next response entity available from this connection and
|
||||
* attaches it to an existing HttpResponse object.
|
||||
*
|
||||
* @param response the response to attach the entity to
|
||||
* @throws HttpException in case of HTTP protocol violation
|
||||
* @throws IOException in case of an I/O error
|
||||
*/
|
||||
void receiveResponseEntity(HttpResponse response)
|
||||
throws HttpException, IOException;
|
||||
|
||||
/**
|
||||
* Writes out all pending buffered data over the open connection.
|
||||
*
|
||||
* @throws IOException in case of an I/O error
|
||||
*/
|
||||
void flush() throws IOException;
|
||||
|
||||
}
|
||||
104
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpConnection.java
vendored
Normal file
104
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpConnection.java
vendored
Normal file
|
|
@ -0,0 +1,104 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.Closeable;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A generic HTTP connection, useful on client and server side.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpConnection extends Closeable {
|
||||
|
||||
/**
|
||||
* Closes this connection gracefully.
|
||||
* This method will attempt to flush the internal output
|
||||
* buffer prior to closing the underlying socket.
|
||||
* This method MUST NOT be called from a different thread to force
|
||||
* shutdown of the connection. Use {@link #shutdown shutdown} instead.
|
||||
*/
|
||||
void close() throws IOException;
|
||||
|
||||
/**
|
||||
* Checks if this connection is open.
|
||||
* @return true if it is open, false if it is closed.
|
||||
*/
|
||||
boolean isOpen();
|
||||
|
||||
/**
|
||||
* Checks whether this connection has gone down.
|
||||
* Network connections may get closed during some time of inactivity
|
||||
* for several reasons. The next time a read is attempted on such a
|
||||
* connection it will throw an IOException.
|
||||
* This method tries to alleviate this inconvenience by trying to
|
||||
* find out if a connection is still usable. Implementations may do
|
||||
* that by attempting a read with a very small timeout. Thus this
|
||||
* method may block for a small amount of time before returning a result.
|
||||
* It is therefore an <i>expensive</i> operation.
|
||||
*
|
||||
* @return <code>true</code> if attempts to use this connection are
|
||||
* likely to succeed, or <code>false</code> if they are likely
|
||||
* to fail and this connection should be closed
|
||||
*/
|
||||
boolean isStale();
|
||||
|
||||
/**
|
||||
* Sets the socket timeout value.
|
||||
*
|
||||
* @param timeout timeout value in milliseconds
|
||||
*/
|
||||
void setSocketTimeout(int timeout);
|
||||
|
||||
/**
|
||||
* Returns the socket timeout value.
|
||||
*
|
||||
* @return positive value in milliseconds if a timeout is set,
|
||||
* <code>0</code> if timeout is disabled or <code>-1</code> if
|
||||
* timeout is undefined.
|
||||
*/
|
||||
int getSocketTimeout();
|
||||
|
||||
/**
|
||||
* Force-closes this connection.
|
||||
* This is the only method of a connection which may be called
|
||||
* from a different thread to terminate the connection.
|
||||
* This method will not attempt to flush the transmitter's
|
||||
* internal buffer prior to closing the underlying socket.
|
||||
*/
|
||||
void shutdown() throws IOException;
|
||||
|
||||
/**
|
||||
* Returns a collection of connection metrics.
|
||||
*
|
||||
* @return HttpConnectionMetrics
|
||||
*/
|
||||
HttpConnectionMetrics getMetrics();
|
||||
|
||||
}
|
||||
42
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpConnectionFactory.java
vendored
Normal file
42
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpConnectionFactory.java
vendored
Normal file
|
|
@ -0,0 +1,42 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.Socket;
|
||||
|
||||
/**
|
||||
* Factory for {@link HttpConnection} instances.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public interface HttpConnectionFactory<T extends HttpConnection> {
|
||||
|
||||
T createConnection(Socket socket) throws IOException;
|
||||
|
||||
}
|
||||
77
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpConnectionMetrics.java
vendored
Normal file
77
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpConnectionMetrics.java
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* The point of access to the statistics of an {@link HttpConnection}.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpConnectionMetrics {
|
||||
|
||||
/**
|
||||
* Returns the number of requests transferred over the connection,
|
||||
* 0 if not available.
|
||||
*/
|
||||
long getRequestCount();
|
||||
|
||||
/**
|
||||
* Returns the number of responses transferred over the connection,
|
||||
* 0 if not available.
|
||||
*/
|
||||
long getResponseCount();
|
||||
|
||||
/**
|
||||
* Returns the number of bytes transferred over the connection,
|
||||
* 0 if not available.
|
||||
*/
|
||||
long getSentBytesCount();
|
||||
|
||||
/**
|
||||
* Returns the number of bytes transferred over the connection,
|
||||
* 0 if not available.
|
||||
*/
|
||||
long getReceivedBytesCount();
|
||||
|
||||
/**
|
||||
* Return the value for the specified metric.
|
||||
*
|
||||
*@param metricName the name of the metric to query.
|
||||
*
|
||||
*@return the object representing the metric requested,
|
||||
* <code>null</code> if the metric cannot not found.
|
||||
*/
|
||||
Object getMetric(String metricName);
|
||||
|
||||
/**
|
||||
* Resets the counts
|
||||
*
|
||||
*/
|
||||
void reset();
|
||||
|
||||
}
|
||||
199
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpEntity.java
vendored
Normal file
199
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpEntity.java
vendored
Normal file
|
|
@ -0,0 +1,199 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
/**
|
||||
* An entity that can be sent or received with an HTTP message.
|
||||
* Entities can be found in some
|
||||
* {@link HttpEntityEnclosingRequest requests} and in
|
||||
* {@link HttpResponse responses}, where they are optional.
|
||||
* <p>
|
||||
* There are three distinct types of entities in HttpCore,
|
||||
* depending on where their {@link #getContent content} originates:
|
||||
* <ul>
|
||||
* <li><b>streamed</b>: The content is received from a stream, or
|
||||
* generated on the fly. In particular, this category includes
|
||||
* entities being received from a {@link HttpConnection connection}.
|
||||
* {@link #isStreaming Streamed} entities are generally not
|
||||
* {@link #isRepeatable repeatable}.
|
||||
* </li>
|
||||
* <li><b>self-contained</b>: The content is in memory or obtained by
|
||||
* means that are independent from a connection or other entity.
|
||||
* Self-contained entities are generally {@link #isRepeatable repeatable}.
|
||||
* </li>
|
||||
* <li><b>wrapping</b>: The content is obtained from another entity.
|
||||
* </li>
|
||||
* </ul>
|
||||
* This distinction is important for connection management with incoming
|
||||
* entities. For entities that are created by an application and only sent
|
||||
* using the HTTP components framework, the difference between streamed
|
||||
* and self-contained is of little importance. In that case, it is suggested
|
||||
* to consider non-repeatable entities as streamed, and those that are
|
||||
* repeatable (without a huge effort) as self-contained.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpEntity {
|
||||
|
||||
/**
|
||||
* Tells if the entity is capable of producing its data more than once.
|
||||
* A repeatable entity's getContent() and writeTo(OutputStream) methods
|
||||
* can be called more than once whereas a non-repeatable entity's can not.
|
||||
* @return true if the entity is repeatable, false otherwise.
|
||||
*/
|
||||
boolean isRepeatable();
|
||||
|
||||
/**
|
||||
* Tells about chunked encoding for this entity.
|
||||
* The primary purpose of this method is to indicate whether
|
||||
* chunked encoding should be used when the entity is sent.
|
||||
* For entities that are received, it can also indicate whether
|
||||
* the entity was received with chunked encoding.
|
||||
* <br/>
|
||||
* The behavior of wrapping entities is implementation dependent,
|
||||
* but should respect the primary purpose.
|
||||
*
|
||||
* @return <code>true</code> if chunked encoding is preferred for this
|
||||
* entity, or <code>false</code> if it is not
|
||||
*/
|
||||
boolean isChunked();
|
||||
|
||||
/**
|
||||
* Tells the length of the content, if known.
|
||||
*
|
||||
* @return the number of bytes of the content, or
|
||||
* a negative number if unknown. If the content length is known
|
||||
* but exceeds {@link java.lang.Long#MAX_VALUE Long.MAX_VALUE},
|
||||
* a negative number is returned.
|
||||
*/
|
||||
long getContentLength();
|
||||
|
||||
/**
|
||||
* Obtains the Content-Type header, if known.
|
||||
* This is the header that should be used when sending the entity,
|
||||
* or the one that was received with the entity. It can include a
|
||||
* charset attribute.
|
||||
*
|
||||
* @return the Content-Type header for this entity, or
|
||||
* <code>null</code> if the content type is unknown
|
||||
*/
|
||||
Header getContentType();
|
||||
|
||||
/**
|
||||
* Obtains the Content-Encoding header, if known.
|
||||
* This is the header that should be used when sending the entity,
|
||||
* or the one that was received with the entity.
|
||||
* Wrapping entities that modify the content encoding should
|
||||
* adjust this header accordingly.
|
||||
*
|
||||
* @return the Content-Encoding header for this entity, or
|
||||
* <code>null</code> if the content encoding is unknown
|
||||
*/
|
||||
Header getContentEncoding();
|
||||
|
||||
/**
|
||||
* Returns a content stream of the entity.
|
||||
* {@link #isRepeatable Repeatable} entities are expected
|
||||
* to create a new instance of {@link InputStream} for each invocation
|
||||
* of this method and therefore can be consumed multiple times.
|
||||
* Entities that are not {@link #isRepeatable repeatable} are expected
|
||||
* to return the same {@link InputStream} instance and therefore
|
||||
* may not be consumed more than once.
|
||||
* <p>
|
||||
* IMPORTANT: Please note all entity implementations must ensure that
|
||||
* all allocated resources are properly deallocated after
|
||||
* the {@link InputStream#close()} method is invoked.
|
||||
*
|
||||
* @return content stream of the entity.
|
||||
*
|
||||
* @throws IOException if the stream could not be created
|
||||
* @throws IllegalStateException
|
||||
* if content stream cannot be created.
|
||||
*
|
||||
* @see #isRepeatable()
|
||||
*/
|
||||
InputStream getContent() throws IOException, IllegalStateException;
|
||||
|
||||
/**
|
||||
* Writes the entity content out to the output stream.
|
||||
* <p>
|
||||
* <p>
|
||||
* IMPORTANT: Please note all entity implementations must ensure that
|
||||
* all allocated resources are properly deallocated when this method
|
||||
* returns.
|
||||
*
|
||||
* @param outstream the output stream to write entity content to
|
||||
*
|
||||
* @throws IOException if an I/O error occurs
|
||||
*/
|
||||
void writeTo(OutputStream outstream) throws IOException;
|
||||
|
||||
/**
|
||||
* Tells whether this entity depends on an underlying stream.
|
||||
* Streamed entities that read data directly from the socket should
|
||||
* return <code>true</code>. Self-contained entities should return
|
||||
* <code>false</code>. Wrapping entities should delegate this call
|
||||
* to the wrapped entity.
|
||||
*
|
||||
* @return <code>true</code> if the entity content is streamed,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
boolean isStreaming(); // don't expect an exception here
|
||||
|
||||
/**
|
||||
* This method is deprecated since version 4.1. Please use standard
|
||||
* java convention to ensure resource deallocation by calling
|
||||
* {@link InputStream#close()} on the input stream returned by
|
||||
* {@link #getContent()}
|
||||
* <p>
|
||||
* This method is called to indicate that the content of this entity
|
||||
* is no longer required. All entity implementations are expected to
|
||||
* release all allocated resources as a result of this method
|
||||
* invocation. Content streaming entities are also expected to
|
||||
* dispose of the remaining content, if any. Wrapping entities should
|
||||
* delegate this call to the wrapped entity.
|
||||
* <p>
|
||||
* This method is of particular importance for entities being
|
||||
* received from a {@link HttpConnection connection}. The entity
|
||||
* needs to be consumed completely in order to re-use the connection
|
||||
* with keep-alive.
|
||||
*
|
||||
* @throws IOException if an I/O error occurs.
|
||||
*
|
||||
* @deprecated (4.1) Use {@link ch.boye.httpclientandroidlib.util.EntityUtils#consume(HttpEntity)}
|
||||
*
|
||||
* @see #getContent() and #writeTo(OutputStream)
|
||||
*/
|
||||
@Deprecated
|
||||
void consumeContent() throws IOException;
|
||||
|
||||
}
|
||||
60
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpEntityEnclosingRequest.java
vendored
Normal file
60
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpEntityEnclosingRequest.java
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* A request with an entity.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpEntityEnclosingRequest extends HttpRequest {
|
||||
|
||||
/**
|
||||
* Tells if this request should use the expect-continue handshake.
|
||||
* The expect continue handshake gives the server a chance to decide
|
||||
* whether to accept the entity enclosing request before the possibly
|
||||
* lengthy entity is sent across the wire.
|
||||
* @return true if the expect continue handshake should be used, false if
|
||||
* not.
|
||||
*/
|
||||
boolean expectContinue();
|
||||
|
||||
/**
|
||||
* Associates the entity with this request.
|
||||
*
|
||||
* @param entity the entity to send.
|
||||
*/
|
||||
void setEntity(HttpEntity entity);
|
||||
|
||||
/**
|
||||
* Returns the entity associated with this request.
|
||||
*
|
||||
* @return entity
|
||||
*/
|
||||
HttpEntity getEntity();
|
||||
|
||||
}
|
||||
67
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpException.java
vendored
Normal file
67
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpException.java
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* Signals that an HTTP exception has occurred.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class HttpException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = -5437299376222011036L;
|
||||
|
||||
/**
|
||||
* Creates a new HttpException with a <tt>null</tt> detail message.
|
||||
*/
|
||||
public HttpException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new HttpException with the specified detail message.
|
||||
*
|
||||
* @param message the exception detail message
|
||||
*/
|
||||
public HttpException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new HttpException with the specified detail message and cause.
|
||||
*
|
||||
* @param message the exception detail message
|
||||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public HttpException(final String message, final Throwable cause) {
|
||||
super(message);
|
||||
initCause(cause);
|
||||
}
|
||||
|
||||
}
|
||||
206
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpHeaders.java
vendored
Normal file
206
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpHeaders.java
vendored
Normal file
|
|
@ -0,0 +1,206 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* Constants enumerating the HTTP headers. All headers defined in RFC1945 (HTTP/1.0), RFC2616 (HTTP/1.1), and RFC2518
|
||||
* (WebDAV) are listed.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public final class HttpHeaders {
|
||||
|
||||
private HttpHeaders() {
|
||||
}
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.1 */
|
||||
public static final String ACCEPT = "Accept";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.2 */
|
||||
public static final String ACCEPT_CHARSET = "Accept-Charset";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.3 */
|
||||
public static final String ACCEPT_ENCODING = "Accept-Encoding";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.4 */
|
||||
public static final String ACCEPT_LANGUAGE = "Accept-Language";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.5 */
|
||||
public static final String ACCEPT_RANGES = "Accept-Ranges";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.6 */
|
||||
public static final String AGE = "Age";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.1, RFC 2616 (HTTP/1.1) Section 14.7 */
|
||||
public static final String ALLOW = "Allow";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.2, RFC 2616 (HTTP/1.1) Section 14.8 */
|
||||
public static final String AUTHORIZATION = "Authorization";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.9 */
|
||||
public static final String CACHE_CONTROL = "Cache-Control";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.10 */
|
||||
public static final String CONNECTION = "Connection";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.3, RFC 2616 (HTTP/1.1) Section 14.11 */
|
||||
public static final String CONTENT_ENCODING = "Content-Encoding";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.12 */
|
||||
public static final String CONTENT_LANGUAGE = "Content-Language";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.4, RFC 2616 (HTTP/1.1) Section 14.13 */
|
||||
public static final String CONTENT_LENGTH = "Content-Length";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.14 */
|
||||
public static final String CONTENT_LOCATION = "Content-Location";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.15 */
|
||||
public static final String CONTENT_MD5 = "Content-MD5";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.16 */
|
||||
public static final String CONTENT_RANGE = "Content-Range";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.5, RFC 2616 (HTTP/1.1) Section 14.17 */
|
||||
public static final String CONTENT_TYPE = "Content-Type";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.6, RFC 2616 (HTTP/1.1) Section 14.18 */
|
||||
public static final String DATE = "Date";
|
||||
|
||||
/** RFC 2518 (WevDAV) Section 9.1 */
|
||||
public static final String DAV = "Dav";
|
||||
|
||||
/** RFC 2518 (WevDAV) Section 9.2 */
|
||||
public static final String DEPTH = "Depth";
|
||||
|
||||
/** RFC 2518 (WevDAV) Section 9.3 */
|
||||
public static final String DESTINATION = "Destination";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.19 */
|
||||
public static final String ETAG = "ETag";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.20 */
|
||||
public static final String EXPECT = "Expect";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.7, RFC 2616 (HTTP/1.1) Section 14.21 */
|
||||
public static final String EXPIRES = "Expires";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.8, RFC 2616 (HTTP/1.1) Section 14.22 */
|
||||
public static final String FROM = "From";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.23 */
|
||||
public static final String HOST = "Host";
|
||||
|
||||
/** RFC 2518 (WevDAV) Section 9.4 */
|
||||
public static final String IF = "If";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.24 */
|
||||
public static final String IF_MATCH = "If-Match";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.9, RFC 2616 (HTTP/1.1) Section 14.25 */
|
||||
public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.26 */
|
||||
public static final String IF_NONE_MATCH = "If-None-Match";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.27 */
|
||||
public static final String IF_RANGE = "If-Range";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.28 */
|
||||
public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.10, RFC 2616 (HTTP/1.1) Section 14.29 */
|
||||
public static final String LAST_MODIFIED = "Last-Modified";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.11, RFC 2616 (HTTP/1.1) Section 14.30 */
|
||||
public static final String LOCATION = "Location";
|
||||
|
||||
/** RFC 2518 (WevDAV) Section 9.5 */
|
||||
public static final String LOCK_TOKEN = "Lock-Token";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.31 */
|
||||
public static final String MAX_FORWARDS = "Max-Forwards";
|
||||
|
||||
/** RFC 2518 (WevDAV) Section 9.6 */
|
||||
public static final String OVERWRITE = "Overwrite";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.12, RFC 2616 (HTTP/1.1) Section 14.32 */
|
||||
public static final String PRAGMA = "Pragma";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.33 */
|
||||
public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.34 */
|
||||
public static final String PROXY_AUTHORIZATION = "Proxy-Authorization";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.35 */
|
||||
public static final String RANGE = "Range";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.13, RFC 2616 (HTTP/1.1) Section 14.36 */
|
||||
public static final String REFERER = "Referer";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.37 */
|
||||
public static final String RETRY_AFTER = "Retry-After";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.14, RFC 2616 (HTTP/1.1) Section 14.38 */
|
||||
public static final String SERVER = "Server";
|
||||
|
||||
/** RFC 2518 (WevDAV) Section 9.7 */
|
||||
public static final String STATUS_URI = "Status-URI";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.39 */
|
||||
public static final String TE = "TE";
|
||||
|
||||
/** RFC 2518 (WevDAV) Section 9.8 */
|
||||
public static final String TIMEOUT = "Timeout";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.40 */
|
||||
public static final String TRAILER = "Trailer";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.41 */
|
||||
public static final String TRANSFER_ENCODING = "Transfer-Encoding";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.42 */
|
||||
public static final String UPGRADE = "Upgrade";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.15, RFC 2616 (HTTP/1.1) Section 14.43 */
|
||||
public static final String USER_AGENT = "User-Agent";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.44 */
|
||||
public static final String VARY = "Vary";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.45 */
|
||||
public static final String VIA = "Via";
|
||||
|
||||
/** RFC 2616 (HTTP/1.1) Section 14.46 */
|
||||
public static final String WARNING = "Warning";
|
||||
|
||||
/** RFC 1945 (HTTP/1.0) Section 10.16, RFC 2616 (HTTP/1.1) Section 14.47 */
|
||||
public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
|
||||
|
||||
}
|
||||
290
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpHost.java
vendored
Normal file
290
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpHost.java
vendored
Normal file
|
|
@ -0,0 +1,290 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.net.InetAddress;
|
||||
import java.util.Locale;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
import ch.boye.httpclientandroidlib.util.LangUtils;
|
||||
|
||||
/**
|
||||
* Holds all of the variables needed to describe an HTTP connection to a host.
|
||||
* This includes remote host name, port and scheme.
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public final class HttpHost implements Cloneable, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7529410654042457626L;
|
||||
|
||||
/** The default scheme is "http". */
|
||||
public static final String DEFAULT_SCHEME_NAME = "http";
|
||||
|
||||
/** The host to use. */
|
||||
protected final String hostname;
|
||||
|
||||
/** The lowercase host, for {@link #equals} and {@link #hashCode}. */
|
||||
protected final String lcHostname;
|
||||
|
||||
|
||||
/** The port to use, defaults to -1 if not set. */
|
||||
protected final int port;
|
||||
|
||||
/** The scheme (lowercased) */
|
||||
protected final String schemeName;
|
||||
|
||||
protected final InetAddress address;
|
||||
|
||||
/**
|
||||
* Creates a new {@link HttpHost HttpHost}, specifying all values.
|
||||
* Constructor for HttpHost.
|
||||
*
|
||||
* @param hostname the hostname (IP or DNS name)
|
||||
* @param port the port number.
|
||||
* <code>-1</code> indicates the scheme default port.
|
||||
* @param scheme the name of the scheme.
|
||||
* <code>null</code> indicates the
|
||||
* {@link #DEFAULT_SCHEME_NAME default scheme}
|
||||
*/
|
||||
public HttpHost(final String hostname, final int port, final String scheme) {
|
||||
super();
|
||||
this.hostname = Args.notBlank(hostname, "Host name");
|
||||
this.lcHostname = hostname.toLowerCase(Locale.ENGLISH);
|
||||
if (scheme != null) {
|
||||
this.schemeName = scheme.toLowerCase(Locale.ENGLISH);
|
||||
} else {
|
||||
this.schemeName = DEFAULT_SCHEME_NAME;
|
||||
}
|
||||
this.port = port;
|
||||
this.address = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link HttpHost HttpHost}, with default scheme.
|
||||
*
|
||||
* @param hostname the hostname (IP or DNS name)
|
||||
* @param port the port number.
|
||||
* <code>-1</code> indicates the scheme default port.
|
||||
*/
|
||||
public HttpHost(final String hostname, final int port) {
|
||||
this(hostname, port, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link HttpHost HttpHost}, with default scheme and port.
|
||||
*
|
||||
* @param hostname the hostname (IP or DNS name)
|
||||
*/
|
||||
public HttpHost(final String hostname) {
|
||||
this(hostname, -1, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link HttpHost HttpHost}, specifying all values.
|
||||
* Constructor for HttpHost.
|
||||
*
|
||||
* @param address the inet address.
|
||||
* @param port the port number.
|
||||
* <code>-1</code> indicates the scheme default port.
|
||||
* @param scheme the name of the scheme.
|
||||
* <code>null</code> indicates the
|
||||
* {@link #DEFAULT_SCHEME_NAME default scheme}
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public HttpHost(final InetAddress address, final int port, final String scheme) {
|
||||
super();
|
||||
this.address = Args.notNull(address, "Inet address");
|
||||
this.hostname = address.getHostAddress();
|
||||
this.lcHostname = this.hostname.toLowerCase(Locale.ENGLISH);
|
||||
if (scheme != null) {
|
||||
this.schemeName = scheme.toLowerCase(Locale.ENGLISH);
|
||||
} else {
|
||||
this.schemeName = DEFAULT_SCHEME_NAME;
|
||||
}
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link HttpHost HttpHost}, with default scheme.
|
||||
*
|
||||
* @param address the inet address.
|
||||
* @param port the port number.
|
||||
* <code>-1</code> indicates the scheme default port.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public HttpHost(final InetAddress address, final int port) {
|
||||
this(address, port, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new {@link HttpHost HttpHost}, with default scheme and port.
|
||||
*
|
||||
* @param address the inet address.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public HttpHost(final InetAddress address) {
|
||||
this(address, -1, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Copy constructor for {@link HttpHost HttpHost}.
|
||||
*
|
||||
* @param httphost the HTTP host to copy details from
|
||||
*/
|
||||
public HttpHost (final HttpHost httphost) {
|
||||
super();
|
||||
Args.notNull(httphost, "HTTP host");
|
||||
this.hostname = httphost.hostname;
|
||||
this.lcHostname = httphost.lcHostname;
|
||||
this.schemeName = httphost.schemeName;
|
||||
this.port = httphost.port;
|
||||
this.address = httphost.address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the host name.
|
||||
*
|
||||
* @return the host name (IP or DNS name)
|
||||
*/
|
||||
public String getHostName() {
|
||||
return this.hostname;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the port.
|
||||
*
|
||||
* @return the host port, or <code>-1</code> if not set
|
||||
*/
|
||||
public int getPort() {
|
||||
return this.port;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the scheme name.
|
||||
*
|
||||
* @return the scheme name
|
||||
*/
|
||||
public String getSchemeName() {
|
||||
return this.schemeName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the inet address if explicitly set by a constructor,
|
||||
* <code>null</code> otherwise.
|
||||
* @return the inet address
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public InetAddress getAddress() {
|
||||
return this.address;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the host URI, as a string.
|
||||
*
|
||||
* @return the host URI
|
||||
*/
|
||||
public String toURI() {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buffer.append(this.schemeName);
|
||||
buffer.append("://");
|
||||
buffer.append(this.hostname);
|
||||
if (this.port != -1) {
|
||||
buffer.append(':');
|
||||
buffer.append(Integer.toString(this.port));
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the host string, without scheme prefix.
|
||||
*
|
||||
* @return the host string, for example <code>localhost:8080</code>
|
||||
*/
|
||||
public String toHostString() {
|
||||
if (this.port != -1) {
|
||||
//the highest port number is 65535, which is length 6 with the addition of the colon
|
||||
final StringBuilder buffer = new StringBuilder(this.hostname.length() + 6);
|
||||
buffer.append(this.hostname);
|
||||
buffer.append(":");
|
||||
buffer.append(Integer.toString(this.port));
|
||||
return buffer.toString();
|
||||
} else {
|
||||
return this.hostname;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return toURI();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj instanceof HttpHost) {
|
||||
final HttpHost that = (HttpHost) obj;
|
||||
return this.lcHostname.equals(that.lcHostname)
|
||||
&& this.port == that.port
|
||||
&& this.schemeName.equals(that.schemeName);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = LangUtils.HASH_SEED;
|
||||
hash = LangUtils.hashCode(hash, this.lcHostname);
|
||||
hash = LangUtils.hashCode(hash, this.port);
|
||||
hash = LangUtils.hashCode(hash, this.schemeName);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
}
|
||||
47
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpInetConnection.java
vendored
Normal file
47
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpInetConnection.java
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.net.InetAddress;
|
||||
|
||||
/**
|
||||
* An HTTP connection over the Internet Protocol (IP).
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpInetConnection extends HttpConnection {
|
||||
|
||||
InetAddress getLocalAddress();
|
||||
|
||||
int getLocalPort();
|
||||
|
||||
InetAddress getRemoteAddress();
|
||||
|
||||
int getRemotePort();
|
||||
|
||||
}
|
||||
210
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpMessage.java
vendored
Normal file
210
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpMessage.java
vendored
Normal file
|
|
@ -0,0 +1,210 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import ch.boye.httpclientandroidlib.params.HttpParams;
|
||||
|
||||
/**
|
||||
* HTTP messages consist of requests from client to server and responses
|
||||
* from server to client.
|
||||
* <pre>
|
||||
* HTTP-message = Request | Response ; HTTP/1.1 messages
|
||||
* </pre>
|
||||
* <p>
|
||||
* HTTP messages use the generic message format of RFC 822 for
|
||||
* transferring entities (the payload of the message). Both types
|
||||
* of message consist of a start-line, zero or more header fields
|
||||
* (also known as "headers"), an empty line (i.e., a line with nothing
|
||||
* preceding the CRLF) indicating the end of the header fields,
|
||||
* and possibly a message-body.
|
||||
* </p>
|
||||
* <pre>
|
||||
* generic-message = start-line
|
||||
* *(message-header CRLF)
|
||||
* CRLF
|
||||
* [ message-body ]
|
||||
* start-line = Request-Line | Status-Line
|
||||
* </pre>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface HttpMessage {
|
||||
|
||||
/**
|
||||
* Returns the protocol version this message is compatible with.
|
||||
*/
|
||||
ProtocolVersion getProtocolVersion();
|
||||
|
||||
/**
|
||||
* Checks if a certain header is present in this message. Header values are
|
||||
* ignored.
|
||||
*
|
||||
* @param name the header name to check for.
|
||||
* @return true if at least one header with this name is present.
|
||||
*/
|
||||
boolean containsHeader(String name);
|
||||
|
||||
/**
|
||||
* Returns all the headers with a specified name of this message. Header values
|
||||
* are ignored. Headers are orderd in the sequence they will be sent over a
|
||||
* connection.
|
||||
*
|
||||
* @param name the name of the headers to return.
|
||||
* @return the headers whose name property equals <code>name</code>.
|
||||
*/
|
||||
Header[] getHeaders(String name);
|
||||
|
||||
/**
|
||||
* Returns the first header with a specified name of this message. Header
|
||||
* values are ignored. If there is more than one matching header in the
|
||||
* message the first element of {@link #getHeaders(String)} is returned.
|
||||
* If there is no matching header in the message <code>null</code> is
|
||||
* returned.
|
||||
*
|
||||
* @param name the name of the header to return.
|
||||
* @return the first header whose name property equals <code>name</code>
|
||||
* or <code>null</code> if no such header could be found.
|
||||
*/
|
||||
Header getFirstHeader(String name);
|
||||
|
||||
/**
|
||||
* Returns the last header with a specified name of this message. Header values
|
||||
* are ignored. If there is more than one matching header in the message the
|
||||
* last element of {@link #getHeaders(String)} is returned. If there is no
|
||||
* matching header in the message <code>null</code> is returned.
|
||||
*
|
||||
* @param name the name of the header to return.
|
||||
* @return the last header whose name property equals <code>name</code>.
|
||||
* or <code>null</code> if no such header could be found.
|
||||
*/
|
||||
Header getLastHeader(String name);
|
||||
|
||||
/**
|
||||
* Returns all the headers of this message. Headers are orderd in the sequence
|
||||
* they will be sent over a connection.
|
||||
*
|
||||
* @return all the headers of this message
|
||||
*/
|
||||
Header[] getAllHeaders();
|
||||
|
||||
/**
|
||||
* Adds a header to this message. The header will be appended to the end of
|
||||
* the list.
|
||||
*
|
||||
* @param header the header to append.
|
||||
*/
|
||||
void addHeader(Header header);
|
||||
|
||||
/**
|
||||
* Adds a header to this message. The header will be appended to the end of
|
||||
* the list.
|
||||
*
|
||||
* @param name the name of the header.
|
||||
* @param value the value of the header.
|
||||
*/
|
||||
void addHeader(String name, String value);
|
||||
|
||||
/**
|
||||
* Overwrites the first header with the same name. The new header will be appended to
|
||||
* the end of the list, if no header with the given name can be found.
|
||||
*
|
||||
* @param header the header to set.
|
||||
*/
|
||||
void setHeader(Header header);
|
||||
|
||||
/**
|
||||
* Overwrites the first header with the same name. The new header will be appended to
|
||||
* the end of the list, if no header with the given name can be found.
|
||||
*
|
||||
* @param name the name of the header.
|
||||
* @param value the value of the header.
|
||||
*/
|
||||
void setHeader(String name, String value);
|
||||
|
||||
/**
|
||||
* Overwrites all the headers in the message.
|
||||
*
|
||||
* @param headers the array of headers to set.
|
||||
*/
|
||||
void setHeaders(Header[] headers);
|
||||
|
||||
/**
|
||||
* Removes a header from this message.
|
||||
*
|
||||
* @param header the header to remove.
|
||||
*/
|
||||
void removeHeader(Header header);
|
||||
|
||||
/**
|
||||
* Removes all headers with a certain name from this message.
|
||||
*
|
||||
* @param name The name of the headers to remove.
|
||||
*/
|
||||
void removeHeaders(String name);
|
||||
|
||||
/**
|
||||
* Returns an iterator of all the headers.
|
||||
*
|
||||
* @return Iterator that returns Header objects in the sequence they are
|
||||
* sent over a connection.
|
||||
*/
|
||||
HeaderIterator headerIterator();
|
||||
|
||||
/**
|
||||
* Returns an iterator of the headers with a given name.
|
||||
*
|
||||
* @param name the name of the headers over which to iterate, or
|
||||
* <code>null</code> for all headers
|
||||
*
|
||||
* @return Iterator that returns Header objects with the argument name
|
||||
* in the sequence they are sent over a connection.
|
||||
*/
|
||||
HeaderIterator headerIterator(String name);
|
||||
|
||||
/**
|
||||
* Returns the parameters effective for this message as set by
|
||||
* {@link #setParams(HttpParams)}.
|
||||
*
|
||||
* @deprecated (4.3) use configuration classes provided 'ch.boye.httpclientandroidlib.config'
|
||||
* and 'ch.boye.httpclientandroidlib.client.config'
|
||||
*/
|
||||
@Deprecated
|
||||
HttpParams getParams();
|
||||
|
||||
/**
|
||||
* Provides parameters to be used for the processing of this message.
|
||||
* @param params the parameters
|
||||
*
|
||||
* @deprecated (4.3) use configuration classes provided 'ch.boye.httpclientandroidlib.config'
|
||||
* and 'ch.boye.httpclientandroidlib.client.config'
|
||||
*/
|
||||
@Deprecated
|
||||
void setParams(HttpParams params);
|
||||
|
||||
}
|
||||
53
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpRequest.java
vendored
Normal file
53
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpRequest.java
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* A request message from a client to a server includes, within the
|
||||
* first line of that message, the method to be applied to the resource,
|
||||
* the identifier of the resource, and the protocol version in use.
|
||||
* <pre>
|
||||
* Request = Request-Line
|
||||
* *(( general-header
|
||||
* | request-header
|
||||
* | entity-header ) CRLF)
|
||||
* CRLF
|
||||
* [ message-body ]
|
||||
* </pre>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpRequest extends HttpMessage {
|
||||
|
||||
/**
|
||||
* Returns the request line of this request.
|
||||
* @return the request line.
|
||||
*/
|
||||
RequestLine getRequestLine();
|
||||
|
||||
}
|
||||
43
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpRequestFactory.java
vendored
Normal file
43
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpRequestFactory.java
vendored
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* A factory for {@link HttpRequest HttpRequest} objects.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpRequestFactory {
|
||||
|
||||
HttpRequest newHttpRequest(RequestLine requestline)
|
||||
throws MethodNotSupportedException;
|
||||
|
||||
HttpRequest newHttpRequest(String method, String uri)
|
||||
throws MethodNotSupportedException;
|
||||
|
||||
}
|
||||
68
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpRequestInterceptor.java
vendored
Normal file
68
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpRequestInterceptor.java
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* HTTP protocol interceptor is a routine that implements a specific aspect of
|
||||
* the HTTP protocol. Usually protocol interceptors are expected to act upon
|
||||
* one specific header or a group of related headers of the incoming message
|
||||
* or populate the outgoing message with one specific header or a group of
|
||||
* related headers.
|
||||
* <p>
|
||||
* Protocol Interceptors can also manipulate content entities enclosed with messages.
|
||||
* Usually this is accomplished by using the 'Decorator' pattern where a wrapper
|
||||
* entity class is used to decorate the original entity.
|
||||
* <p>
|
||||
* Protocol interceptors must be implemented as thread-safe. Similarly to
|
||||
* servlets, protocol interceptors should not use instance variables unless
|
||||
* access to those variables is synchronized.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpRequestInterceptor {
|
||||
|
||||
/**
|
||||
* Processes a request.
|
||||
* On the client side, this step is performed before the request is
|
||||
* sent to the server. On the server side, this step is performed
|
||||
* on incoming messages before the message body is evaluated.
|
||||
*
|
||||
* @param request the request to preprocess
|
||||
* @param context the context for the request
|
||||
*
|
||||
* @throws HttpException in case of an HTTP protocol violation
|
||||
* @throws IOException in case of an I/O error
|
||||
*/
|
||||
void process(HttpRequest request, HttpContext context)
|
||||
throws HttpException, IOException;
|
||||
|
||||
}
|
||||
155
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpResponse.java
vendored
Normal file
155
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpResponse.java
vendored
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* After receiving and interpreting a request message, a server responds
|
||||
* with an HTTP response message.
|
||||
* <pre>
|
||||
* Response = Status-Line
|
||||
* *(( general-header
|
||||
* | response-header
|
||||
* | entity-header ) CRLF)
|
||||
* CRLF
|
||||
* [ message-body ]
|
||||
* </pre>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpResponse extends HttpMessage {
|
||||
|
||||
/**
|
||||
* Obtains the status line of this response.
|
||||
* The status line can be set using one of the
|
||||
* {@link #setStatusLine setStatusLine} methods,
|
||||
* or it can be initialized in a constructor.
|
||||
*
|
||||
* @return the status line, or <code>null</code> if not yet set
|
||||
*/
|
||||
StatusLine getStatusLine();
|
||||
|
||||
/**
|
||||
* Sets the status line of this response.
|
||||
*
|
||||
* @param statusline the status line of this response
|
||||
*/
|
||||
void setStatusLine(StatusLine statusline);
|
||||
|
||||
/**
|
||||
* Sets the status line of this response.
|
||||
* The reason phrase will be determined based on the current
|
||||
* {@link #getLocale locale}.
|
||||
*
|
||||
* @param ver the HTTP version
|
||||
* @param code the status code
|
||||
*/
|
||||
void setStatusLine(ProtocolVersion ver, int code);
|
||||
|
||||
/**
|
||||
* Sets the status line of this response with a reason phrase.
|
||||
*
|
||||
* @param ver the HTTP version
|
||||
* @param code the status code
|
||||
* @param reason the reason phrase, or <code>null</code> to omit
|
||||
*/
|
||||
void setStatusLine(ProtocolVersion ver, int code, String reason);
|
||||
|
||||
/**
|
||||
* Updates the status line of this response with a new status code.
|
||||
*
|
||||
* @param code the HTTP status code.
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* if the status line has not be set
|
||||
*
|
||||
* @see HttpStatus
|
||||
* @see #setStatusLine(StatusLine)
|
||||
* @see #setStatusLine(ProtocolVersion,int)
|
||||
*/
|
||||
void setStatusCode(int code)
|
||||
throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Updates the status line of this response with a new reason phrase.
|
||||
*
|
||||
* @param reason the new reason phrase as a single-line string, or
|
||||
* <code>null</code> to unset the reason phrase
|
||||
*
|
||||
* @throws IllegalStateException
|
||||
* if the status line has not be set
|
||||
*
|
||||
* @see #setStatusLine(StatusLine)
|
||||
* @see #setStatusLine(ProtocolVersion,int)
|
||||
*/
|
||||
void setReasonPhrase(String reason)
|
||||
throws IllegalStateException;
|
||||
|
||||
/**
|
||||
* Obtains the message entity of this response, if any.
|
||||
* The entity is provided by calling {@link #setEntity setEntity}.
|
||||
*
|
||||
* @return the response entity, or
|
||||
* <code>null</code> if there is none
|
||||
*/
|
||||
HttpEntity getEntity();
|
||||
|
||||
/**
|
||||
* Associates a response entity with this response.
|
||||
* <p/>
|
||||
* Please note that if an entity has already been set for this response and it depends on
|
||||
* an input stream ({@link HttpEntity#isStreaming()} returns <code>true</code>),
|
||||
* it must be fully consumed in order to ensure release of resources.
|
||||
*
|
||||
* @param entity the entity to associate with this response, or
|
||||
* <code>null</code> to unset
|
||||
*
|
||||
* @see HttpEntity#isStreaming()
|
||||
* @see ch.boye.httpclientandroidlib.util.EntityUtils#updateEntity(HttpResponse, HttpEntity)
|
||||
*/
|
||||
void setEntity(HttpEntity entity);
|
||||
|
||||
/**
|
||||
* Obtains the locale of this response.
|
||||
* The locale is used to determine the reason phrase
|
||||
* for the {@link #setStatusCode status code}.
|
||||
* It can be changed using {@link #setLocale setLocale}.
|
||||
*
|
||||
* @return the locale of this response, never <code>null</code>
|
||||
*/
|
||||
Locale getLocale();
|
||||
|
||||
/**
|
||||
* Changes the locale of this response.
|
||||
*
|
||||
* @param loc the new locale
|
||||
*/
|
||||
void setLocale(Locale loc);
|
||||
|
||||
}
|
||||
67
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpResponseFactory.java
vendored
Normal file
67
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpResponseFactory.java
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* A factory for {@link HttpResponse HttpResponse} objects.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpResponseFactory {
|
||||
|
||||
/**
|
||||
* Creates a new response from status line elements.
|
||||
*
|
||||
* @param ver the protocol version
|
||||
* @param status the status code
|
||||
* @param context the context from which to determine the locale
|
||||
* for looking up a reason phrase to the status code, or
|
||||
* <code>null</code> to use the default locale
|
||||
*
|
||||
* @return the new response with an initialized status line
|
||||
*/
|
||||
HttpResponse newHttpResponse(ProtocolVersion ver, int status,
|
||||
HttpContext context);
|
||||
|
||||
/**
|
||||
* Creates a new response from a status line.
|
||||
*
|
||||
* @param statusline the status line
|
||||
* @param context the context from which to determine the locale
|
||||
* for looking up a reason phrase if the status code
|
||||
* is updated, or
|
||||
* <code>null</code> to use the default locale
|
||||
*
|
||||
* @return the new response with the argument status line
|
||||
*/
|
||||
HttpResponse newHttpResponse(StatusLine statusline,
|
||||
HttpContext context);
|
||||
|
||||
}
|
||||
68
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpResponseInterceptor.java
vendored
Normal file
68
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpResponseInterceptor.java
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* HTTP protocol interceptor is a routine that implements a specific aspect of
|
||||
* the HTTP protocol. Usually protocol interceptors are expected to act upon
|
||||
* one specific header or a group of related headers of the incoming message
|
||||
* or populate the outgoing message with one specific header or a group of
|
||||
* related headers. Protocol
|
||||
* <p>
|
||||
* Interceptors can also manipulate content entities enclosed with messages.
|
||||
* Usually this is accomplished by using the 'Decorator' pattern where a wrapper
|
||||
* entity class is used to decorate the original entity.
|
||||
* <p>
|
||||
* Protocol interceptors must be implemented as thread-safe. Similarly to
|
||||
* servlets, protocol interceptors should not use instance variables unless
|
||||
* access to those variables is synchronized.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpResponseInterceptor {
|
||||
|
||||
/**
|
||||
* Processes a response.
|
||||
* On the server side, this step is performed before the response is
|
||||
* sent to the client. On the client side, this step is performed
|
||||
* on incoming messages before the message body is evaluated.
|
||||
*
|
||||
* @param response the response to postprocess
|
||||
* @param context the context for the request
|
||||
*
|
||||
* @throws HttpException in case of an HTTP protocol violation
|
||||
* @throws IOException in case of an I/O error
|
||||
*/
|
||||
void process(HttpResponse response, HttpContext context)
|
||||
throws HttpException, IOException;
|
||||
|
||||
}
|
||||
88
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpServerConnection.java
vendored
Normal file
88
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpServerConnection.java
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A server-side HTTP connection, which can be used for receiving
|
||||
* requests and sending responses.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpServerConnection extends HttpConnection {
|
||||
|
||||
/**
|
||||
* Receives the request line and all headers available from this connection.
|
||||
* The caller should examine the returned request and decide if to receive a
|
||||
* request entity as well.
|
||||
*
|
||||
* @return a new HttpRequest object whose request line and headers are
|
||||
* initialized.
|
||||
* @throws HttpException in case of HTTP protocol violation
|
||||
* @throws IOException in case of an I/O error
|
||||
*/
|
||||
HttpRequest receiveRequestHeader()
|
||||
throws HttpException, IOException;
|
||||
|
||||
/**
|
||||
* Receives the next request entity available from this connection and attaches it to
|
||||
* an existing request.
|
||||
* @param request the request to attach the entity to.
|
||||
* @throws HttpException in case of HTTP protocol violation
|
||||
* @throws IOException in case of an I/O error
|
||||
*/
|
||||
void receiveRequestEntity(HttpEntityEnclosingRequest request)
|
||||
throws HttpException, IOException;
|
||||
|
||||
/**
|
||||
* Sends the response line and headers of a response over this connection.
|
||||
* @param response the response whose headers to send.
|
||||
* @throws HttpException in case of HTTP protocol violation
|
||||
* @throws IOException in case of an I/O error
|
||||
*/
|
||||
void sendResponseHeader(HttpResponse response)
|
||||
throws HttpException, IOException;
|
||||
|
||||
/**
|
||||
* Sends the response entity of a response over this connection.
|
||||
* @param response the response whose entity to send.
|
||||
* @throws HttpException in case of HTTP protocol violation
|
||||
* @throws IOException in case of an I/O error
|
||||
*/
|
||||
void sendResponseEntity(HttpResponse response)
|
||||
throws HttpException, IOException;
|
||||
|
||||
/**
|
||||
* Sends all pending buffered data over this connection.
|
||||
* @throws IOException in case of an I/O error
|
||||
*/
|
||||
void flush()
|
||||
throws IOException;
|
||||
|
||||
}
|
||||
175
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpStatus.java
vendored
Normal file
175
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpStatus.java
vendored
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* Constants enumerating the HTTP status codes.
|
||||
* All status codes defined in RFC1945 (HTTP/1.0), RFC2616 (HTTP/1.1), and
|
||||
* RFC2518 (WebDAV) are listed.
|
||||
*
|
||||
* @see StatusLine
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpStatus {
|
||||
|
||||
// --- 1xx Informational ---
|
||||
|
||||
/** <tt>100 Continue</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_CONTINUE = 100;
|
||||
/** <tt>101 Switching Protocols</tt> (HTTP/1.1 - RFC 2616)*/
|
||||
public static final int SC_SWITCHING_PROTOCOLS = 101;
|
||||
/** <tt>102 Processing</tt> (WebDAV - RFC 2518) */
|
||||
public static final int SC_PROCESSING = 102;
|
||||
|
||||
// --- 2xx Success ---
|
||||
|
||||
/** <tt>200 OK</tt> (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_OK = 200;
|
||||
/** <tt>201 Created</tt> (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_CREATED = 201;
|
||||
/** <tt>202 Accepted</tt> (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_ACCEPTED = 202;
|
||||
/** <tt>203 Non Authoritative Information</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_NON_AUTHORITATIVE_INFORMATION = 203;
|
||||
/** <tt>204 No Content</tt> (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_NO_CONTENT = 204;
|
||||
/** <tt>205 Reset Content</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_RESET_CONTENT = 205;
|
||||
/** <tt>206 Partial Content</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_PARTIAL_CONTENT = 206;
|
||||
/**
|
||||
* <tt>207 Multi-Status</tt> (WebDAV - RFC 2518) or <tt>207 Partial Update
|
||||
* OK</tt> (HTTP/1.1 - draft-ietf-http-v11-spec-rev-01?)
|
||||
*/
|
||||
public static final int SC_MULTI_STATUS = 207;
|
||||
|
||||
// --- 3xx Redirection ---
|
||||
|
||||
/** <tt>300 Mutliple Choices</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_MULTIPLE_CHOICES = 300;
|
||||
/** <tt>301 Moved Permanently</tt> (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_MOVED_PERMANENTLY = 301;
|
||||
/** <tt>302 Moved Temporarily</tt> (Sometimes <tt>Found</tt>) (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_MOVED_TEMPORARILY = 302;
|
||||
/** <tt>303 See Other</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_SEE_OTHER = 303;
|
||||
/** <tt>304 Not Modified</tt> (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_NOT_MODIFIED = 304;
|
||||
/** <tt>305 Use Proxy</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_USE_PROXY = 305;
|
||||
/** <tt>307 Temporary Redirect</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_TEMPORARY_REDIRECT = 307;
|
||||
|
||||
// --- 4xx Client Error ---
|
||||
|
||||
/** <tt>400 Bad Request</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_BAD_REQUEST = 400;
|
||||
/** <tt>401 Unauthorized</tt> (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_UNAUTHORIZED = 401;
|
||||
/** <tt>402 Payment Required</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_PAYMENT_REQUIRED = 402;
|
||||
/** <tt>403 Forbidden</tt> (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_FORBIDDEN = 403;
|
||||
/** <tt>404 Not Found</tt> (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_NOT_FOUND = 404;
|
||||
/** <tt>405 Method Not Allowed</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_METHOD_NOT_ALLOWED = 405;
|
||||
/** <tt>406 Not Acceptable</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_NOT_ACCEPTABLE = 406;
|
||||
/** <tt>407 Proxy Authentication Required</tt> (HTTP/1.1 - RFC 2616)*/
|
||||
public static final int SC_PROXY_AUTHENTICATION_REQUIRED = 407;
|
||||
/** <tt>408 Request Timeout</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_REQUEST_TIMEOUT = 408;
|
||||
/** <tt>409 Conflict</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_CONFLICT = 409;
|
||||
/** <tt>410 Gone</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_GONE = 410;
|
||||
/** <tt>411 Length Required</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_LENGTH_REQUIRED = 411;
|
||||
/** <tt>412 Precondition Failed</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_PRECONDITION_FAILED = 412;
|
||||
/** <tt>413 Request Entity Too Large</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_REQUEST_TOO_LONG = 413;
|
||||
/** <tt>414 Request-URI Too Long</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_REQUEST_URI_TOO_LONG = 414;
|
||||
/** <tt>415 Unsupported Media Type</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415;
|
||||
/** <tt>416 Requested Range Not Satisfiable</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_REQUESTED_RANGE_NOT_SATISFIABLE = 416;
|
||||
/** <tt>417 Expectation Failed</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_EXPECTATION_FAILED = 417;
|
||||
|
||||
/**
|
||||
* Static constant for a 418 error.
|
||||
* <tt>418 Unprocessable Entity</tt> (WebDAV drafts?)
|
||||
* or <tt>418 Reauthentication Required</tt> (HTTP/1.1 drafts?)
|
||||
*/
|
||||
// not used
|
||||
// public static final int SC_UNPROCESSABLE_ENTITY = 418;
|
||||
|
||||
/**
|
||||
* Static constant for a 419 error.
|
||||
* <tt>419 Insufficient Space on Resource</tt>
|
||||
* (WebDAV - draft-ietf-webdav-protocol-05?)
|
||||
* or <tt>419 Proxy Reauthentication Required</tt>
|
||||
* (HTTP/1.1 drafts?)
|
||||
*/
|
||||
public static final int SC_INSUFFICIENT_SPACE_ON_RESOURCE = 419;
|
||||
/**
|
||||
* Static constant for a 420 error.
|
||||
* <tt>420 Method Failure</tt>
|
||||
* (WebDAV - draft-ietf-webdav-protocol-05?)
|
||||
*/
|
||||
public static final int SC_METHOD_FAILURE = 420;
|
||||
/** <tt>422 Unprocessable Entity</tt> (WebDAV - RFC 2518) */
|
||||
public static final int SC_UNPROCESSABLE_ENTITY = 422;
|
||||
/** <tt>423 Locked</tt> (WebDAV - RFC 2518) */
|
||||
public static final int SC_LOCKED = 423;
|
||||
/** <tt>424 Failed Dependency</tt> (WebDAV - RFC 2518) */
|
||||
public static final int SC_FAILED_DEPENDENCY = 424;
|
||||
|
||||
// --- 5xx Server Error ---
|
||||
|
||||
/** <tt>500 Server Error</tt> (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_INTERNAL_SERVER_ERROR = 500;
|
||||
/** <tt>501 Not Implemented</tt> (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_NOT_IMPLEMENTED = 501;
|
||||
/** <tt>502 Bad Gateway</tt> (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_BAD_GATEWAY = 502;
|
||||
/** <tt>503 Service Unavailable</tt> (HTTP/1.0 - RFC 1945) */
|
||||
public static final int SC_SERVICE_UNAVAILABLE = 503;
|
||||
/** <tt>504 Gateway Timeout</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_GATEWAY_TIMEOUT = 504;
|
||||
/** <tt>505 HTTP Version Not Supported</tt> (HTTP/1.1 - RFC 2616) */
|
||||
public static final int SC_HTTP_VERSION_NOT_SUPPORTED = 505;
|
||||
|
||||
/** <tt>507 Insufficient Storage</tt> (WebDAV - RFC 2518) */
|
||||
public static final int SC_INSUFFICIENT_STORAGE = 507;
|
||||
|
||||
}
|
||||
110
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpVersion.java
vendored
Normal file
110
mobile/android/thirdparty/ch/boye/httpclientandroidlib/HttpVersion.java
vendored
Normal file
|
|
@ -0,0 +1,110 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Represents an HTTP version. HTTP uses a "major.minor" numbering
|
||||
* scheme to indicate versions of the protocol.
|
||||
* <p>
|
||||
* The version of an HTTP message is indicated by an HTTP-Version field
|
||||
* in the first line of the message.
|
||||
* </p>
|
||||
* <pre>
|
||||
* HTTP-Version = "HTTP" "/" 1*DIGIT "." 1*DIGIT
|
||||
* </pre>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public final class HttpVersion extends ProtocolVersion
|
||||
implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -5856653513894415344L;
|
||||
|
||||
/** The protocol name. */
|
||||
public static final String HTTP = "HTTP";
|
||||
|
||||
/** HTTP protocol version 0.9 */
|
||||
public static final HttpVersion HTTP_0_9 = new HttpVersion(0, 9);
|
||||
|
||||
/** HTTP protocol version 1.0 */
|
||||
public static final HttpVersion HTTP_1_0 = new HttpVersion(1, 0);
|
||||
|
||||
/** HTTP protocol version 1.1 */
|
||||
public static final HttpVersion HTTP_1_1 = new HttpVersion(1, 1);
|
||||
|
||||
|
||||
/**
|
||||
* Create an HTTP protocol version designator.
|
||||
*
|
||||
* @param major the major version number of the HTTP protocol
|
||||
* @param minor the minor version number of the HTTP protocol
|
||||
*
|
||||
* @throws IllegalArgumentException if either major or minor version number is negative
|
||||
*/
|
||||
public HttpVersion(final int major, final int minor) {
|
||||
super(HTTP, major, minor);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains a specific HTTP version.
|
||||
*
|
||||
* @param major the major version
|
||||
* @param minor the minor version
|
||||
*
|
||||
* @return an instance of {@link HttpVersion} with the argument version
|
||||
*/
|
||||
@Override
|
||||
public ProtocolVersion forVersion(final int major, final int minor) {
|
||||
|
||||
if ((major == this.major) && (minor == this.minor)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
if (major == 1) {
|
||||
if (minor == 0) {
|
||||
return HTTP_1_0;
|
||||
}
|
||||
if (minor == 1) {
|
||||
return HTTP_1_1;
|
||||
}
|
||||
}
|
||||
if ((major == 0) && (minor == 9)) {
|
||||
return HTTP_0_9;
|
||||
}
|
||||
|
||||
// argument checking is done in the constructor
|
||||
return new HttpVersion(major, minor);
|
||||
}
|
||||
|
||||
}
|
||||
57
mobile/android/thirdparty/ch/boye/httpclientandroidlib/MalformedChunkCodingException.java
vendored
Normal file
57
mobile/android/thirdparty/ch/boye/httpclientandroidlib/MalformedChunkCodingException.java
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Signals a malformed chunked stream.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class MalformedChunkCodingException extends IOException {
|
||||
|
||||
private static final long serialVersionUID = 2158560246948994524L;
|
||||
|
||||
/**
|
||||
* Creates a MalformedChunkCodingException without a detail message.
|
||||
*/
|
||||
public MalformedChunkCodingException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a MalformedChunkCodingException with the specified detail message.
|
||||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public MalformedChunkCodingException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/MessageConstraintException.java
vendored
Normal file
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/MessageConstraintException.java
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Signals a message constraint violation.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public class MessageConstraintException extends IOException {
|
||||
|
||||
private static final long serialVersionUID = 6077207720446368695L;
|
||||
|
||||
/**
|
||||
* Creates a TruncatedChunkException with the specified detail message.
|
||||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public MessageConstraintException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
59
mobile/android/thirdparty/ch/boye/httpclientandroidlib/MethodNotSupportedException.java
vendored
Normal file
59
mobile/android/thirdparty/ch/boye/httpclientandroidlib/MethodNotSupportedException.java
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
|
||||
/**
|
||||
* Signals that an HTTP method is not supported.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class MethodNotSupportedException extends HttpException {
|
||||
|
||||
private static final long serialVersionUID = 3365359036840171201L;
|
||||
|
||||
/**
|
||||
* Creates a new MethodNotSupportedException with the specified detail message.
|
||||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public MethodNotSupportedException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new MethodNotSupportedException with the specified detail message and cause.
|
||||
*
|
||||
* @param message the exception detail message
|
||||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public MethodNotSupportedException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
47
mobile/android/thirdparty/ch/boye/httpclientandroidlib/NameValuePair.java
vendored
Normal file
47
mobile/android/thirdparty/ch/boye/httpclientandroidlib/NameValuePair.java
vendored
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* A name / value pair parameter used as an element of HTTP messages.
|
||||
* <pre>
|
||||
* parameter = attribute "=" value
|
||||
* attribute = token
|
||||
* value = token | quoted-string
|
||||
* </pre>
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface NameValuePair {
|
||||
|
||||
String getName();
|
||||
|
||||
String getValue();
|
||||
|
||||
}
|
||||
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/NoHttpResponseException.java
vendored
Normal file
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/NoHttpResponseException.java
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Signals that the target server failed to respond with a valid HTTP response.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class NoHttpResponseException extends IOException {
|
||||
|
||||
private static final long serialVersionUID = -7658940387386078766L;
|
||||
|
||||
/**
|
||||
* Creates a new NoHttpResponseException with the specified detail message.
|
||||
*
|
||||
* @param message exception message
|
||||
*/
|
||||
public NoHttpResponseException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
61
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ParseException.java
vendored
Normal file
61
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ParseException.java
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* Signals a parse error.
|
||||
* Parse errors when receiving a message will typically trigger
|
||||
* {@link ProtocolException}. Parse errors that do not occur during
|
||||
* protocol execution may be handled differently.
|
||||
* This is an unchecked exception, since there are cases where
|
||||
* the data to be parsed has been generated and is therefore
|
||||
* known to be parseable.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class ParseException extends RuntimeException {
|
||||
|
||||
private static final long serialVersionUID = -7288819855864183578L;
|
||||
|
||||
/**
|
||||
* Creates a {@link ParseException} without details.
|
||||
*/
|
||||
public ParseException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a {@link ParseException} with a detail message.
|
||||
*
|
||||
* @param message the exception detail message, or <code>null</code>
|
||||
*/
|
||||
public ParseException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
67
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ProtocolException.java
vendored
Normal file
67
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ProtocolException.java
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* Signals that an HTTP protocol violation has occurred.
|
||||
* For example a malformed status line or headers, a missing message body, etc.
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class ProtocolException extends HttpException {
|
||||
|
||||
private static final long serialVersionUID = -2143571074341228994L;
|
||||
|
||||
/**
|
||||
* Creates a new ProtocolException with a <tt>null</tt> detail message.
|
||||
*/
|
||||
public ProtocolException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ProtocolException with the specified detail message.
|
||||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public ProtocolException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new ProtocolException with the specified detail message and cause.
|
||||
*
|
||||
* @param message the exception detail message
|
||||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public ProtocolException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
264
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ProtocolVersion.java
vendored
Normal file
264
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ProtocolVersion.java
vendored
Normal file
|
|
@ -0,0 +1,264 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* Represents a protocol version. The "major.minor" numbering
|
||||
* scheme is used to indicate versions of the protocol.
|
||||
* <p>
|
||||
* This class defines a protocol version as a combination of
|
||||
* protocol name, major version number, and minor version number.
|
||||
* Note that {@link #equals} and {@link #hashCode} are defined as
|
||||
* final here, they cannot be overridden in derived classes.
|
||||
* </p>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class ProtocolVersion implements Serializable, Cloneable {
|
||||
|
||||
private static final long serialVersionUID = 8950662842175091068L;
|
||||
|
||||
|
||||
/** Name of the protocol. */
|
||||
protected final String protocol;
|
||||
|
||||
/** Major version number of the protocol */
|
||||
protected final int major;
|
||||
|
||||
/** Minor version number of the protocol */
|
||||
protected final int minor;
|
||||
|
||||
|
||||
/**
|
||||
* Create a protocol version designator.
|
||||
*
|
||||
* @param protocol the name of the protocol, for example "HTTP"
|
||||
* @param major the major version number of the protocol
|
||||
* @param minor the minor version number of the protocol
|
||||
*/
|
||||
public ProtocolVersion(final String protocol, final int major, final int minor) {
|
||||
this.protocol = Args.notNull(protocol, "Protocol name");
|
||||
this.major = Args.notNegative(major, "Protocol minor version");
|
||||
this.minor = Args.notNegative(minor, "Protocol minor version");
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the name of the protocol.
|
||||
*
|
||||
* @return the protocol name
|
||||
*/
|
||||
public final String getProtocol() {
|
||||
return protocol;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the major version number of the protocol.
|
||||
*
|
||||
* @return the major version number.
|
||||
*/
|
||||
public final int getMajor() {
|
||||
return major;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the minor version number of the HTTP protocol.
|
||||
*
|
||||
* @return the minor version number.
|
||||
*/
|
||||
public final int getMinor() {
|
||||
return minor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains a specific version of this protocol.
|
||||
* This can be used by derived classes to instantiate themselves instead
|
||||
* of the base class, and to define constants for commonly used versions.
|
||||
* <br/>
|
||||
* The default implementation in this class returns <code>this</code>
|
||||
* if the version matches, and creates a new {@link ProtocolVersion}
|
||||
* otherwise.
|
||||
*
|
||||
* @param major the major version
|
||||
* @param minor the minor version
|
||||
*
|
||||
* @return a protocol version with the same protocol name
|
||||
* and the argument version
|
||||
*/
|
||||
public ProtocolVersion forVersion(final int major, final int minor) {
|
||||
|
||||
if ((major == this.major) && (minor == this.minor)) {
|
||||
return this;
|
||||
}
|
||||
|
||||
// argument checking is done in the constructor
|
||||
return new ProtocolVersion(this.protocol, major, minor);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Obtains a hash code consistent with {@link #equals}.
|
||||
*
|
||||
* @return the hashcode of this protocol version
|
||||
*/
|
||||
@Override
|
||||
public final int hashCode() {
|
||||
return this.protocol.hashCode() ^ (this.major * 100000) ^ this.minor;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks equality of this protocol version with an object.
|
||||
* The object is equal if it is a protocl version with the same
|
||||
* protocol name, major version number, and minor version number.
|
||||
* The specific class of the object is <i>not</i> relevant,
|
||||
* instances of derived classes with identical attributes are
|
||||
* equal to instances of the base class and vice versa.
|
||||
*
|
||||
* @param obj the object to compare with
|
||||
*
|
||||
* @return <code>true</code> if the argument is the same protocol version,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
@Override
|
||||
public final boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (!(obj instanceof ProtocolVersion)) {
|
||||
return false;
|
||||
}
|
||||
final ProtocolVersion that = (ProtocolVersion) obj;
|
||||
|
||||
return ((this.protocol.equals(that.protocol)) &&
|
||||
(this.major == that.major) &&
|
||||
(this.minor == that.minor));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Checks whether this protocol can be compared to another one.
|
||||
* Only protocol versions with the same protocol name can be
|
||||
* {@link #compareToVersion compared}.
|
||||
*
|
||||
* @param that the protocol version to consider
|
||||
*
|
||||
* @return <code>true</code> if {@link #compareToVersion compareToVersion}
|
||||
* can be called with the argument, <code>false</code> otherwise
|
||||
*/
|
||||
public boolean isComparable(final ProtocolVersion that) {
|
||||
return (that != null) && this.protocol.equals(that.protocol);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Compares this protocol version with another one.
|
||||
* Only protocol versions with the same protocol name can be compared.
|
||||
* This method does <i>not</i> define a total ordering, as it would be
|
||||
* required for {@link java.lang.Comparable}.
|
||||
*
|
||||
* @param that the protocol version to compare with
|
||||
*
|
||||
* @return a negative integer, zero, or a positive integer
|
||||
* as this version is less than, equal to, or greater than
|
||||
* the argument version.
|
||||
*
|
||||
* @throws IllegalArgumentException
|
||||
* if the argument has a different protocol name than this object,
|
||||
* or if the argument is <code>null</code>
|
||||
*/
|
||||
public int compareToVersion(final ProtocolVersion that) {
|
||||
Args.notNull(that, "Protocol version");
|
||||
Args.check(this.protocol.equals(that.protocol),
|
||||
"Versions for different protocols cannot be compared: %s %s", this, that);
|
||||
int delta = getMajor() - that.getMajor();
|
||||
if (delta == 0) {
|
||||
delta = getMinor() - that.getMinor();
|
||||
}
|
||||
return delta;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests if this protocol version is greater or equal to the given one.
|
||||
*
|
||||
* @param version the version against which to check this version
|
||||
*
|
||||
* @return <code>true</code> if this protocol version is
|
||||
* {@link #isComparable comparable} to the argument
|
||||
* and {@link #compareToVersion compares} as greater or equal,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public final boolean greaterEquals(final ProtocolVersion version) {
|
||||
return isComparable(version) && (compareToVersion(version) >= 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Tests if this protocol version is less or equal to the given one.
|
||||
*
|
||||
* @param version the version against which to check this version
|
||||
*
|
||||
* @return <code>true</code> if this protocol version is
|
||||
* {@link #isComparable comparable} to the argument
|
||||
* and {@link #compareToVersion compares} as less or equal,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
public final boolean lessEquals(final ProtocolVersion version) {
|
||||
return isComparable(version) && (compareToVersion(version) <= 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Converts this protocol version to a string.
|
||||
*
|
||||
* @return a protocol version string, like "HTTP/1.1"
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buffer.append(this.protocol);
|
||||
buffer.append('/');
|
||||
buffer.append(Integer.toString(this.major));
|
||||
buffer.append('.');
|
||||
buffer.append(Integer.toString(this.minor));
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object clone() throws CloneNotSupportedException {
|
||||
return super.clone();
|
||||
}
|
||||
|
||||
}
|
||||
1
mobile/android/thirdparty/ch/boye/httpclientandroidlib/README.txt
vendored
Normal file
1
mobile/android/thirdparty/ch/boye/httpclientandroidlib/README.txt
vendored
Normal file
|
|
@ -0,0 +1 @@
|
|||
These files are managed in the android-sync repo. Do not modify directly, or your changes will be lost.
|
||||
51
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ReasonPhraseCatalog.java
vendored
Normal file
51
mobile/android/thirdparty/ch/boye/httpclientandroidlib/ReasonPhraseCatalog.java
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
/**
|
||||
* Interface for obtaining reason phrases for HTTP status codes.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface ReasonPhraseCatalog {
|
||||
|
||||
/**
|
||||
* Obtains the reason phrase for a status code.
|
||||
* The optional context allows for catalogs that detect
|
||||
* the language for the reason phrase.
|
||||
*
|
||||
* @param status the status code, in the range 100-599
|
||||
* @param loc the preferred locale for the reason phrase
|
||||
*
|
||||
* @return the reason phrase, or <code>null</code> if unknown
|
||||
*/
|
||||
String getReason(int status, Locale loc);
|
||||
|
||||
}
|
||||
49
mobile/android/thirdparty/ch/boye/httpclientandroidlib/RequestLine.java
vendored
Normal file
49
mobile/android/thirdparty/ch/boye/httpclientandroidlib/RequestLine.java
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* The Request-Line begins with a method token, followed by the
|
||||
* Request-URI and the protocol version, and ending with CRLF. The
|
||||
* elements are separated by SP characters. No CR or LF is allowed
|
||||
* except in the final CRLF sequence.
|
||||
* <pre>
|
||||
* Request-Line = Method SP Request-URI SP HTTP-Version CRLF
|
||||
* </pre>
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface RequestLine {
|
||||
|
||||
String getMethod();
|
||||
|
||||
ProtocolVersion getProtocolVersion();
|
||||
|
||||
String getUri();
|
||||
|
||||
}
|
||||
52
mobile/android/thirdparty/ch/boye/httpclientandroidlib/StatusLine.java
vendored
Normal file
52
mobile/android/thirdparty/ch/boye/httpclientandroidlib/StatusLine.java
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* The first line of a Response message is the Status-Line, consisting
|
||||
* of the protocol version followed by a numeric status code and its
|
||||
* associated textual phrase, with each element separated by SP
|
||||
* characters. No CR or LF is allowed except in the final CRLF sequence.
|
||||
* <pre>
|
||||
* Status-Line = HTTP-Version SP Status-Code SP Reason-Phrase CRLF
|
||||
* </pre>
|
||||
*
|
||||
* @see HttpStatus
|
||||
* @version $Id: StatusLine.java 937295 2010-04-23 13:44:00Z olegk $
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface StatusLine {
|
||||
|
||||
ProtocolVersion getProtocolVersion();
|
||||
|
||||
int getStatusCode();
|
||||
|
||||
String getReasonPhrase();
|
||||
|
||||
}
|
||||
59
mobile/android/thirdparty/ch/boye/httpclientandroidlib/TokenIterator.java
vendored
Normal file
59
mobile/android/thirdparty/ch/boye/httpclientandroidlib/TokenIterator.java
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
/**
|
||||
* An iterator for {@link String} tokens.
|
||||
* This interface is designed as a complement to
|
||||
* {@link HeaderElementIterator}, in cases where the items
|
||||
* are plain strings rather than full header elements.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface TokenIterator extends Iterator<Object> {
|
||||
|
||||
/**
|
||||
* Indicates whether there is another token in this iteration.
|
||||
*
|
||||
* @return <code>true</code> if there is another token,
|
||||
* <code>false</code> otherwise
|
||||
*/
|
||||
boolean hasNext();
|
||||
|
||||
/**
|
||||
* Obtains the next token from this iteration.
|
||||
* This method should only be called while {@link #hasNext hasNext}
|
||||
* is true.
|
||||
*
|
||||
* @return the next token in this iteration
|
||||
*/
|
||||
String nextToken();
|
||||
|
||||
}
|
||||
48
mobile/android/thirdparty/ch/boye/httpclientandroidlib/TruncatedChunkException.java
vendored
Normal file
48
mobile/android/thirdparty/ch/boye/httpclientandroidlib/TruncatedChunkException.java
vendored
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
/**
|
||||
* Signals a truncated chunk in a chunked stream.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
public class TruncatedChunkException extends MalformedChunkCodingException {
|
||||
|
||||
private static final long serialVersionUID = -23506263930279460L;
|
||||
|
||||
/**
|
||||
* Creates a TruncatedChunkException with the specified detail message.
|
||||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public TruncatedChunkException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
57
mobile/android/thirdparty/ch/boye/httpclientandroidlib/UnsupportedHttpVersionException.java
vendored
Normal file
57
mobile/android/thirdparty/ch/boye/httpclientandroidlib/UnsupportedHttpVersionException.java
vendored
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib;
|
||||
|
||||
|
||||
/**
|
||||
* Signals an unsupported version of the HTTP protocol.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public class UnsupportedHttpVersionException extends ProtocolException {
|
||||
|
||||
private static final long serialVersionUID = -1348448090193107031L;
|
||||
|
||||
|
||||
/**
|
||||
* Creates an exception without a detail message.
|
||||
*/
|
||||
public UnsupportedHttpVersionException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an exception with the specified detail message.
|
||||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public UnsupportedHttpVersionException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
}
|
||||
741
mobile/android/thirdparty/ch/boye/httpclientandroidlib/androidextra/Base64.java
vendored
Normal file
741
mobile/android/thirdparty/ch/boye/httpclientandroidlib/androidextra/Base64.java
vendored
Normal file
|
|
@ -0,0 +1,741 @@
|
|||
/*
|
||||
* Copyright (C) 2010 The Android Open Source Project
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.androidextra;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
/**
|
||||
* Utilities for encoding and decoding the Base64 representation of
|
||||
* binary data. See RFCs <a
|
||||
* href="http://www.ietf.org/rfc/rfc2045.txt">2045</a> and <a
|
||||
* href="http://www.ietf.org/rfc/rfc3548.txt">3548</a>.
|
||||
*/
|
||||
public class Base64 {
|
||||
/**
|
||||
* Default values for encoder/decoder flags.
|
||||
*/
|
||||
public static final int DEFAULT = 0;
|
||||
|
||||
/**
|
||||
* Encoder flag bit to omit the padding '=' characters at the end
|
||||
* of the output (if any).
|
||||
*/
|
||||
public static final int NO_PADDING = 1;
|
||||
|
||||
/**
|
||||
* Encoder flag bit to omit all line terminators (i.e., the output
|
||||
* will be on one long line).
|
||||
*/
|
||||
public static final int NO_WRAP = 2;
|
||||
|
||||
/**
|
||||
* Encoder flag bit to indicate lines should be terminated with a
|
||||
* CRLF pair instead of just an LF. Has no effect if {@code
|
||||
* NO_WRAP} is specified as well.
|
||||
*/
|
||||
public static final int CRLF = 4;
|
||||
|
||||
/**
|
||||
* Encoder/decoder flag bit to indicate using the "URL and
|
||||
* filename safe" variant of Base64 (see RFC 3548 section 4) where
|
||||
* {@code -} and {@code _} are used in place of {@code +} and
|
||||
* {@code /}.
|
||||
*/
|
||||
public static final int URL_SAFE = 8;
|
||||
|
||||
/**
|
||||
* Flag to pass to {@link Base64OutputStream} to indicate that it
|
||||
* should not close the output stream it is wrapping when it
|
||||
* itself is closed.
|
||||
*/
|
||||
public static final int NO_CLOSE = 16;
|
||||
|
||||
// --------------------------------------------------------
|
||||
// shared code
|
||||
// --------------------------------------------------------
|
||||
|
||||
/* package */ static abstract class Coder {
|
||||
public byte[] output;
|
||||
public int op;
|
||||
|
||||
/**
|
||||
* Encode/decode another block of input data. this.output is
|
||||
* provided by the caller, and must be big enough to hold all
|
||||
* the coded data. On exit, this.opwill be set to the length
|
||||
* of the coded data.
|
||||
*
|
||||
* @param finish true if this is the final call to process for
|
||||
* this object. Will finalize the coder state and
|
||||
* include any final bytes in the output.
|
||||
*
|
||||
* @return true if the input so far is good; false if some
|
||||
* error has been detected in the input stream..
|
||||
*/
|
||||
public abstract boolean process(byte[] input, int offset, int len, boolean finish);
|
||||
|
||||
/**
|
||||
* @return the maximum number of bytes a call to process()
|
||||
* could produce for the given number of input bytes. This may
|
||||
* be an overestimate.
|
||||
*/
|
||||
public abstract int maxOutputSize(int len);
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// decoding
|
||||
// --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Decode the Base64-encoded data in input and return the data in
|
||||
* a new byte array.
|
||||
*
|
||||
* <p>The padding '=' characters at the end are considered optional, but
|
||||
* if any are present, there must be the correct number of them.
|
||||
*
|
||||
* @param str the input String to decode, which is converted to
|
||||
* bytes using the default charset
|
||||
* @param flags controls certain features of the decoded output.
|
||||
* Pass {@code DEFAULT} to decode standard Base64.
|
||||
*
|
||||
* @throws IllegalArgumentException if the input contains
|
||||
* incorrect padding
|
||||
*/
|
||||
public static byte[] decode(String str, int flags) {
|
||||
return decode(str.getBytes(), flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode the Base64-encoded data in input and return the data in
|
||||
* a new byte array.
|
||||
*
|
||||
* <p>The padding '=' characters at the end are considered optional, but
|
||||
* if any are present, there must be the correct number of them.
|
||||
*
|
||||
* @param input the input array to decode
|
||||
* @param flags controls certain features of the decoded output.
|
||||
* Pass {@code DEFAULT} to decode standard Base64.
|
||||
*
|
||||
* @throws IllegalArgumentException if the input contains
|
||||
* incorrect padding
|
||||
*/
|
||||
public static byte[] decode(byte[] input, int flags) {
|
||||
return decode(input, 0, input.length, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode the Base64-encoded data in input and return the data in
|
||||
* a new byte array.
|
||||
*
|
||||
* <p>The padding '=' characters at the end are considered optional, but
|
||||
* if any are present, there must be the correct number of them.
|
||||
*
|
||||
* @param input the data to decode
|
||||
* @param offset the position within the input array at which to start
|
||||
* @param len the number of bytes of input to decode
|
||||
* @param flags controls certain features of the decoded output.
|
||||
* Pass {@code DEFAULT} to decode standard Base64.
|
||||
*
|
||||
* @throws IllegalArgumentException if the input contains
|
||||
* incorrect padding
|
||||
*/
|
||||
public static byte[] decode(byte[] input, int offset, int len, int flags) {
|
||||
// Allocate space for the most data the input could represent.
|
||||
// (It could contain less if it contains whitespace, etc.)
|
||||
Decoder decoder = new Decoder(flags, new byte[len*3/4]);
|
||||
|
||||
if (!decoder.process(input, offset, len, true)) {
|
||||
throw new IllegalArgumentException("bad base-64");
|
||||
}
|
||||
|
||||
// Maybe we got lucky and allocated exactly enough output space.
|
||||
if (decoder.op == decoder.output.length) {
|
||||
return decoder.output;
|
||||
}
|
||||
|
||||
// Need to shorten the array, so allocate a new one of the
|
||||
// right size and copy.
|
||||
byte[] temp = new byte[decoder.op];
|
||||
System.arraycopy(decoder.output, 0, temp, 0, decoder.op);
|
||||
return temp;
|
||||
}
|
||||
|
||||
/* package */ static class Decoder extends Coder {
|
||||
/**
|
||||
* Lookup table for turning bytes into their position in the
|
||||
* Base64 alphabet.
|
||||
*/
|
||||
private static final int DECODE[] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1,
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
|
||||
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
};
|
||||
|
||||
/**
|
||||
* Decode lookup table for the "web safe" variant (RFC 3548
|
||||
* sec. 4) where - and _ replace + and /.
|
||||
*/
|
||||
private static final int DECODE_WEBSAFE[] = {
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1,
|
||||
52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -2, -1, -1,
|
||||
-1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14,
|
||||
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63,
|
||||
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
|
||||
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
|
||||
};
|
||||
|
||||
/** Non-data values in the DECODE arrays. */
|
||||
private static final int SKIP = -1;
|
||||
private static final int EQUALS = -2;
|
||||
|
||||
/**
|
||||
* States 0-3 are reading through the next input tuple.
|
||||
* State 4 is having read one '=' and expecting exactly
|
||||
* one more.
|
||||
* State 5 is expecting no more data or padding characters
|
||||
* in the input.
|
||||
* State 6 is the error state; an error has been detected
|
||||
* in the input and no future input can "fix" it.
|
||||
*/
|
||||
private int state; // state number (0 to 6)
|
||||
private int value;
|
||||
|
||||
final private int[] alphabet;
|
||||
|
||||
public Decoder(int flags, byte[] output) {
|
||||
this.output = output;
|
||||
|
||||
alphabet = ((flags & URL_SAFE) == 0) ? DECODE : DECODE_WEBSAFE;
|
||||
state = 0;
|
||||
value = 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an overestimate for the number of bytes {@code
|
||||
* len} bytes could decode to.
|
||||
*/
|
||||
public int maxOutputSize(int len) {
|
||||
return len * 3/4 + 10;
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode another block of input data.
|
||||
*
|
||||
* @return true if the state machine is still healthy. false if
|
||||
* bad base-64 data has been detected in the input stream.
|
||||
*/
|
||||
public boolean process(byte[] input, int offset, int len, boolean finish) {
|
||||
if (this.state == 6) return false;
|
||||
|
||||
int p = offset;
|
||||
len += offset;
|
||||
|
||||
// Using local variables makes the decoder about 12%
|
||||
// faster than if we manipulate the member variables in
|
||||
// the loop. (Even alphabet makes a measurable
|
||||
// difference, which is somewhat surprising to me since
|
||||
// the member variable is final.)
|
||||
int state = this.state;
|
||||
int value = this.value;
|
||||
int op = 0;
|
||||
final byte[] output = this.output;
|
||||
final int[] alphabet = this.alphabet;
|
||||
|
||||
while (p < len) {
|
||||
// Try the fast path: we're starting a new tuple and the
|
||||
// next four bytes of the input stream are all data
|
||||
// bytes. This corresponds to going through states
|
||||
// 0-1-2-3-0. We expect to use this method for most of
|
||||
// the data.
|
||||
//
|
||||
// If any of the next four bytes of input are non-data
|
||||
// (whitespace, etc.), value will end up negative. (All
|
||||
// the non-data values in decode are small negative
|
||||
// numbers, so shifting any of them up and or'ing them
|
||||
// together will result in a value with its top bit set.)
|
||||
//
|
||||
// You can remove this whole block and the output should
|
||||
// be the same, just slower.
|
||||
if (state == 0) {
|
||||
while (p+4 <= len &&
|
||||
(value = ((alphabet[input[p] & 0xff] << 18) |
|
||||
(alphabet[input[p+1] & 0xff] << 12) |
|
||||
(alphabet[input[p+2] & 0xff] << 6) |
|
||||
(alphabet[input[p+3] & 0xff]))) >= 0) {
|
||||
output[op+2] = (byte) value;
|
||||
output[op+1] = (byte) (value >> 8);
|
||||
output[op] = (byte) (value >> 16);
|
||||
op += 3;
|
||||
p += 4;
|
||||
}
|
||||
if (p >= len) break;
|
||||
}
|
||||
|
||||
// The fast path isn't available -- either we've read a
|
||||
// partial tuple, or the next four input bytes aren't all
|
||||
// data, or whatever. Fall back to the slower state
|
||||
// machine implementation.
|
||||
|
||||
int d = alphabet[input[p++] & 0xff];
|
||||
|
||||
switch (state) {
|
||||
case 0:
|
||||
if (d >= 0) {
|
||||
value = d;
|
||||
++state;
|
||||
} else if (d != SKIP) {
|
||||
this.state = 6;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (d >= 0) {
|
||||
value = (value << 6) | d;
|
||||
++state;
|
||||
} else if (d != SKIP) {
|
||||
this.state = 6;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (d >= 0) {
|
||||
value = (value << 6) | d;
|
||||
++state;
|
||||
} else if (d == EQUALS) {
|
||||
// Emit the last (partial) output tuple;
|
||||
// expect exactly one more padding character.
|
||||
output[op++] = (byte) (value >> 4);
|
||||
state = 4;
|
||||
} else if (d != SKIP) {
|
||||
this.state = 6;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
if (d >= 0) {
|
||||
// Emit the output triple and return to state 0.
|
||||
value = (value << 6) | d;
|
||||
output[op+2] = (byte) value;
|
||||
output[op+1] = (byte) (value >> 8);
|
||||
output[op] = (byte) (value >> 16);
|
||||
op += 3;
|
||||
state = 0;
|
||||
} else if (d == EQUALS) {
|
||||
// Emit the last (partial) output tuple;
|
||||
// expect no further data or padding characters.
|
||||
output[op+1] = (byte) (value >> 2);
|
||||
output[op] = (byte) (value >> 10);
|
||||
op += 2;
|
||||
state = 5;
|
||||
} else if (d != SKIP) {
|
||||
this.state = 6;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 4:
|
||||
if (d == EQUALS) {
|
||||
++state;
|
||||
} else if (d != SKIP) {
|
||||
this.state = 6;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case 5:
|
||||
if (d != SKIP) {
|
||||
this.state = 6;
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!finish) {
|
||||
// We're out of input, but a future call could provide
|
||||
// more.
|
||||
this.state = state;
|
||||
this.value = value;
|
||||
this.op = op;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Done reading input. Now figure out where we are left in
|
||||
// the state machine and finish up.
|
||||
|
||||
switch (state) {
|
||||
case 0:
|
||||
// Output length is a multiple of three. Fine.
|
||||
break;
|
||||
case 1:
|
||||
// Read one extra input byte, which isn't enough to
|
||||
// make another output byte. Illegal.
|
||||
this.state = 6;
|
||||
return false;
|
||||
case 2:
|
||||
// Read two extra input bytes, enough to emit 1 more
|
||||
// output byte. Fine.
|
||||
output[op++] = (byte) (value >> 4);
|
||||
break;
|
||||
case 3:
|
||||
// Read three extra input bytes, enough to emit 2 more
|
||||
// output bytes. Fine.
|
||||
output[op++] = (byte) (value >> 10);
|
||||
output[op++] = (byte) (value >> 2);
|
||||
break;
|
||||
case 4:
|
||||
// Read one padding '=' when we expected 2. Illegal.
|
||||
this.state = 6;
|
||||
return false;
|
||||
case 5:
|
||||
// Read all the padding '='s we expected and no more.
|
||||
// Fine.
|
||||
break;
|
||||
}
|
||||
|
||||
this.state = state;
|
||||
this.op = op;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// --------------------------------------------------------
|
||||
// encoding
|
||||
// --------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Base64-encode the given data and return a newly allocated
|
||||
* String with the result.
|
||||
*
|
||||
* @param input the data to encode
|
||||
* @param flags controls certain features of the encoded output.
|
||||
* Passing {@code DEFAULT} results in output that
|
||||
* adheres to RFC 2045.
|
||||
*/
|
||||
public static String encodeToString(byte[] input, int flags) {
|
||||
try {
|
||||
return new String(encode(input, flags), "US-ASCII");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// US-ASCII is guaranteed to be available.
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encode the given data and return a newly allocated
|
||||
* String with the result.
|
||||
*
|
||||
* @param input the data to encode
|
||||
* @param offset the position within the input array at which to
|
||||
* start
|
||||
* @param len the number of bytes of input to encode
|
||||
* @param flags controls certain features of the encoded output.
|
||||
* Passing {@code DEFAULT} results in output that
|
||||
* adheres to RFC 2045.
|
||||
*/
|
||||
public static String encodeToString(byte[] input, int offset, int len, int flags) {
|
||||
try {
|
||||
return new String(encode(input, offset, len, flags), "US-ASCII");
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
// US-ASCII is guaranteed to be available.
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encode the given data and return a newly allocated
|
||||
* byte[] with the result.
|
||||
*
|
||||
* @param input the data to encode
|
||||
* @param flags controls certain features of the encoded output.
|
||||
* Passing {@code DEFAULT} results in output that
|
||||
* adheres to RFC 2045.
|
||||
*/
|
||||
public static byte[] encode(byte[] input, int flags) {
|
||||
return encode(input, 0, input.length, flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Base64-encode the given data and return a newly allocated
|
||||
* byte[] with the result.
|
||||
*
|
||||
* @param input the data to encode
|
||||
* @param offset the position within the input array at which to
|
||||
* start
|
||||
* @param len the number of bytes of input to encode
|
||||
* @param flags controls certain features of the encoded output.
|
||||
* Passing {@code DEFAULT} results in output that
|
||||
* adheres to RFC 2045.
|
||||
*/
|
||||
public static byte[] encode(byte[] input, int offset, int len, int flags) {
|
||||
Encoder encoder = new Encoder(flags, null);
|
||||
|
||||
// Compute the exact length of the array we will produce.
|
||||
int output_len = len / 3 * 4;
|
||||
|
||||
// Account for the tail of the data and the padding bytes, if any.
|
||||
if (encoder.do_padding) {
|
||||
if (len % 3 > 0) {
|
||||
output_len += 4;
|
||||
}
|
||||
} else {
|
||||
switch (len % 3) {
|
||||
case 0: break;
|
||||
case 1: output_len += 2; break;
|
||||
case 2: output_len += 3; break;
|
||||
}
|
||||
}
|
||||
|
||||
// Account for the newlines, if any.
|
||||
if (encoder.do_newline && len > 0) {
|
||||
output_len += (((len-1) / (3 * Encoder.LINE_GROUPS)) + 1) *
|
||||
(encoder.do_cr ? 2 : 1);
|
||||
}
|
||||
|
||||
encoder.output = new byte[output_len];
|
||||
encoder.process(input, offset, len, true);
|
||||
|
||||
assert encoder.op == output_len;
|
||||
|
||||
return encoder.output;
|
||||
}
|
||||
|
||||
/* package */ static class Encoder extends Coder {
|
||||
/**
|
||||
* Emit a new line every this many output tuples. Corresponds to
|
||||
* a 76-character line length (the maximum allowable according to
|
||||
* <a href="http://www.ietf.org/rfc/rfc2045.txt">RFC 2045</a>).
|
||||
*/
|
||||
public static final int LINE_GROUPS = 19;
|
||||
|
||||
/**
|
||||
* Lookup table for turning Base64 alphabet positions (6 bits)
|
||||
* into output bytes.
|
||||
*/
|
||||
private static final byte ENCODE[] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/',
|
||||
};
|
||||
|
||||
/**
|
||||
* Lookup table for turning Base64 alphabet positions (6 bits)
|
||||
* into output bytes.
|
||||
*/
|
||||
private static final byte ENCODE_WEBSAFE[] = {
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P',
|
||||
'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f',
|
||||
'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v',
|
||||
'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_',
|
||||
};
|
||||
|
||||
final private byte[] tail;
|
||||
/* package */ int tailLen;
|
||||
private int count;
|
||||
|
||||
final public boolean do_padding;
|
||||
final public boolean do_newline;
|
||||
final public boolean do_cr;
|
||||
final private byte[] alphabet;
|
||||
|
||||
public Encoder(int flags, byte[] output) {
|
||||
this.output = output;
|
||||
|
||||
do_padding = (flags & NO_PADDING) == 0;
|
||||
do_newline = (flags & NO_WRAP) == 0;
|
||||
do_cr = (flags & CRLF) != 0;
|
||||
alphabet = ((flags & URL_SAFE) == 0) ? ENCODE : ENCODE_WEBSAFE;
|
||||
|
||||
tail = new byte[2];
|
||||
tailLen = 0;
|
||||
|
||||
count = do_newline ? LINE_GROUPS : -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return an overestimate for the number of bytes {@code
|
||||
* len} bytes could encode to.
|
||||
*/
|
||||
public int maxOutputSize(int len) {
|
||||
return len * 8/5 + 10;
|
||||
}
|
||||
|
||||
public boolean process(byte[] input, int offset, int len, boolean finish) {
|
||||
// Using local variables makes the encoder about 9% faster.
|
||||
final byte[] alphabet = this.alphabet;
|
||||
final byte[] output = this.output;
|
||||
int op = 0;
|
||||
int count = this.count;
|
||||
|
||||
int p = offset;
|
||||
len += offset;
|
||||
int v = -1;
|
||||
|
||||
// First we need to concatenate the tail of the previous call
|
||||
// with any input bytes available now and see if we can empty
|
||||
// the tail.
|
||||
|
||||
switch (tailLen) {
|
||||
case 0:
|
||||
// There was no tail.
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (p+2 <= len) {
|
||||
// A 1-byte tail with at least 2 bytes of
|
||||
// input available now.
|
||||
v = ((tail[0] & 0xff) << 16) |
|
||||
((input[p++] & 0xff) << 8) |
|
||||
(input[p++] & 0xff);
|
||||
tailLen = 0;
|
||||
};
|
||||
break;
|
||||
|
||||
case 2:
|
||||
if (p+1 <= len) {
|
||||
// A 2-byte tail with at least 1 byte of input.
|
||||
v = ((tail[0] & 0xff) << 16) |
|
||||
((tail[1] & 0xff) << 8) |
|
||||
(input[p++] & 0xff);
|
||||
tailLen = 0;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (v != -1) {
|
||||
output[op++] = alphabet[(v >> 18) & 0x3f];
|
||||
output[op++] = alphabet[(v >> 12) & 0x3f];
|
||||
output[op++] = alphabet[(v >> 6) & 0x3f];
|
||||
output[op++] = alphabet[v & 0x3f];
|
||||
if (--count == 0) {
|
||||
if (do_cr) output[op++] = '\r';
|
||||
output[op++] = '\n';
|
||||
count = LINE_GROUPS;
|
||||
}
|
||||
}
|
||||
|
||||
// At this point either there is no tail, or there are fewer
|
||||
// than 3 bytes of input available.
|
||||
|
||||
// The main loop, turning 3 input bytes into 4 output bytes on
|
||||
// each iteration.
|
||||
while (p+3 <= len) {
|
||||
v = ((input[p] & 0xff) << 16) |
|
||||
((input[p+1] & 0xff) << 8) |
|
||||
(input[p+2] & 0xff);
|
||||
output[op] = alphabet[(v >> 18) & 0x3f];
|
||||
output[op+1] = alphabet[(v >> 12) & 0x3f];
|
||||
output[op+2] = alphabet[(v >> 6) & 0x3f];
|
||||
output[op+3] = alphabet[v & 0x3f];
|
||||
p += 3;
|
||||
op += 4;
|
||||
if (--count == 0) {
|
||||
if (do_cr) output[op++] = '\r';
|
||||
output[op++] = '\n';
|
||||
count = LINE_GROUPS;
|
||||
}
|
||||
}
|
||||
|
||||
if (finish) {
|
||||
// Finish up the tail of the input. Note that we need to
|
||||
// consume any bytes in tail before any bytes
|
||||
// remaining in input; there should be at most two bytes
|
||||
// total.
|
||||
|
||||
if (p-tailLen == len-1) {
|
||||
int t = 0;
|
||||
v = ((tailLen > 0 ? tail[t++] : input[p++]) & 0xff) << 4;
|
||||
tailLen -= t;
|
||||
output[op++] = alphabet[(v >> 6) & 0x3f];
|
||||
output[op++] = alphabet[v & 0x3f];
|
||||
if (do_padding) {
|
||||
output[op++] = '=';
|
||||
output[op++] = '=';
|
||||
}
|
||||
if (do_newline) {
|
||||
if (do_cr) output[op++] = '\r';
|
||||
output[op++] = '\n';
|
||||
}
|
||||
} else if (p-tailLen == len-2) {
|
||||
int t = 0;
|
||||
v = (((tailLen > 1 ? tail[t++] : input[p++]) & 0xff) << 10) |
|
||||
(((tailLen > 0 ? tail[t++] : input[p++]) & 0xff) << 2);
|
||||
tailLen -= t;
|
||||
output[op++] = alphabet[(v >> 12) & 0x3f];
|
||||
output[op++] = alphabet[(v >> 6) & 0x3f];
|
||||
output[op++] = alphabet[v & 0x3f];
|
||||
if (do_padding) {
|
||||
output[op++] = '=';
|
||||
}
|
||||
if (do_newline) {
|
||||
if (do_cr) output[op++] = '\r';
|
||||
output[op++] = '\n';
|
||||
}
|
||||
} else if (do_newline && op > 0 && count != LINE_GROUPS) {
|
||||
if (do_cr) output[op++] = '\r';
|
||||
output[op++] = '\n';
|
||||
}
|
||||
|
||||
assert tailLen == 0;
|
||||
assert p == len;
|
||||
} else {
|
||||
// Save the leftovers in tail to be consumed on the next
|
||||
// call to encodeInternal.
|
||||
|
||||
if (p == len-1) {
|
||||
tail[tailLen++] = input[p];
|
||||
} else if (p == len-2) {
|
||||
tail[tailLen++] = input[p];
|
||||
tail[tailLen++] = input[p+1];
|
||||
}
|
||||
}
|
||||
|
||||
this.op = op;
|
||||
this.count = count;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private Base64() { } // don't instantiate
|
||||
}
|
||||
113
mobile/android/thirdparty/ch/boye/httpclientandroidlib/androidextra/HttpClientAndroidLog.java
vendored
Normal file
113
mobile/android/thirdparty/ch/boye/httpclientandroidlib/androidextra/HttpClientAndroidLog.java
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
package ch.boye.httpclientandroidlib.androidextra;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
public class HttpClientAndroidLog {
|
||||
|
||||
private String logTag;
|
||||
private boolean debugEnabled;
|
||||
private boolean errorEnabled;
|
||||
private boolean traceEnabled;
|
||||
private boolean warnEnabled;
|
||||
private boolean infoEnabled;
|
||||
|
||||
public HttpClientAndroidLog(Object tag) {
|
||||
logTag=tag.toString();
|
||||
debugEnabled=false;
|
||||
errorEnabled=false;
|
||||
traceEnabled=false;
|
||||
warnEnabled=false;
|
||||
infoEnabled=false;
|
||||
}
|
||||
|
||||
public void enableDebug(boolean enable) {
|
||||
debugEnabled=enable;
|
||||
}
|
||||
|
||||
public boolean isDebugEnabled() {
|
||||
return debugEnabled;
|
||||
}
|
||||
|
||||
public void debug(Object message) {
|
||||
if(isDebugEnabled())
|
||||
Log.d(logTag, message.toString());
|
||||
}
|
||||
|
||||
public void debug(Object message, Throwable t) {
|
||||
if(isDebugEnabled())
|
||||
Log.d(logTag, message.toString(), t);
|
||||
}
|
||||
|
||||
public void enableError(boolean enable) {
|
||||
errorEnabled=enable;
|
||||
}
|
||||
|
||||
public boolean isErrorEnabled() {
|
||||
return errorEnabled;
|
||||
}
|
||||
|
||||
public void error(Object message) {
|
||||
if(isErrorEnabled())
|
||||
Log.e(logTag, message.toString());
|
||||
}
|
||||
|
||||
public void error(Object message, Throwable t) {
|
||||
if(isErrorEnabled())
|
||||
Log.e(logTag, message.toString(), t);
|
||||
}
|
||||
|
||||
public void enableWarn(boolean enable) {
|
||||
warnEnabled=enable;
|
||||
}
|
||||
|
||||
public boolean isWarnEnabled() {
|
||||
return warnEnabled;
|
||||
}
|
||||
|
||||
public void warn(Object message) {
|
||||
if(isWarnEnabled())
|
||||
Log.w(logTag, message.toString());
|
||||
}
|
||||
|
||||
public void warn(Object message, Throwable t) {
|
||||
if(isWarnEnabled())
|
||||
Log.w(logTag, message.toString(), t);
|
||||
}
|
||||
|
||||
public void enableInfo(boolean enable) {
|
||||
infoEnabled=enable;
|
||||
}
|
||||
|
||||
public boolean isInfoEnabled() {
|
||||
return infoEnabled;
|
||||
}
|
||||
|
||||
public void info(Object message) {
|
||||
if(isInfoEnabled())
|
||||
Log.i(logTag, message.toString());
|
||||
}
|
||||
|
||||
public void info(Object message, Throwable t) {
|
||||
if(isInfoEnabled())
|
||||
Log.i(logTag, message.toString(), t);
|
||||
}
|
||||
|
||||
public void enableTrace(boolean enable) {
|
||||
traceEnabled=enable;
|
||||
}
|
||||
|
||||
public boolean isTraceEnabled() {
|
||||
return traceEnabled;
|
||||
}
|
||||
|
||||
public void trace(Object message) {
|
||||
if(isTraceEnabled())
|
||||
Log.i(logTag, message.toString());
|
||||
}
|
||||
|
||||
public void trace(Object message, Throwable t) {
|
||||
if(isTraceEnabled())
|
||||
Log.i(logTag, message.toString(), t);
|
||||
}
|
||||
|
||||
}
|
||||
76
mobile/android/thirdparty/ch/boye/httpclientandroidlib/annotation/GuardedBy.java
vendored
Normal file
76
mobile/android/thirdparty/ch/boye/httpclientandroidlib/annotation/GuardedBy.java
vendored
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.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 field or method to which this annotation is applied can only be accessed
|
||||
* when holding a particular lock, which may be a built-in (synchronization) lock,
|
||||
* or may be an explicit java.util.concurrent.Lock.
|
||||
*
|
||||
* The argument determines which lock guards the annotated field or method:
|
||||
* <ul>
|
||||
* <li>
|
||||
* <code>this</code> : The intrinsic lock of the object in whose class the field is defined.
|
||||
* </li>
|
||||
* <li>
|
||||
* <code>class-name.this</code> : For inner classes, it may be necessary to disambiguate 'this';
|
||||
* the <em>class-name.this</em> designation allows you to specify which 'this' reference is intended
|
||||
* </li>
|
||||
* <li>
|
||||
* <code>itself</code> : For reference fields only; the object to which the field refers.
|
||||
* </li>
|
||||
* <li>
|
||||
* <code>field-name</code> : The lock object is referenced by the (instance or static) field
|
||||
* specified by <em>field-name</em>.
|
||||
* </li>
|
||||
* <li>
|
||||
* <code>class-name.field-name</code> : The lock object is reference by the static field specified
|
||||
* by <em>class-name.field-name</em>.
|
||||
* </li>
|
||||
* <li>
|
||||
* <code>method-name()</code> : The lock object is returned by calling the named nil-ary method.
|
||||
* </li>
|
||||
* <li>
|
||||
* <code>class-name.class</code> : The Class object for the specified class should be used as the lock object.
|
||||
* </li>
|
||||
* <p>
|
||||
* 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();
|
||||
}
|
||||
59
mobile/android/thirdparty/ch/boye/httpclientandroidlib/annotation/Immutable.java
vendored
Normal file
59
mobile/android/thirdparty/ch/boye/httpclientandroidlib/annotation/Immutable.java
vendored
Normal file
|
|
@ -0,0 +1,59 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.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
|
||||
* <ul>
|
||||
* <li> all public fields are final, </li>
|
||||
* <li> all public final reference fields refer to other immutable objects, and </li>
|
||||
* <li> constructors and methods do not publish references to any internal state
|
||||
* which is potentially mutable by the implementation. </li>
|
||||
* </ul>
|
||||
* 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.
|
||||
* <p>
|
||||
* Immutable objects are inherently thread-safe; they may be passed between threads or
|
||||
* published without synchronization.
|
||||
* <p>
|
||||
* 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 {
|
||||
}
|
||||
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/annotation/NotThreadSafe.java
vendored
Normal file
50
mobile/android/thirdparty/ch/boye/httpclientandroidlib/annotation/NotThreadSafe.java
vendored
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.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
|
||||
* <p>
|
||||
* 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 {
|
||||
}
|
||||
51
mobile/android/thirdparty/ch/boye/httpclientandroidlib/annotation/ThreadSafe.java
vendored
Normal file
51
mobile/android/thirdparty/ch/boye/httpclientandroidlib/annotation/ThreadSafe.java
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.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
|
||||
* <p>
|
||||
* 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 {
|
||||
}
|
||||
34
mobile/android/thirdparty/ch/boye/httpclientandroidlib/annotation/package-info.java
vendored
Normal file
34
mobile/android/thirdparty/ch/boye/httpclientandroidlib/annotation/package-info.java
vendored
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Thread-safety annotations based on JCIP-ANNOTATIONS
|
||||
* <br/>
|
||||
* Copyright (c) 2005 Brian Goetz and Tim Peierls.
|
||||
* See http://www.jcip.net
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.annotation;
|
||||
64
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AUTH.java
vendored
Normal file
64
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AUTH.java
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Constants and static helpers related to the HTTP authentication.
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public final class AUTH {
|
||||
|
||||
/**
|
||||
* The www authenticate challange header.
|
||||
*/
|
||||
public static final String WWW_AUTH = "WWW-Authenticate";
|
||||
|
||||
/**
|
||||
* The www authenticate response header.
|
||||
*/
|
||||
public static final String WWW_AUTH_RESP = "Authorization";
|
||||
|
||||
/**
|
||||
* The proxy authenticate challange header.
|
||||
*/
|
||||
public static final String PROXY_AUTH = "Proxy-Authenticate";
|
||||
|
||||
/**
|
||||
* The proxy authenticate response header.
|
||||
*/
|
||||
public static final String PROXY_AUTH_RESP = "Proxy-Authorization";
|
||||
|
||||
private AUTH() {
|
||||
}
|
||||
|
||||
}
|
||||
62
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthOption.java
vendored
Normal file
62
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthOption.java
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
*/
|
||||
@Immutable
|
||||
public final class AuthOption {
|
||||
|
||||
private final AuthScheme authScheme;
|
||||
private final Credentials creds;
|
||||
|
||||
public AuthOption(final AuthScheme authScheme, final Credentials creds) {
|
||||
super();
|
||||
Args.notNull(authScheme, "Auth scheme");
|
||||
Args.notNull(creds, "User credentials");
|
||||
this.authScheme = authScheme;
|
||||
this.creds = creds;
|
||||
}
|
||||
|
||||
public AuthScheme getAuthScheme() {
|
||||
return this.authScheme;
|
||||
}
|
||||
|
||||
public Credentials getCredentials() {
|
||||
return this.creds;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.authScheme.toString();
|
||||
}
|
||||
|
||||
}
|
||||
33
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthProtocolState.java
vendored
Normal file
33
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthProtocolState.java
vendored
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
public enum AuthProtocolState {
|
||||
|
||||
UNCHALLENGED, CHALLENGED, HANDSHAKE, FAILURE, SUCCESS
|
||||
|
||||
}
|
||||
130
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthScheme.java
vendored
Normal file
130
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthScheme.java
vendored
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.Header;
|
||||
import ch.boye.httpclientandroidlib.HttpRequest;
|
||||
|
||||
/**
|
||||
* This interface represents an abstract challenge-response oriented
|
||||
* authentication scheme.
|
||||
* <p>
|
||||
* An authentication scheme should be able to support the following
|
||||
* functions:
|
||||
* <ul>
|
||||
* <li>Parse and process the challenge sent by the target server
|
||||
* in response to request for a protected resource
|
||||
* <li>Provide its textual designation
|
||||
* <li>Provide its parameters, if available
|
||||
* <li>Provide the realm this authentication scheme is applicable to,
|
||||
* if available
|
||||
* <li>Generate authorization string for the given set of credentials
|
||||
* and the HTTP request in response to the authorization challenge.
|
||||
* </ul>
|
||||
* <p>
|
||||
* Authentication schemes may be stateful involving a series of
|
||||
* challenge-response exchanges.
|
||||
* <p>
|
||||
* IMPORTANT: implementations of this interface MUST also implement {@link ContextAwareAuthScheme}
|
||||
* interface in order to remain API compatible with newer versions of HttpClient.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
|
||||
public interface AuthScheme {
|
||||
|
||||
/**
|
||||
* Processes the given challenge token. Some authentication schemes
|
||||
* may involve multiple challenge-response exchanges. Such schemes must be able
|
||||
* to maintain the state information when dealing with sequential challenges
|
||||
*
|
||||
* @param header the challenge header
|
||||
*/
|
||||
void processChallenge(final Header header) throws MalformedChallengeException;
|
||||
|
||||
/**
|
||||
* Returns textual designation of the given authentication scheme.
|
||||
*
|
||||
* @return the name of the given authentication scheme
|
||||
*/
|
||||
String getSchemeName();
|
||||
|
||||
/**
|
||||
* Returns authentication parameter with the given name, if available.
|
||||
*
|
||||
* @param name The name of the parameter to be returned
|
||||
*
|
||||
* @return the parameter with the given name
|
||||
*/
|
||||
String getParameter(final String name);
|
||||
|
||||
/**
|
||||
* Returns authentication realm. If the concept of an authentication
|
||||
* realm is not applicable to the given authentication scheme, returns
|
||||
* <code>null</code>.
|
||||
*
|
||||
* @return the authentication realm
|
||||
*/
|
||||
String getRealm();
|
||||
|
||||
/**
|
||||
* Tests if the authentication scheme is provides authorization on a per
|
||||
* connection basis instead of usual per request basis
|
||||
*
|
||||
* @return <tt>true</tt> if the scheme is connection based, <tt>false</tt>
|
||||
* if the scheme is request based.
|
||||
*/
|
||||
boolean isConnectionBased();
|
||||
|
||||
/**
|
||||
* Authentication process may involve a series of challenge-response exchanges.
|
||||
* This method tests if the authorization process has been completed, either
|
||||
* successfully or unsuccessfully, that is, all the required authorization
|
||||
* challenges have been processed in their entirety.
|
||||
*
|
||||
* @return <tt>true</tt> if the authentication process has been completed,
|
||||
* <tt>false</tt> otherwise.
|
||||
*/
|
||||
boolean isComplete();
|
||||
|
||||
/**
|
||||
* Produces an authorization string for the given set of {@link Credentials}.
|
||||
*
|
||||
* @param credentials The set of credentials to be used for athentication
|
||||
* @param request The request being authenticated
|
||||
* @throws AuthenticationException if authorization string cannot
|
||||
* be generated due to an authentication failure
|
||||
*
|
||||
* @return the authorization string
|
||||
*
|
||||
* @deprecated (4.1) Use {@link ContextAwareAuthScheme#authenticate(Credentials, HttpRequest, ch.boye.httpclientandroidlib.protocol.HttpContext)}
|
||||
*/
|
||||
@Deprecated
|
||||
Header authenticate(Credentials credentials, HttpRequest request)
|
||||
throws AuthenticationException;
|
||||
|
||||
}
|
||||
51
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthSchemeFactory.java
vendored
Normal file
51
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthSchemeFactory.java
vendored
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.params.HttpParams;
|
||||
|
||||
/**
|
||||
* Factory for {@link AuthScheme} implementations.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.3) use {@link AuthSchemeProvider}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AuthSchemeFactory {
|
||||
|
||||
/**
|
||||
* Creates an instance of {@link AuthScheme} using given HTTP parameters.
|
||||
*
|
||||
* @param params HTTP parameters.
|
||||
*
|
||||
* @return auth scheme.
|
||||
*/
|
||||
AuthScheme newInstance(HttpParams params);
|
||||
|
||||
}
|
||||
46
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthSchemeProvider.java
vendored
Normal file
46
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthSchemeProvider.java
vendored
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.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);
|
||||
|
||||
}
|
||||
155
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthSchemeRegistry.java
vendored
Normal file
155
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthSchemeRegistry.java
vendored
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpRequest;
|
||||
import ch.boye.httpclientandroidlib.annotation.ThreadSafe;
|
||||
import ch.boye.httpclientandroidlib.config.Lookup;
|
||||
import ch.boye.httpclientandroidlib.params.HttpParams;
|
||||
import ch.boye.httpclientandroidlib.protocol.ExecutionContext;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* Authentication scheme registry that can be used to obtain the corresponding
|
||||
* authentication scheme implementation for a given type of authorization challenge.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.3) use {@link ch.boye.httpclientandroidlib.config.Registry}
|
||||
*/
|
||||
@ThreadSafe
|
||||
@Deprecated
|
||||
public final class AuthSchemeRegistry implements Lookup<AuthSchemeProvider> {
|
||||
|
||||
private final ConcurrentHashMap<String,AuthSchemeFactory> registeredSchemes;
|
||||
|
||||
public AuthSchemeRegistry() {
|
||||
super();
|
||||
this.registeredSchemes = new ConcurrentHashMap<String,AuthSchemeFactory>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers a {@link AuthSchemeFactory} with the given identifier. If a factory with the
|
||||
* given name already exists it will be overridden. This name is the same one used to
|
||||
* retrieve the {@link AuthScheme authentication scheme} from {@link #getAuthScheme}.
|
||||
*
|
||||
* <p>
|
||||
* Please note that custom authentication preferences, if used, need to be updated accordingly
|
||||
* for the new {@link AuthScheme authentication scheme} to take effect.
|
||||
* </p>
|
||||
*
|
||||
* @param name the identifier for this scheme
|
||||
* @param factory the {@link AuthSchemeFactory} class to register
|
||||
*
|
||||
* @see #getAuthScheme
|
||||
*/
|
||||
public void register(
|
||||
final String name,
|
||||
final AuthSchemeFactory factory) {
|
||||
Args.notNull(name, "Name");
|
||||
Args.notNull(factory, "Authentication scheme factory");
|
||||
registeredSchemes.put(name.toLowerCase(Locale.ENGLISH), factory);
|
||||
}
|
||||
|
||||
/**
|
||||
* Unregisters the class implementing an {@link AuthScheme authentication scheme} with
|
||||
* the given name.
|
||||
*
|
||||
* @param name the identifier of the class to unregister
|
||||
*/
|
||||
public void unregister(final String name) {
|
||||
Args.notNull(name, "Name");
|
||||
registeredSchemes.remove(name.toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the {@link AuthScheme authentication scheme} with the given name.
|
||||
*
|
||||
* @param name the {@link AuthScheme authentication scheme} identifier
|
||||
* @param params the {@link HttpParams HTTP parameters} for the authentication
|
||||
* scheme.
|
||||
*
|
||||
* @return {@link AuthScheme authentication scheme}
|
||||
*
|
||||
* @throws IllegalStateException if a scheme with the given name cannot be found
|
||||
*/
|
||||
public AuthScheme getAuthScheme(final String name, final HttpParams params)
|
||||
throws IllegalStateException {
|
||||
|
||||
Args.notNull(name, "Name");
|
||||
final AuthSchemeFactory factory = registeredSchemes.get(name.toLowerCase(Locale.ENGLISH));
|
||||
if (factory != null) {
|
||||
return factory.newInstance(params);
|
||||
} else {
|
||||
throw new IllegalStateException("Unsupported authentication scheme: " + name);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains a list containing the names of all registered {@link AuthScheme authentication
|
||||
* schemes}
|
||||
*
|
||||
* @return list of registered scheme names
|
||||
*/
|
||||
public List<String> getSchemeNames() {
|
||||
return new ArrayList<String>(registeredSchemes.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* Populates the internal collection of registered {@link AuthScheme authentication schemes}
|
||||
* with the content of the map passed as a parameter.
|
||||
*
|
||||
* @param map authentication schemes
|
||||
*/
|
||||
public void setItems(final Map<String, AuthSchemeFactory> map) {
|
||||
if (map == null) {
|
||||
return;
|
||||
}
|
||||
registeredSchemes.clear();
|
||||
registeredSchemes.putAll(map);
|
||||
}
|
||||
|
||||
public AuthSchemeProvider lookup(final String name) {
|
||||
return new AuthSchemeProvider() {
|
||||
|
||||
public AuthScheme create(final HttpContext context) {
|
||||
final HttpRequest request = (HttpRequest) context.getAttribute(
|
||||
ExecutionContext.HTTP_REQUEST);
|
||||
return getAuthScheme(name, request.getParams());
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
302
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthScope.java
vendored
Normal file
302
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthScope.java
vendored
Normal file
|
|
@ -0,0 +1,302 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpHost;
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
import ch.boye.httpclientandroidlib.util.LangUtils;
|
||||
|
||||
/**
|
||||
* The class represents an authentication scope consisting of a host name,
|
||||
* a port number, a realm name and an authentication scheme name which
|
||||
* {@link Credentials Credentials} apply to.
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class AuthScope {
|
||||
|
||||
/**
|
||||
* The <tt>null</tt> value represents any host. In the future versions of
|
||||
* HttpClient the use of this parameter will be discontinued.
|
||||
*/
|
||||
public static final String ANY_HOST = null;
|
||||
|
||||
/**
|
||||
* The <tt>-1</tt> value represents any port.
|
||||
*/
|
||||
public static final int ANY_PORT = -1;
|
||||
|
||||
/**
|
||||
* The <tt>null</tt> value represents any realm.
|
||||
*/
|
||||
public static final String ANY_REALM = null;
|
||||
|
||||
/**
|
||||
* The <tt>null</tt> value represents any authentication scheme.
|
||||
*/
|
||||
public static final String ANY_SCHEME = null;
|
||||
|
||||
/**
|
||||
* Default scope matching any host, port, realm and authentication scheme.
|
||||
* In the future versions of HttpClient the use of this parameter will be
|
||||
* discontinued.
|
||||
*/
|
||||
public static final AuthScope ANY = new AuthScope(ANY_HOST, ANY_PORT, ANY_REALM, ANY_SCHEME);
|
||||
|
||||
/** The authentication scheme the credentials apply to. */
|
||||
private final String scheme;
|
||||
|
||||
/** The realm the credentials apply to. */
|
||||
private final String realm;
|
||||
|
||||
/** The host the credentials apply to. */
|
||||
private final String host;
|
||||
|
||||
/** The port the credentials apply to. */
|
||||
private final int port;
|
||||
|
||||
/** Creates a new credentials scope for the given
|
||||
* <tt>host</tt>, <tt>port</tt>, <tt>realm</tt>, and
|
||||
* <tt>authentication scheme</tt>.
|
||||
*
|
||||
* @param host the host the credentials apply to. May be set
|
||||
* to <tt>null</tt> if credentials are applicable to
|
||||
* any host.
|
||||
* @param port the port the credentials apply to. May be set
|
||||
* to negative value if credentials are applicable to
|
||||
* any port.
|
||||
* @param realm the realm the credentials apply to. May be set
|
||||
* to <tt>null</tt> if credentials are applicable to
|
||||
* any realm.
|
||||
* @param scheme the authentication scheme the credentials apply to.
|
||||
* May be set to <tt>null</tt> if credentials are applicable to
|
||||
* any authentication scheme.
|
||||
*/
|
||||
public AuthScope(final String host, final int port,
|
||||
final String realm, final String scheme)
|
||||
{
|
||||
this.host = (host == null) ? ANY_HOST: host.toLowerCase(Locale.ENGLISH);
|
||||
this.port = (port < 0) ? ANY_PORT: port;
|
||||
this.realm = (realm == null) ? ANY_REALM: realm;
|
||||
this.scheme = (scheme == null) ? ANY_SCHEME: scheme.toUpperCase(Locale.ENGLISH);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
*/
|
||||
public AuthScope(final HttpHost host, final String realm, final String schemeName) {
|
||||
this(host.getHostName(), host.getPort(), realm, schemeName);
|
||||
}
|
||||
|
||||
/**
|
||||
* @since 4.2
|
||||
*/
|
||||
public AuthScope(final HttpHost host) {
|
||||
this(host, ANY_REALM, ANY_SCHEME);
|
||||
}
|
||||
|
||||
/** Creates a new credentials scope for the given
|
||||
* <tt>host</tt>, <tt>port</tt>, <tt>realm</tt>, and any
|
||||
* authentication scheme.
|
||||
*
|
||||
* @param host the host the credentials apply to. May be set
|
||||
* to <tt>null</tt> if credentials are applicable to
|
||||
* any host.
|
||||
* @param port the port the credentials apply to. May be set
|
||||
* to negative value if credentials are applicable to
|
||||
* any port.
|
||||
* @param realm the realm the credentials apply to. May be set
|
||||
* to <tt>null</tt> if credentials are applicable to
|
||||
* any realm.
|
||||
*/
|
||||
public AuthScope(final String host, final int port, final String realm) {
|
||||
this(host, port, realm, ANY_SCHEME);
|
||||
}
|
||||
|
||||
/** Creates a new credentials scope for the given
|
||||
* <tt>host</tt>, <tt>port</tt>, any realm name, and any
|
||||
* authentication scheme.
|
||||
*
|
||||
* @param host the host the credentials apply to. May be set
|
||||
* to <tt>null</tt> if credentials are applicable to
|
||||
* any host.
|
||||
* @param port the port the credentials apply to. May be set
|
||||
* to negative value if credentials are applicable to
|
||||
* any port.
|
||||
*/
|
||||
public AuthScope(final String host, final int port) {
|
||||
this(host, port, ANY_REALM, ANY_SCHEME);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a copy of the given credentials scope.
|
||||
*/
|
||||
public AuthScope(final AuthScope authscope) {
|
||||
super();
|
||||
Args.notNull(authscope, "Scope");
|
||||
this.host = authscope.getHost();
|
||||
this.port = authscope.getPort();
|
||||
this.realm = authscope.getRealm();
|
||||
this.scheme = authscope.getScheme();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the host
|
||||
*/
|
||||
public String getHost() {
|
||||
return this.host;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the port
|
||||
*/
|
||||
public int getPort() {
|
||||
return this.port;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the realm name
|
||||
*/
|
||||
public String getRealm() {
|
||||
return this.realm;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the scheme type
|
||||
*/
|
||||
public String getScheme() {
|
||||
return this.scheme;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests if the authentication scopes match.
|
||||
*
|
||||
* @return the match factor. Negative value signifies no match.
|
||||
* Non-negative signifies a match. The greater the returned value
|
||||
* the closer the match.
|
||||
*/
|
||||
public int match(final AuthScope that) {
|
||||
int factor = 0;
|
||||
if (LangUtils.equals(this.scheme, that.scheme)) {
|
||||
factor += 1;
|
||||
} else {
|
||||
if (this.scheme != ANY_SCHEME && that.scheme != ANY_SCHEME) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (LangUtils.equals(this.realm, that.realm)) {
|
||||
factor += 2;
|
||||
} else {
|
||||
if (this.realm != ANY_REALM && that.realm != ANY_REALM) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (this.port == that.port) {
|
||||
factor += 4;
|
||||
} else {
|
||||
if (this.port != ANY_PORT && that.port != ANY_PORT) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (LangUtils.equals(this.host, that.host)) {
|
||||
factor += 8;
|
||||
} else {
|
||||
if (this.host != ANY_HOST && that.host != ANY_HOST) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return factor;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#equals(Object)
|
||||
*/
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (o == null) {
|
||||
return false;
|
||||
}
|
||||
if (o == this) {
|
||||
return true;
|
||||
}
|
||||
if (!(o instanceof AuthScope)) {
|
||||
return super.equals(o);
|
||||
}
|
||||
final AuthScope that = (AuthScope) o;
|
||||
return
|
||||
LangUtils.equals(this.host, that.host)
|
||||
&& this.port == that.port
|
||||
&& LangUtils.equals(this.realm, that.realm)
|
||||
&& LangUtils.equals(this.scheme, that.scheme);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#toString()
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
if (this.scheme != null) {
|
||||
buffer.append(this.scheme.toUpperCase(Locale.ENGLISH));
|
||||
buffer.append(' ');
|
||||
}
|
||||
if (this.realm != null) {
|
||||
buffer.append('\'');
|
||||
buffer.append(this.realm);
|
||||
buffer.append('\'');
|
||||
} else {
|
||||
buffer.append("<any realm>");
|
||||
}
|
||||
if (this.host != null) {
|
||||
buffer.append('@');
|
||||
buffer.append(this.host);
|
||||
if (this.port >= 0) {
|
||||
buffer.append(':');
|
||||
buffer.append(this.port);
|
||||
}
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @see java.lang.Object#hashCode()
|
||||
*/
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = LangUtils.HASH_SEED;
|
||||
hash = LangUtils.hashCode(hash, this.host);
|
||||
hash = LangUtils.hashCode(hash, this.port);
|
||||
hash = LangUtils.hashCode(hash, this.realm);
|
||||
hash = LangUtils.hashCode(hash, this.scheme);
|
||||
return hash;
|
||||
}
|
||||
}
|
||||
235
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthState.java
vendored
Normal file
235
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthState.java
vendored
Normal file
|
|
@ -0,0 +1,235 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.util.Queue;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.NotThreadSafe;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* This class provides detailed information about the state of the authentication process.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class AuthState {
|
||||
|
||||
/** 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<AuthOption> authOptions;
|
||||
|
||||
public AuthState() {
|
||||
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<AuthOption> getAuthOptions() {
|
||||
return this.authOptions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns <code>true</code> if {@link AuthOption}s are available, <code>false</code>
|
||||
* otherwise.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public boolean hasAuthOptions() {
|
||||
return this.authOptions != null && !this.authOptions.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the auth state with a queue of {@link AuthOption}s.
|
||||
*
|
||||
* @param authOptions a queue of auth options. May not be null or empty.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public void update(final Queue<AuthOption> authOptions) {
|
||||
Args.notEmpty(authOptions, "Queue of auth options");
|
||||
this.authOptions = authOptions;
|
||||
this.authScheme = null;
|
||||
this.credentials = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invalidates the authentication state by resetting its parameters.
|
||||
*
|
||||
* @deprecated (4.2) use {@link #reset()}
|
||||
*/
|
||||
@Deprecated
|
||||
public void invalidate() {
|
||||
reset();
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated (4.2) do not use
|
||||
*/
|
||||
@Deprecated
|
||||
public boolean isValid() {
|
||||
return this.authScheme != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 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, <code>null</code otherwise
|
||||
*
|
||||
* @deprecated (4.2) do not use.
|
||||
*/
|
||||
@Deprecated
|
||||
public AuthScope getAuthScope() {
|
||||
return this.authScope;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets actual {@link AuthScope}.
|
||||
*
|
||||
* @param authScope Authentication scope
|
||||
*
|
||||
* @deprecated (4.2) do not use.
|
||||
*/
|
||||
@Deprecated
|
||||
public void setAuthScope(final AuthScope authScope) {
|
||||
this.authScope = authScope;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("state:").append(this.state).append(";");
|
||||
if (this.authScheme != null) {
|
||||
buffer.append("auth scheme:").append(this.authScheme.getSchemeName()).append(";");
|
||||
}
|
||||
if (this.credentials != null) {
|
||||
buffer.append("credentials present");
|
||||
}
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
}
|
||||
70
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthenticationException.java
vendored
Normal file
70
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/AuthenticationException.java
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.ProtocolException;
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Signals a failure in authentication process
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class AuthenticationException extends ProtocolException {
|
||||
|
||||
private static final long serialVersionUID = -6794031905674764776L;
|
||||
|
||||
/**
|
||||
* Creates a new AuthenticationException with a <tt>null</tt> detail message.
|
||||
*/
|
||||
public AuthenticationException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AuthenticationException with the specified message.
|
||||
*
|
||||
* @param message the exception detail message
|
||||
*/
|
||||
public AuthenticationException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new AuthenticationException with the specified detail message and cause.
|
||||
*
|
||||
* @param message the exception detail message
|
||||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public AuthenticationException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
}
|
||||
89
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/BasicUserPrincipal.java
vendored
Normal file
89
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/BasicUserPrincipal.java
vendored
Normal file
|
|
@ -0,0 +1,89 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.security.Principal;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
import ch.boye.httpclientandroidlib.util.LangUtils;
|
||||
|
||||
/**
|
||||
* Basic user principal used for HTTP authentication
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public final class BasicUserPrincipal implements Principal, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -2266305184969850467L;
|
||||
|
||||
private final String username;
|
||||
|
||||
public BasicUserPrincipal(final String username) {
|
||||
super();
|
||||
Args.notNull(username, "User name");
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = LangUtils.HASH_SEED;
|
||||
hash = LangUtils.hashCode(hash, this.username);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof BasicUserPrincipal) {
|
||||
final BasicUserPrincipal that = (BasicUserPrincipal) o;
|
||||
if (LangUtils.equals(this.username, that.username)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("[principal: ");
|
||||
buffer.append(this.username);
|
||||
buffer.append("]");
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
38
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/ChallengeState.java
vendored
Normal file
38
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/ChallengeState.java
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
/**
|
||||
* Challenge mode (TARGET or PROXY)
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public enum ChallengeState {
|
||||
|
||||
TARGET, PROXY
|
||||
|
||||
}
|
||||
62
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/ContextAwareAuthScheme.java
vendored
Normal file
62
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/ContextAwareAuthScheme.java
vendored
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.Header;
|
||||
import ch.boye.httpclientandroidlib.HttpRequest;
|
||||
import ch.boye.httpclientandroidlib.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;
|
||||
|
||||
}
|
||||
44
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/Credentials.java
vendored
Normal file
44
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/Credentials.java
vendored
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.security.Principal;
|
||||
|
||||
/**
|
||||
* This interface represents a set of credentials consisting of a security
|
||||
* principal and a secret (password) that can be used to establish user
|
||||
* identity
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface Credentials {
|
||||
|
||||
Principal getUserPrincipal();
|
||||
|
||||
String getPassword();
|
||||
|
||||
}
|
||||
69
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/InvalidCredentialsException.java
vendored
Normal file
69
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/InvalidCredentialsException.java
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Authentication credentials required to respond to a authentication
|
||||
* challenge are invalid
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class InvalidCredentialsException extends AuthenticationException {
|
||||
|
||||
private static final long serialVersionUID = -4834003835215460648L;
|
||||
|
||||
/**
|
||||
* Creates a new InvalidCredentialsException with a <tt>null</tt> detail message.
|
||||
*/
|
||||
public InvalidCredentialsException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new InvalidCredentialsException with the specified message.
|
||||
*
|
||||
* @param message the exception detail message
|
||||
*/
|
||||
public InvalidCredentialsException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new InvalidCredentialsException with the specified detail message and cause.
|
||||
*
|
||||
* @param message the exception detail message
|
||||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public InvalidCredentialsException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
70
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/MalformedChallengeException.java
vendored
Normal file
70
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/MalformedChallengeException.java
vendored
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import ch.boye.httpclientandroidlib.ProtocolException;
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Signals that authentication challenge is in some way invalid or
|
||||
* illegal in the given context
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class MalformedChallengeException extends ProtocolException {
|
||||
|
||||
private static final long serialVersionUID = 814586927989932284L;
|
||||
|
||||
/**
|
||||
* Creates a new MalformedChallengeException with a <tt>null</tt> detail message.
|
||||
*/
|
||||
public MalformedChallengeException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new MalformedChallengeException with the specified message.
|
||||
*
|
||||
* @param message the exception detail message
|
||||
*/
|
||||
public MalformedChallengeException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new MalformedChallengeException with the specified detail message and cause.
|
||||
*
|
||||
* @param message the exception detail message
|
||||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public MalformedChallengeException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
177
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/NTCredentials.java
vendored
Normal file
177
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/NTCredentials.java
vendored
Normal file
|
|
@ -0,0 +1,177 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.security.Principal;
|
||||
import java.util.Locale;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
import ch.boye.httpclientandroidlib.util.LangUtils;
|
||||
|
||||
/**
|
||||
* {@link Credentials} implementation for Microsoft Windows platforms that includes
|
||||
* Windows specific attributes such as name of the domain the user belongs to.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class NTCredentials implements Credentials, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -7385699315228907265L;
|
||||
|
||||
/** The user principal */
|
||||
private final NTUserPrincipal principal;
|
||||
|
||||
/** Password */
|
||||
private final String password;
|
||||
|
||||
/** The host the authentication request is originating from. */
|
||||
private final String workstation;
|
||||
|
||||
/**
|
||||
* The constructor with the fully qualified username and password combined
|
||||
* string argument.
|
||||
*
|
||||
* @param usernamePassword the domain/username:password formed string
|
||||
*/
|
||||
public NTCredentials(final String usernamePassword) {
|
||||
super();
|
||||
Args.notNull(usernamePassword, "Username:password string");
|
||||
final String username;
|
||||
final int atColon = usernamePassword.indexOf(':');
|
||||
if (atColon >= 0) {
|
||||
username = usernamePassword.substring(0, atColon);
|
||||
this.password = usernamePassword.substring(atColon + 1);
|
||||
} else {
|
||||
username = usernamePassword;
|
||||
this.password = null;
|
||||
}
|
||||
final int atSlash = username.indexOf('/');
|
||||
if (atSlash >= 0) {
|
||||
this.principal = new NTUserPrincipal(
|
||||
username.substring(0, atSlash).toUpperCase(Locale.ENGLISH),
|
||||
username.substring(atSlash + 1));
|
||||
} else {
|
||||
this.principal = new NTUserPrincipal(
|
||||
null,
|
||||
username.substring(atSlash + 1));
|
||||
}
|
||||
this.workstation = null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
* @param userName The user name. This should not include the domain to authenticate with.
|
||||
* For example: "user" is correct whereas "DOMAIN\\user" is not.
|
||||
* @param password The password.
|
||||
* @param workstation The workstation the authentication request is originating from.
|
||||
* Essentially, the computer name for this machine.
|
||||
* @param domain The domain to authenticate within.
|
||||
*/
|
||||
public NTCredentials(
|
||||
final String userName,
|
||||
final String password,
|
||||
final String workstation,
|
||||
final String domain) {
|
||||
super();
|
||||
Args.notNull(userName, "User name");
|
||||
this.principal = new NTUserPrincipal(domain, userName);
|
||||
this.password = password;
|
||||
if (workstation != null) {
|
||||
this.workstation = workstation.toUpperCase(Locale.ENGLISH);
|
||||
} else {
|
||||
this.workstation = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Principal getUserPrincipal() {
|
||||
return this.principal;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return this.principal.getUsername();
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the name to authenticate with.
|
||||
*
|
||||
* @return String the domain these credentials are intended to authenticate with.
|
||||
*/
|
||||
public String getDomain() {
|
||||
return this.principal.getDomain();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the workstation name of the computer originating the request.
|
||||
*
|
||||
* @return String the workstation the user is logged into.
|
||||
*/
|
||||
public String getWorkstation() {
|
||||
return this.workstation;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = LangUtils.HASH_SEED;
|
||||
hash = LangUtils.hashCode(hash, this.principal);
|
||||
hash = LangUtils.hashCode(hash, this.workstation);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof NTCredentials) {
|
||||
final NTCredentials that = (NTCredentials) o;
|
||||
if (LangUtils.equals(this.principal, that.principal)
|
||||
&& LangUtils.equals(this.workstation, that.workstation)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buffer.append("[principal: ");
|
||||
buffer.append(this.principal);
|
||||
buffer.append("][workstation: ");
|
||||
buffer.append(this.workstation);
|
||||
buffer.append("]");
|
||||
return buffer.toString();
|
||||
}
|
||||
|
||||
}
|
||||
113
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/NTUserPrincipal.java
vendored
Normal file
113
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/NTUserPrincipal.java
vendored
Normal file
|
|
@ -0,0 +1,113 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.security.Principal;
|
||||
import java.util.Locale;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
import ch.boye.httpclientandroidlib.util.LangUtils;
|
||||
|
||||
/**
|
||||
* Microsoft Windows specific user principal implementation.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class NTUserPrincipal implements Principal, Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6870169797924406894L;
|
||||
|
||||
private final String username;
|
||||
private final String domain;
|
||||
private final String ntname;
|
||||
|
||||
public NTUserPrincipal(
|
||||
final String domain,
|
||||
final String username) {
|
||||
super();
|
||||
Args.notNull(username, "User name");
|
||||
this.username = username;
|
||||
if (domain != null) {
|
||||
this.domain = domain.toUpperCase(Locale.ENGLISH);
|
||||
} else {
|
||||
this.domain = null;
|
||||
}
|
||||
if (this.domain != null && this.domain.length() > 0) {
|
||||
final StringBuilder buffer = new StringBuilder();
|
||||
buffer.append(this.domain);
|
||||
buffer.append('\\');
|
||||
buffer.append(this.username);
|
||||
this.ntname = buffer.toString();
|
||||
} else {
|
||||
this.ntname = this.username;
|
||||
}
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.ntname;
|
||||
}
|
||||
|
||||
public String getDomain() {
|
||||
return this.domain;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int hash = LangUtils.HASH_SEED;
|
||||
hash = LangUtils.hashCode(hash, this.username);
|
||||
hash = LangUtils.hashCode(hash, this.domain);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof NTUserPrincipal) {
|
||||
final NTUserPrincipal that = (NTUserPrincipal) o;
|
||||
if (LangUtils.equals(this.username, that.username)
|
||||
&& LangUtils.equals(this.domain, that.domain)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.ntname;
|
||||
}
|
||||
|
||||
}
|
||||
120
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/UsernamePasswordCredentials.java
vendored
Normal file
120
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/UsernamePasswordCredentials.java
vendored
Normal file
|
|
@ -0,0 +1,120 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.security.Principal;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
import ch.boye.httpclientandroidlib.util.LangUtils;
|
||||
|
||||
/**
|
||||
* Simple {@link Credentials} implementation based on a user name / password
|
||||
* pair.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class UsernamePasswordCredentials implements Credentials, Serializable {
|
||||
|
||||
private static final long serialVersionUID = 243343858802739403L;
|
||||
|
||||
private final BasicUserPrincipal principal;
|
||||
private final String password;
|
||||
|
||||
/**
|
||||
* The constructor with the username and password combined string argument.
|
||||
*
|
||||
* @param usernamePassword the username:password formed string
|
||||
* @see #toString
|
||||
*/
|
||||
public UsernamePasswordCredentials(final String usernamePassword) {
|
||||
super();
|
||||
Args.notNull(usernamePassword, "Username:password string");
|
||||
final int atColon = usernamePassword.indexOf(':');
|
||||
if (atColon >= 0) {
|
||||
this.principal = new BasicUserPrincipal(usernamePassword.substring(0, atColon));
|
||||
this.password = usernamePassword.substring(atColon + 1);
|
||||
} else {
|
||||
this.principal = new BasicUserPrincipal(usernamePassword);
|
||||
this.password = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* The constructor with the username and password arguments.
|
||||
*
|
||||
* @param userName the user name
|
||||
* @param password the password
|
||||
*/
|
||||
public UsernamePasswordCredentials(final String userName, final String password) {
|
||||
super();
|
||||
Args.notNull(userName, "Username");
|
||||
this.principal = new BasicUserPrincipal(userName);
|
||||
this.password = password;
|
||||
}
|
||||
|
||||
public Principal getUserPrincipal() {
|
||||
return this.principal;
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
return this.principal.getName();
|
||||
}
|
||||
|
||||
public String getPassword() {
|
||||
return password;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return this.principal.hashCode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object o) {
|
||||
if (this == o) {
|
||||
return true;
|
||||
}
|
||||
if (o instanceof UsernamePasswordCredentials) {
|
||||
final UsernamePasswordCredentials that = (UsernamePasswordCredentials) o;
|
||||
if (LangUtils.equals(this.principal, that.principal)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return this.principal.toString();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
31
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/package-info.java
vendored
Normal file
31
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/package-info.java
vendored
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Client HTTP authentication APIs.
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth;
|
||||
74
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/params/AuthPNames.java
vendored
Normal file
74
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/params/AuthPNames.java
vendored
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth.params;
|
||||
|
||||
/**
|
||||
* Parameter names for HTTP authentication classes.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.3) use {@link ch.boye.httpclientandroidlib.client.config.RequestConfig}
|
||||
* and constructor parameters of
|
||||
* {@link ch.boye.httpclientandroidlib.auth.AuthSchemeProvider}s.
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AuthPNames {
|
||||
|
||||
/**
|
||||
* Defines the charset to be used when encoding
|
||||
* {@link ch.boye.httpclientandroidlib.auth.Credentials}.
|
||||
* <p>
|
||||
* This parameter expects a value of type {@link String}.
|
||||
*/
|
||||
public static final String CREDENTIAL_CHARSET = "http.auth.credential-charset";
|
||||
|
||||
/**
|
||||
* Defines the order of preference for supported
|
||||
* {@link ch.boye.httpclientandroidlib.auth.AuthScheme}s when authenticating with
|
||||
* the target host.
|
||||
* <p>
|
||||
* This parameter expects a value of type {@link java.util.Collection}. The
|
||||
* collection is expected to contain {@link String} instances representing
|
||||
* a name of an authentication scheme as returned by
|
||||
* {@link ch.boye.httpclientandroidlib.auth.AuthScheme#getSchemeName()}.
|
||||
*/
|
||||
public static final String TARGET_AUTH_PREF = "http.auth.target-scheme-pref";
|
||||
|
||||
/**
|
||||
* Defines the order of preference for supported
|
||||
* {@link ch.boye.httpclientandroidlib.auth.AuthScheme}s when authenticating with the
|
||||
* proxy host.
|
||||
* <p>
|
||||
* This parameter expects a value of type {@link java.util.Collection}. The
|
||||
* collection is expected to contain {@link String} instances representing
|
||||
* a name of an authentication scheme as returned by
|
||||
* {@link ch.boye.httpclientandroidlib.auth.AuthScheme#getSchemeName()}.
|
||||
*/
|
||||
public static final String PROXY_AUTH_PREF = "http.auth.proxy-scheme-pref";
|
||||
|
||||
}
|
||||
55
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/params/AuthParamBean.java
vendored
Normal file
55
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/params/AuthParamBean.java
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth.params;
|
||||
|
||||
import ch.boye.httpclientandroidlib.params.HttpAbstractParamBean;
|
||||
import ch.boye.httpclientandroidlib.params.HttpParams;
|
||||
|
||||
/**
|
||||
* This is a Java Bean class that can be used to wrap an instance of
|
||||
* {@link HttpParams} and manipulate HTTP authentication parameters
|
||||
* using Java Beans conventions.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.3) use {@link ch.boye.httpclientandroidlib.client.config.RequestConfig}
|
||||
* and constructor parameters of
|
||||
* {@link ch.boye.httpclientandroidlib.auth.AuthSchemeProvider}s.
|
||||
*/
|
||||
@Deprecated
|
||||
public class AuthParamBean extends HttpAbstractParamBean {
|
||||
|
||||
public AuthParamBean (final HttpParams params) {
|
||||
super(params);
|
||||
}
|
||||
|
||||
public void setCredentialCharset (final String charset) {
|
||||
AuthParams.setCredentialCharset(params, charset);
|
||||
}
|
||||
|
||||
}
|
||||
82
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/params/AuthParams.java
vendored
Normal file
82
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/params/AuthParams.java
vendored
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.auth.params;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.params.HttpParams;
|
||||
import ch.boye.httpclientandroidlib.protocol.HTTP;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* An adaptor for manipulating HTTP authentication parameters
|
||||
* in {@link HttpParams}.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.3) use {@link ch.boye.httpclientandroidlib.client.config.RequestConfig}
|
||||
* and constructor parameters of
|
||||
* {@link ch.boye.httpclientandroidlib.auth.AuthSchemeProvider}s.
|
||||
*/
|
||||
@Immutable
|
||||
@Deprecated
|
||||
public final class AuthParams {
|
||||
|
||||
private AuthParams() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtains the charset for encoding
|
||||
* {@link ch.boye.httpclientandroidlib.auth.Credentials}.If not configured,
|
||||
* {@link HTTP#DEFAULT_PROTOCOL_CHARSET}is used instead.
|
||||
*
|
||||
* @return The charset
|
||||
*/
|
||||
public static String getCredentialCharset(final HttpParams params) {
|
||||
Args.notNull(params, "HTTP parameters");
|
||||
String charset = (String) params.getParameter
|
||||
(AuthPNames.CREDENTIAL_CHARSET);
|
||||
if (charset == null) {
|
||||
charset = HTTP.DEF_PROTOCOL_CHARSET.name();
|
||||
}
|
||||
return charset;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Sets the charset to be used when encoding
|
||||
* {@link ch.boye.httpclientandroidlib.auth.Credentials}.
|
||||
*
|
||||
* @param charset The charset
|
||||
*/
|
||||
public static void setCredentialCharset(final HttpParams params, final String charset) {
|
||||
Args.notNull(params, "HTTP parameters");
|
||||
params.setParameter(AuthPNames.CREDENTIAL_CHARSET, charset);
|
||||
}
|
||||
|
||||
}
|
||||
32
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/params/package-info.java
vendored
Normal file
32
mobile/android/thirdparty/ch/boye/httpclientandroidlib/auth/params/package-info.java
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
/**
|
||||
* Deprecated.
|
||||
* @deprecated (4.3).
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.auth.params;
|
||||
49
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/AuthCache.java
vendored
Normal file
49
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/AuthCache.java
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpHost;
|
||||
import ch.boye.httpclientandroidlib.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();
|
||||
|
||||
}
|
||||
101
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/AuthenticationHandler.java
vendored
Normal file
101
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/AuthenticationHandler.java
vendored
Normal file
|
|
@ -0,0 +1,101 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import ch.boye.httpclientandroidlib.Header;
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
import ch.boye.httpclientandroidlib.auth.AuthScheme;
|
||||
import ch.boye.httpclientandroidlib.auth.AuthenticationException;
|
||||
import ch.boye.httpclientandroidlib.auth.MalformedChallengeException;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
/**
|
||||
* A handler for determining if an HTTP response represents an authentication
|
||||
* challenge that was sent back to the client as a result of authentication
|
||||
* failure.
|
||||
* <p>
|
||||
* Implementations of this interface must be thread-safe. Access to shared
|
||||
* data must be synchronized as methods of this interface may be executed
|
||||
* from multiple threads.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.2) use {@link AuthenticationStrategy}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface AuthenticationHandler {
|
||||
|
||||
/**
|
||||
* Determines if the given HTTP response response represents
|
||||
* an authentication challenge that was sent back as a result
|
||||
* of authentication failure
|
||||
* @param response HTTP response.
|
||||
* @param context HTTP context.
|
||||
* @return <code>true</code> if user authentication is required,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
boolean isAuthenticationRequested(
|
||||
HttpResponse response,
|
||||
HttpContext context);
|
||||
|
||||
/**
|
||||
* Extracts from the given HTTP response a collection of authentication
|
||||
* challenges, each of which represents an authentication scheme supported
|
||||
* by the authentication host.
|
||||
*
|
||||
* @param response HTTP response.
|
||||
* @param context HTTP context.
|
||||
* @return a collection of challenges keyed by names of corresponding
|
||||
* authentication schemes.
|
||||
* @throws MalformedChallengeException if one of the authentication
|
||||
* challenges is not valid or malformed.
|
||||
*/
|
||||
Map<String, Header> getChallenges(
|
||||
HttpResponse response,
|
||||
HttpContext context) throws MalformedChallengeException;
|
||||
|
||||
/**
|
||||
* Selects one authentication challenge out of all available and
|
||||
* creates and generates {@link AuthScheme} instance capable of
|
||||
* processing that challenge.
|
||||
* @param challenges collection of challenges.
|
||||
* @param response HTTP response.
|
||||
* @param context HTTP context.
|
||||
* @return authentication scheme to use for authentication.
|
||||
* @throws AuthenticationException if an authentication scheme
|
||||
* could not be selected.
|
||||
*/
|
||||
AuthScheme selectScheme(
|
||||
Map<String, Header> challenges,
|
||||
HttpResponse response,
|
||||
HttpContext context) throws AuthenticationException;
|
||||
|
||||
}
|
||||
130
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/AuthenticationStrategy.java
vendored
Normal file
130
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/AuthenticationStrategy.java
vendored
Normal file
|
|
@ -0,0 +1,130 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Queue;
|
||||
|
||||
import ch.boye.httpclientandroidlib.Header;
|
||||
import ch.boye.httpclientandroidlib.HttpHost;
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
import ch.boye.httpclientandroidlib.auth.AuthOption;
|
||||
import ch.boye.httpclientandroidlib.auth.AuthScheme;
|
||||
import ch.boye.httpclientandroidlib.auth.MalformedChallengeException;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
/**
|
||||
* A handler for determining if an HTTP response represents an authentication challenge that was
|
||||
* sent back to the client as a result of authentication failure.
|
||||
* <p>
|
||||
* Implementations of this interface must be thread-safe. Access to shared data must be
|
||||
* synchronized as methods of this interface may be executed from multiple threads.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public interface AuthenticationStrategy {
|
||||
|
||||
/**
|
||||
* Determines if the given HTTP response response represents
|
||||
* an authentication challenge that was sent back as a result
|
||||
* of authentication failure.
|
||||
*
|
||||
* @param authhost authentication host.
|
||||
* @param response HTTP response.
|
||||
* @param context HTTP context.
|
||||
* @return <code>true</code> if user authentication is required,
|
||||
* <code>false</code> otherwise.
|
||||
*/
|
||||
boolean isAuthenticationRequested(
|
||||
HttpHost authhost,
|
||||
HttpResponse response,
|
||||
HttpContext context);
|
||||
|
||||
/**
|
||||
* Extracts from the given HTTP response a collection of authentication
|
||||
* challenges, each of which represents an authentication scheme supported
|
||||
* by the authentication host.
|
||||
*
|
||||
* @param authhost authentication host.
|
||||
* @param response HTTP response.
|
||||
* @param context HTTP context.
|
||||
* @return a collection of challenges keyed by names of corresponding
|
||||
* authentication schemes.
|
||||
* @throws MalformedChallengeException if one of the authentication
|
||||
* challenges is not valid or malformed.
|
||||
*/
|
||||
Map<String, Header> getChallenges(
|
||||
HttpHost authhost,
|
||||
HttpResponse response,
|
||||
HttpContext context) throws MalformedChallengeException;
|
||||
|
||||
/**
|
||||
* Selects one authentication challenge out of all available and
|
||||
* creates and generates {@link AuthOption} instance capable of
|
||||
* processing that challenge.
|
||||
*
|
||||
* @param challenges collection of challenges.
|
||||
* @param authhost authentication host.
|
||||
* @param response HTTP response.
|
||||
* @param context HTTP context.
|
||||
* @return authentication auth schemes that can be used for authentication. Can be empty.
|
||||
* @throws MalformedChallengeException if one of the authentication
|
||||
* challenges is not valid or malformed.
|
||||
*/
|
||||
Queue<AuthOption> select(
|
||||
Map<String, Header> challenges,
|
||||
HttpHost authhost,
|
||||
HttpResponse response,
|
||||
HttpContext context) throws MalformedChallengeException;
|
||||
|
||||
/**
|
||||
* Callback invoked in case of successful authentication.
|
||||
*
|
||||
* @param authhost authentication host.
|
||||
* @param authScheme authentication scheme used.
|
||||
* @param context HTTP context.
|
||||
*/
|
||||
void authSucceeded(
|
||||
HttpHost authhost,
|
||||
AuthScheme authScheme,
|
||||
HttpContext context);
|
||||
|
||||
/**
|
||||
* Callback invoked in case of unsuccessful authentication.
|
||||
*
|
||||
* @param authhost authentication host.
|
||||
* @param authScheme authentication scheme used.
|
||||
* @param context HTTP context.
|
||||
*/
|
||||
void authFailed(
|
||||
HttpHost authhost,
|
||||
AuthScheme authScheme,
|
||||
HttpContext context);
|
||||
|
||||
}
|
||||
54
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/BackoffManager.java
vendored
Normal file
54
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/BackoffManager.java
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.conn.routing.HttpRoute;
|
||||
|
||||
/**
|
||||
* Represents a controller that dynamically adjusts the size
|
||||
* of an available connection pool based on feedback from
|
||||
* using the connections.
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
public interface BackoffManager {
|
||||
|
||||
/**
|
||||
* Called when we have decided that the result of
|
||||
* using a connection should be interpreted as a
|
||||
* backoff signal.
|
||||
*/
|
||||
public void backOff(HttpRoute route);
|
||||
|
||||
/**
|
||||
* Called when we have determined that the result of
|
||||
* using a connection has succeeded and that we may
|
||||
* probe for more connections.
|
||||
*/
|
||||
public void probe(HttpRoute route);
|
||||
}
|
||||
68
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/CircularRedirectException.java
vendored
Normal file
68
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/CircularRedirectException.java
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Signals a circular redirect
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class CircularRedirectException extends RedirectException {
|
||||
|
||||
private static final long serialVersionUID = 6830063487001091803L;
|
||||
|
||||
/**
|
||||
* Creates a new CircularRedirectException with a <tt>null</tt> detail message.
|
||||
*/
|
||||
public CircularRedirectException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new CircularRedirectException with the specified detail message.
|
||||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public CircularRedirectException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new CircularRedirectException with the specified detail message and cause.
|
||||
*
|
||||
* @param message the exception detail message
|
||||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public CircularRedirectException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
61
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/ClientProtocolException.java
vendored
Normal file
61
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/ClientProtocolException.java
vendored
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Signals an error in the HTTP protocol.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class ClientProtocolException extends IOException {
|
||||
|
||||
private static final long serialVersionUID = -5596590843227115865L;
|
||||
|
||||
public ClientProtocolException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public ClientProtocolException(final String s) {
|
||||
super(s);
|
||||
}
|
||||
|
||||
public ClientProtocolException(final Throwable cause) {
|
||||
initCause(cause);
|
||||
}
|
||||
|
||||
public ClientProtocolException(final String message, final Throwable cause) {
|
||||
super(message);
|
||||
initCause(cause);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
64
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/ConnectionBackoffStrategy.java
vendored
Normal file
64
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/ConnectionBackoffStrategy.java
vendored
Normal file
|
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
|
||||
/**
|
||||
* When managing a dynamic number of connections for a given route, this
|
||||
* strategy assesses whether a given request execution outcome should
|
||||
* result in a backoff signal or not, based on either examining the
|
||||
* <code>Throwable</code> that resulted or by examining the resulting
|
||||
* response (e.g. for its status code).
|
||||
*
|
||||
* @since 4.2
|
||||
*
|
||||
*/
|
||||
public interface ConnectionBackoffStrategy {
|
||||
|
||||
/**
|
||||
* Determines whether seeing the given <code>Throwable</code> as
|
||||
* a result of request execution should result in a backoff
|
||||
* signal.
|
||||
* @param t the <code>Throwable</code> that happened
|
||||
* @return <code>true</code> if a backoff signal should be
|
||||
* given
|
||||
*/
|
||||
boolean shouldBackoff(Throwable t);
|
||||
|
||||
/**
|
||||
* Determines whether receiving the given {@link HttpResponse} as
|
||||
* a result of request execution should result in a backoff
|
||||
* signal. Implementations MUST restrict themselves to examining
|
||||
* the response header and MUST NOT consume any of the response
|
||||
* body, if any.
|
||||
* @param resp the <code>HttpResponse</code> that was received
|
||||
* @return <code>true</code> if a backoff signal should be
|
||||
* given
|
||||
*/
|
||||
boolean shouldBackoff(HttpResponse resp);
|
||||
}
|
||||
71
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/CookieStore.java
vendored
Normal file
71
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/CookieStore.java
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
import ch.boye.httpclientandroidlib.cookie.Cookie;
|
||||
|
||||
/**
|
||||
* This interface represents an abstract store for {@link Cookie}
|
||||
* objects.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface CookieStore {
|
||||
|
||||
/**
|
||||
* Adds an {@link 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
|
||||
*/
|
||||
void addCookie(Cookie cookie);
|
||||
|
||||
/**
|
||||
* Returns all cookies contained in this store.
|
||||
*
|
||||
* @return all cookies
|
||||
*/
|
||||
List<Cookie> getCookies();
|
||||
|
||||
/**
|
||||
* Removes all of {@link Cookie}s in this store that have expired by
|
||||
* the specified {@link java.util.Date}.
|
||||
*
|
||||
* @return true if any cookies were purged.
|
||||
*/
|
||||
boolean clearExpired(Date date);
|
||||
|
||||
/**
|
||||
* Clears all cookies.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
}
|
||||
71
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/CredentialsProvider.java
vendored
Normal file
71
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/CredentialsProvider.java
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.auth.AuthScope;
|
||||
import ch.boye.httpclientandroidlib.auth.Credentials;
|
||||
|
||||
/**
|
||||
* Abstract credentials provider that maintains a collection of user
|
||||
* credentials.
|
||||
* <p>
|
||||
* Implementations of this interface must be thread-safe. Access to shared
|
||||
* data must be synchronized as methods of this interface may be executed
|
||||
* from multiple threads.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface CredentialsProvider {
|
||||
|
||||
/**
|
||||
* Sets the {@link Credentials credentials} for the given authentication
|
||||
* scope. Any previous credentials for the given scope will be overwritten.
|
||||
*
|
||||
* @param authscope the {@link AuthScope authentication scope}
|
||||
* @param credentials the authentication {@link Credentials credentials}
|
||||
* for the given scope.
|
||||
*
|
||||
* @see #getCredentials(AuthScope)
|
||||
*/
|
||||
void setCredentials(AuthScope authscope, Credentials credentials);
|
||||
|
||||
/**
|
||||
* Get the {@link Credentials credentials} for the given authentication scope.
|
||||
*
|
||||
* @param authscope the {@link AuthScope authentication scope}
|
||||
* @return the credentials
|
||||
*
|
||||
* @see #setCredentials(AuthScope, Credentials)
|
||||
*/
|
||||
Credentials getCredentials(AuthScope authscope);
|
||||
|
||||
/**
|
||||
* Clears all credentials.
|
||||
*/
|
||||
void clear();
|
||||
|
||||
}
|
||||
258
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/HttpClient.java
vendored
Normal file
258
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/HttpClient.java
vendored
Normal file
|
|
@ -0,0 +1,258 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpHost;
|
||||
import ch.boye.httpclientandroidlib.HttpRequest;
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
import ch.boye.httpclientandroidlib.client.methods.HttpUriRequest;
|
||||
import ch.boye.httpclientandroidlib.conn.ClientConnectionManager;
|
||||
import ch.boye.httpclientandroidlib.params.HttpParams;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* This interface represents only the most basic contract for HTTP request
|
||||
* execution. It imposes no restrictions or particular details on the request
|
||||
* execution process and leaves the specifics of state management,
|
||||
* authentication and redirect handling up to individual implementations.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public interface HttpClient {
|
||||
|
||||
|
||||
/**
|
||||
* Obtains the parameters for this client.
|
||||
* These parameters will become defaults for all requests being
|
||||
* executed with this client, and for the parameters of
|
||||
* dependent objects in this client.
|
||||
*
|
||||
* @return the default parameters
|
||||
*
|
||||
* @deprecated (4.3) use
|
||||
* {@link ch.boye.httpclientandroidlib.client.config.RequestConfig}.
|
||||
*/
|
||||
@Deprecated
|
||||
HttpParams getParams();
|
||||
|
||||
/**
|
||||
* Obtains the connection manager used by this client.
|
||||
*
|
||||
* @return the connection manager
|
||||
*
|
||||
* @deprecated (4.3) use
|
||||
* {@link ch.boye.httpclientandroidlib.impl.client.HttpClientBuilder}.
|
||||
*/
|
||||
@Deprecated
|
||||
ClientConnectionManager getConnectionManager();
|
||||
|
||||
/**
|
||||
* Executes HTTP request using the default context.
|
||||
*
|
||||
* @param request the request to execute
|
||||
*
|
||||
* @return the response to the request. This is always a final response,
|
||||
* never an intermediate response with an 1xx status code.
|
||||
* Whether redirects or authentication challenges will be returned
|
||||
* or handled automatically depends on the implementation and
|
||||
* configuration of this client.
|
||||
* @throws IOException in case of a problem or the connection was aborted
|
||||
* @throws ClientProtocolException in case of an http protocol error
|
||||
*/
|
||||
HttpResponse execute(HttpUriRequest request)
|
||||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes HTTP request using the given context.
|
||||
*
|
||||
* @param request the request to execute
|
||||
* @param context the context to use for the execution, or
|
||||
* <code>null</code> to use the default context
|
||||
*
|
||||
* @return the response to the request. This is always a final response,
|
||||
* never an intermediate response with an 1xx status code.
|
||||
* Whether redirects or authentication challenges will be returned
|
||||
* or handled automatically depends on the implementation and
|
||||
* configuration of this client.
|
||||
* @throws IOException in case of a problem or the connection was aborted
|
||||
* @throws ClientProtocolException in case of an http protocol error
|
||||
*/
|
||||
HttpResponse execute(HttpUriRequest request, HttpContext context)
|
||||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes HTTP request using the default context.
|
||||
*
|
||||
* @param target the target host for the request.
|
||||
* Implementations may accept <code>null</code>
|
||||
* if they can still determine a route, for example
|
||||
* to a default target or by inspecting the request.
|
||||
* @param request the request to execute
|
||||
*
|
||||
* @return the response to the request. This is always a final response,
|
||||
* never an intermediate response with an 1xx status code.
|
||||
* Whether redirects or authentication challenges will be returned
|
||||
* or handled automatically depends on the implementation and
|
||||
* configuration of this client.
|
||||
* @throws IOException in case of a problem or the connection was aborted
|
||||
* @throws ClientProtocolException in case of an http protocol error
|
||||
*/
|
||||
HttpResponse execute(HttpHost target, HttpRequest request)
|
||||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes HTTP request using the given context.
|
||||
*
|
||||
* @param target the target host for the request.
|
||||
* Implementations may accept <code>null</code>
|
||||
* if they can still determine a route, for example
|
||||
* to a default target or by inspecting the request.
|
||||
* @param request the request to execute
|
||||
* @param context the context to use for the execution, or
|
||||
* <code>null</code> to use the default context
|
||||
*
|
||||
* @return the response to the request. This is always a final response,
|
||||
* never an intermediate response with an 1xx status code.
|
||||
* Whether redirects or authentication challenges will be returned
|
||||
* or handled automatically depends on the implementation and
|
||||
* configuration of this client.
|
||||
* @throws IOException in case of a problem or the connection was aborted
|
||||
* @throws ClientProtocolException in case of an http protocol error
|
||||
*/
|
||||
HttpResponse execute(HttpHost target, HttpRequest request,
|
||||
HttpContext context)
|
||||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes HTTP request using the default context and processes the
|
||||
* response using the given response handler.
|
||||
* <p/>
|
||||
* Implementing classes are required to ensure that the content entity
|
||||
* associated with the response is fully consumed and the underlying
|
||||
* connection is released back to the connection manager automatically
|
||||
* in all cases relieving individual {@link ResponseHandler}s from
|
||||
* having to manage resource deallocation internally.
|
||||
*
|
||||
* @param request the request to execute
|
||||
* @param responseHandler the response handler
|
||||
*
|
||||
* @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
|
||||
*/
|
||||
<T> T execute(
|
||||
HttpUriRequest request,
|
||||
ResponseHandler<? extends T> responseHandler)
|
||||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes HTTP request using the given context and processes the
|
||||
* response using the given response handler.
|
||||
* <p/>
|
||||
* Implementing classes are required to ensure that the content entity
|
||||
* associated with the response is fully consumed and the underlying
|
||||
* connection is released back to the connection manager automatically
|
||||
* in all cases relieving individual {@link ResponseHandler}s from
|
||||
* having to manage resource deallocation internally.
|
||||
*
|
||||
* @param request the request to execute
|
||||
* @param responseHandler the response handler
|
||||
* @param context the context to use for the execution, or
|
||||
* <code>null</code> to use the default context
|
||||
*
|
||||
* @return the response object as generated by the response handler.
|
||||
* @throws IOException in case of a problem or the connection was aborted
|
||||
* @throws ClientProtocolException in case of an http protocol error
|
||||
*/
|
||||
<T> T execute(
|
||||
HttpUriRequest request,
|
||||
ResponseHandler<? extends T> responseHandler,
|
||||
HttpContext context)
|
||||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes HTTP request to the target using the default context and
|
||||
* processes the response using the given response handler.
|
||||
* <p/>
|
||||
* Implementing classes are required to ensure that the content entity
|
||||
* associated with the response is fully consumed and the underlying
|
||||
* connection is released back to the connection manager automatically
|
||||
* in all cases relieving individual {@link ResponseHandler}s from
|
||||
* having to manage resource deallocation internally.
|
||||
*
|
||||
* @param target the target host for the request.
|
||||
* Implementations may accept <code>null</code>
|
||||
* 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
|
||||
*/
|
||||
<T> T execute(
|
||||
HttpHost target,
|
||||
HttpRequest request,
|
||||
ResponseHandler<? extends T> responseHandler)
|
||||
throws IOException, ClientProtocolException;
|
||||
|
||||
/**
|
||||
* Executes HTTP request to the target using the given context and
|
||||
* processes the response using the given response handler.
|
||||
* <p/>
|
||||
* Implementing classes are required to ensure that the content entity
|
||||
* associated with the response is fully consumed and the underlying
|
||||
* connection is released back to the connection manager automatically
|
||||
* in all cases relieving individual {@link ResponseHandler}s from
|
||||
* having to manage resource deallocation internally.
|
||||
*
|
||||
* @param target the target host for the request.
|
||||
* Implementations may accept <code>null</code>
|
||||
* 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
|
||||
* <code>null</code> to use the default context
|
||||
*
|
||||
* @return the response object as generated by the response handler.
|
||||
* @throws IOException in case of a problem or the connection was aborted
|
||||
* @throws ClientProtocolException in case of an http protocol error
|
||||
*/
|
||||
<T> T execute(
|
||||
HttpHost target,
|
||||
HttpRequest request,
|
||||
ResponseHandler<? extends T> responseHandler,
|
||||
HttpContext context)
|
||||
throws IOException, ClientProtocolException;
|
||||
|
||||
}
|
||||
60
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/HttpRequestRetryHandler.java
vendored
Normal file
60
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/HttpRequestRetryHandler.java
vendored
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* A handler for determining if an HttpRequest should be retried after a
|
||||
* recoverable exception during execution.
|
||||
* <p>
|
||||
* Implementations of this interface must be thread-safe. Access to shared
|
||||
* data must be synchronized as methods of this interface may be executed
|
||||
* from multiple threads.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface HttpRequestRetryHandler {
|
||||
|
||||
/**
|
||||
* Determines if a method should be retried after an IOException
|
||||
* occurs during execution.
|
||||
*
|
||||
* @param exception the exception that occurred
|
||||
* @param executionCount the number of times this method has been
|
||||
* unsuccessfully executed
|
||||
* @param context the context for the request execution
|
||||
*
|
||||
* @return <code>true</code> if the method should be retried, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
boolean retryRequest(IOException exception, int executionCount, HttpContext context);
|
||||
|
||||
}
|
||||
52
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/HttpResponseException.java
vendored
Normal file
52
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/HttpResponseException.java
vendored
Normal file
|
|
@ -0,0 +1,52 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Signals a non 2xx HTTP response.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class HttpResponseException extends ClientProtocolException {
|
||||
|
||||
private static final long serialVersionUID = -7186627969477257933L;
|
||||
|
||||
private final int statusCode;
|
||||
|
||||
public HttpResponseException(final int statusCode, final String s) {
|
||||
super(s);
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public int getStatusCode() {
|
||||
return this.statusCode;
|
||||
}
|
||||
|
||||
}
|
||||
72
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/NonRepeatableRequestException.java
vendored
Normal file
72
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/NonRepeatableRequestException.java
vendored
Normal file
|
|
@ -0,0 +1,72 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.ProtocolException;
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Signals failure to retry the request due to non-repeatable request
|
||||
* entity.
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class NonRepeatableRequestException extends ProtocolException {
|
||||
|
||||
private static final long serialVersionUID = 82685265288806048L;
|
||||
|
||||
/**
|
||||
* Creates a new NonRepeatableEntityException with a <tt>null</tt> detail message.
|
||||
*/
|
||||
public NonRepeatableRequestException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new NonRepeatableEntityException with the specified detail message.
|
||||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public NonRepeatableRequestException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new NonRepeatableEntityException with the specified detail message.
|
||||
*
|
||||
* @param message The exception detail message
|
||||
* @param cause the cause
|
||||
*/
|
||||
public NonRepeatableRequestException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
69
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/RedirectException.java
vendored
Normal file
69
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/RedirectException.java
vendored
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.ProtocolException;
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Signals violation of HTTP specification caused by an invalid redirect
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
@Immutable
|
||||
public class RedirectException extends ProtocolException {
|
||||
|
||||
private static final long serialVersionUID = 4418824536372559326L;
|
||||
|
||||
/**
|
||||
* Creates a new RedirectException with a <tt>null</tt> detail message.
|
||||
*/
|
||||
public RedirectException() {
|
||||
super();
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new RedirectException with the specified detail message.
|
||||
*
|
||||
* @param message The exception detail message
|
||||
*/
|
||||
public RedirectException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new RedirectException with the specified detail message and cause.
|
||||
*
|
||||
* @param message the exception detail message
|
||||
* @param cause the <tt>Throwable</tt> that caused this exception, or <tt>null</tt>
|
||||
* if the cause is unavailable, unknown, or not a <tt>Throwable</tt>
|
||||
*/
|
||||
public RedirectException(final String message, final Throwable cause) {
|
||||
super(message, cause);
|
||||
}
|
||||
}
|
||||
77
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/RedirectHandler.java
vendored
Normal file
77
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/RedirectHandler.java
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import java.net.URI;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
import ch.boye.httpclientandroidlib.ProtocolException;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* A handler for determining if an HTTP request should be redirected to
|
||||
* a new location in response to an HTTP response received from the target
|
||||
* server.
|
||||
* <p>
|
||||
* Implementations of this interface must be thread-safe. Access to shared
|
||||
* data must be synchronized as methods of this interface may be executed
|
||||
* from multiple threads.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.1) use {@link RedirectStrategy}
|
||||
*/
|
||||
@Deprecated
|
||||
public interface RedirectHandler {
|
||||
|
||||
/**
|
||||
* Determines if a request should be redirected to a new location
|
||||
* given the response from the target server.
|
||||
*
|
||||
* @param response the response received from the target server
|
||||
* @param context the context for the request execution
|
||||
*
|
||||
* @return <code>true</code> if the request should be redirected, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
boolean isRedirectRequested(HttpResponse response, HttpContext context);
|
||||
|
||||
/**
|
||||
* Determines the location request is expected to be redirected to
|
||||
* given the response from the target server and the current request
|
||||
* execution context.
|
||||
*
|
||||
* @param response the response received from the target server
|
||||
* @param context the context for the request execution
|
||||
*
|
||||
* @return redirect URI
|
||||
*/
|
||||
URI getLocationURI(HttpResponse response, HttpContext context)
|
||||
throws ProtocolException;
|
||||
|
||||
}
|
||||
81
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/RedirectStrategy.java
vendored
Normal file
81
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/RedirectStrategy.java
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpRequest;
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
import ch.boye.httpclientandroidlib.ProtocolException;
|
||||
import ch.boye.httpclientandroidlib.client.methods.HttpUriRequest;
|
||||
import ch.boye.httpclientandroidlib.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.
|
||||
* <p>
|
||||
* Implementations of this interface must be thread-safe. Access to shared
|
||||
* data must be synchronized as methods of this interface may be executed
|
||||
* from multiple threads.
|
||||
*
|
||||
* @since 4.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 <code>true</code> if the request should be redirected, <code>false</code>
|
||||
* 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;
|
||||
|
||||
}
|
||||
77
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/RequestDirector.java
vendored
Normal file
77
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/RequestDirector.java
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpException;
|
||||
import ch.boye.httpclientandroidlib.HttpHost;
|
||||
import ch.boye.httpclientandroidlib.HttpRequest;
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* A client-side request director.
|
||||
* The director decides which steps are necessary to execute a request.
|
||||
* It establishes connections and optionally processes redirects and
|
||||
* authentication challenges. The director may therefore generate and
|
||||
* send a sequence of requests in order to execute one initial request.
|
||||
*
|
||||
* @since 4.0
|
||||
*
|
||||
* @deprecated (4.3) No longer used
|
||||
*/
|
||||
@Deprecated
|
||||
public interface RequestDirector {
|
||||
|
||||
|
||||
/**
|
||||
* Executes a request.
|
||||
* <br/><b>Note:</b>
|
||||
* For the time being, a new director is instantiated for each request.
|
||||
* This is the same behavior as for <code>HttpMethodDirector</code>
|
||||
* in HttpClient 3.
|
||||
*
|
||||
* @param target the target host for the request.
|
||||
* Implementations may accept <code>null</code>
|
||||
* if they can still determine a route, for example
|
||||
* to a default target or by inspecting the request.
|
||||
* @param request the request to execute
|
||||
* @param context the context for executing the request
|
||||
*
|
||||
* @return the final response to the request.
|
||||
* This is never an intermediate response with status code 1xx.
|
||||
*
|
||||
* @throws HttpException in case of a problem
|
||||
* @throws IOException in case of an IO problem
|
||||
* or if the connection was aborted
|
||||
*/
|
||||
HttpResponse execute(HttpHost target, HttpRequest request, HttpContext context)
|
||||
throws HttpException, IOException;
|
||||
|
||||
}
|
||||
54
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/ResponseHandler.java
vendored
Normal file
54
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/ResponseHandler.java
vendored
Normal file
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
|
||||
/**
|
||||
* Handler that encapsulates the process of generating a response object
|
||||
* from a {@link HttpResponse}.
|
||||
*
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface ResponseHandler<T> {
|
||||
|
||||
/**
|
||||
* Processes an {@link HttpResponse} and returns some value
|
||||
* corresponding to that response.
|
||||
*
|
||||
* @param response The response to process
|
||||
* @return A value determined by the response
|
||||
*
|
||||
* @throws ClientProtocolException in case of an http protocol error
|
||||
* @throws IOException in case of a problem or the connection was aborted
|
||||
*/
|
||||
T handleResponse(HttpResponse response) throws ClientProtocolException, IOException;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.HttpResponse;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* Strategy interface that allows API users to plug in their own logic to
|
||||
* control whether or not a retry should automatically be done, how many times
|
||||
* it should be retried and so on.
|
||||
*
|
||||
* @since 4.2
|
||||
*/
|
||||
public interface ServiceUnavailableRetryStrategy {
|
||||
|
||||
/**
|
||||
* Determines if a method should be retried given the response from the target server.
|
||||
*
|
||||
* @param response the response from the target server
|
||||
* @param executionCount the number of times this method has been
|
||||
* unsuccessfully executed
|
||||
* @param context the context for the request execution
|
||||
|
||||
* @return <code>true</code> if the method should be retried, <code>false</code>
|
||||
* otherwise
|
||||
*/
|
||||
boolean retryRequest(HttpResponse response, int executionCount, HttpContext context);
|
||||
|
||||
/**
|
||||
* @return The interval between the subsequent auto-retries.
|
||||
*/
|
||||
long getRetryInterval();
|
||||
|
||||
}
|
||||
58
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/UserTokenHandler.java
vendored
Normal file
58
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/UserTokenHandler.java
vendored
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
|
||||
package ch.boye.httpclientandroidlib.client;
|
||||
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* A handler for determining if the given execution context is user specific
|
||||
* or not. The token object returned by this handler is expected to uniquely
|
||||
* identify the current user if the context is user specific or to be
|
||||
* <code>null</code> if the context does not contain any resources or details
|
||||
* specific to the current user.
|
||||
* <p/>
|
||||
* The user token will be used to ensure that user specific resources will not
|
||||
* be shared with or reused by other users.
|
||||
*
|
||||
* @since 4.0
|
||||
*/
|
||||
public interface UserTokenHandler {
|
||||
|
||||
/**
|
||||
* The token object returned by this method is expected to uniquely
|
||||
* identify the current user if the context is user specific or to be
|
||||
* <code>null</code> if it is not.
|
||||
*
|
||||
* @param context the execution context
|
||||
*
|
||||
* @return user token that uniquely identifies the user or
|
||||
* <code>null</null> if the context is not user specific.
|
||||
*/
|
||||
Object getUserToken(HttpContext context);
|
||||
|
||||
}
|
||||
55
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/CacheResponseStatus.java
vendored
Normal file
55
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/CacheResponseStatus.java
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
/**
|
||||
* This enumeration represents the various ways a response can be generated
|
||||
* by the {@link ch.boye.httpclientandroidlib.impl.client.cache.CachingHttpClient};
|
||||
* if a request is executed with an {@link ch.boye.httpclientandroidlib.protocol.HttpContext}
|
||||
* then a parameter with one of these values will be registered in the
|
||||
* context under the key
|
||||
* {@link ch.boye.httpclientandroidlib.impl.client.cache.CachingHttpClient#CACHE_RESPONSE_STATUS}.
|
||||
*/
|
||||
public enum CacheResponseStatus {
|
||||
|
||||
/** The response was generated directly by the caching module. */
|
||||
CACHE_MODULE_RESPONSE,
|
||||
|
||||
/** A response was generated from the cache with no requests sent
|
||||
* upstream.
|
||||
*/
|
||||
CACHE_HIT,
|
||||
|
||||
/** The response came from an upstream server. */
|
||||
CACHE_MISS,
|
||||
|
||||
/** The response was generated from the cache after validating the
|
||||
* entry with the origin server.
|
||||
*/
|
||||
VALIDATED;
|
||||
|
||||
}
|
||||
81
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HeaderConstants.java
vendored
Normal file
81
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HeaderConstants.java
vendored
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
|
||||
/**
|
||||
* Records static constants for various HTTP header names.
|
||||
* @since 4.1
|
||||
*/
|
||||
@Immutable
|
||||
public class HeaderConstants {
|
||||
|
||||
public static final String GET_METHOD = "GET";
|
||||
public static final String HEAD_METHOD = "HEAD";
|
||||
public static final String OPTIONS_METHOD = "OPTIONS";
|
||||
public static final String PUT_METHOD = "PUT";
|
||||
public static final String DELETE_METHOD = "DELETE";
|
||||
public static final String TRACE_METHOD = "TRACE";
|
||||
|
||||
public static final String LAST_MODIFIED = "Last-Modified";
|
||||
public static final String IF_MATCH = "If-Match";
|
||||
public static final String IF_RANGE = "If-Range";
|
||||
public static final String IF_UNMODIFIED_SINCE = "If-Unmodified-Since";
|
||||
public static final String IF_MODIFIED_SINCE = "If-Modified-Since";
|
||||
public static final String IF_NONE_MATCH = "If-None-Match";
|
||||
|
||||
public static final String PRAGMA = "Pragma";
|
||||
public static final String MAX_FORWARDS = "Max-Forwards";
|
||||
public static final String ETAG = "ETag";
|
||||
public static final String EXPIRES = "Expires";
|
||||
public static final String AGE = "Age";
|
||||
public static final String VARY = "Vary";
|
||||
public static final String ALLOW = "Allow";
|
||||
public static final String VIA = "Via";
|
||||
public static final String PUBLIC = "public";
|
||||
public static final String PRIVATE = "private";
|
||||
|
||||
public static final String CACHE_CONTROL = "Cache-Control";
|
||||
public static final String CACHE_CONTROL_NO_STORE = "no-store";
|
||||
public static final String CACHE_CONTROL_NO_CACHE = "no-cache";
|
||||
public static final String CACHE_CONTROL_MAX_AGE = "max-age";
|
||||
public static final String CACHE_CONTROL_MAX_STALE = "max-stale";
|
||||
public static final String CACHE_CONTROL_MIN_FRESH = "min-fresh";
|
||||
public static final String CACHE_CONTROL_MUST_REVALIDATE = "must-revalidate";
|
||||
public static final String CACHE_CONTROL_PROXY_REVALIDATE = "proxy-revalidate";
|
||||
public static final String STALE_IF_ERROR = "stale-if-error";
|
||||
public static final String STALE_WHILE_REVALIDATE = "stale-while-revalidate";
|
||||
|
||||
public static final String WARNING = "Warning";
|
||||
public static final String RANGE = "Range";
|
||||
public static final String CONTENT_RANGE = "Content-Range";
|
||||
public static final String WWW_AUTHENTICATE = "WWW-Authenticate";
|
||||
public static final String PROXY_AUTHENTICATE = "Proxy-Authenticate";
|
||||
public static final String AUTHORIZATION = "Authorization";
|
||||
|
||||
}
|
||||
71
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheContext.java
vendored
Normal file
71
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheContext.java
vendored
Normal file
|
|
@ -0,0 +1,71 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import ch.boye.httpclientandroidlib.annotation.NotThreadSafe;
|
||||
import ch.boye.httpclientandroidlib.client.protocol.HttpClientContext;
|
||||
import ch.boye.httpclientandroidlib.protocol.BasicHttpContext;
|
||||
import ch.boye.httpclientandroidlib.protocol.HttpContext;
|
||||
|
||||
/**
|
||||
* @since 4.3
|
||||
*/
|
||||
@NotThreadSafe
|
||||
public class HttpCacheContext extends HttpClientContext {
|
||||
|
||||
/**
|
||||
* This is the name under which the {@link CacheResponseStatus} of a request
|
||||
* (for example, whether it resulted in a cache hit) will be recorded if an
|
||||
* {@link HttpContext} is provided during execution.
|
||||
*/
|
||||
public static final String CACHE_RESPONSE_STATUS = "http.cache.response.status";
|
||||
|
||||
public static HttpCacheContext adapt(final HttpContext context) {
|
||||
if (context instanceof HttpCacheContext) {
|
||||
return (HttpCacheContext) context;
|
||||
} else {
|
||||
return new HttpCacheContext(context);
|
||||
}
|
||||
}
|
||||
|
||||
public static HttpCacheContext create() {
|
||||
return new HttpCacheContext(new BasicHttpContext());
|
||||
}
|
||||
|
||||
public HttpCacheContext(final HttpContext context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
public HttpCacheContext() {
|
||||
super();
|
||||
}
|
||||
|
||||
public CacheResponseStatus getCacheResponseStatus() {
|
||||
return getAttribute(CACHE_RESPONSE_STATUS, CacheResponseStatus.class);
|
||||
}
|
||||
|
||||
}
|
||||
263
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheEntry.java
vendored
Normal file
263
mobile/android/thirdparty/ch/boye/httpclientandroidlib/client/cache/HttpCacheEntry.java
vendored
Normal file
|
|
@ -0,0 +1,263 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import ch.boye.httpclientandroidlib.Header;
|
||||
import ch.boye.httpclientandroidlib.ProtocolVersion;
|
||||
import ch.boye.httpclientandroidlib.StatusLine;
|
||||
import ch.boye.httpclientandroidlib.annotation.Immutable;
|
||||
import ch.boye.httpclientandroidlib.client.utils.DateUtils;
|
||||
import ch.boye.httpclientandroidlib.message.HeaderGroup;
|
||||
import ch.boye.httpclientandroidlib.protocol.HTTP;
|
||||
import ch.boye.httpclientandroidlib.util.Args;
|
||||
|
||||
/**
|
||||
* Structure used to store an {@link ch.boye.httpclientandroidlib.HttpResponse} in a cache.
|
||||
* Some entries can optionally depend on system resources that may require
|
||||
* explicit deallocation. In such a case {@link #getResource()} should return
|
||||
* a non null instance of {@link Resource} that must be deallocated by calling
|
||||
* {@link Resource#dispose()} method when no longer used.
|
||||
*
|
||||
* @since 4.1
|
||||
*/
|
||||
@Immutable
|
||||
public class HttpCacheEntry implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = -6300496422359477413L;
|
||||
|
||||
private final Date requestDate;
|
||||
private final Date responseDate;
|
||||
private final StatusLine statusLine;
|
||||
private final HeaderGroup responseHeaders;
|
||||
private final Resource resource;
|
||||
private final Map<String,String> variantMap;
|
||||
private final Date date;
|
||||
|
||||
/**
|
||||
* Create a new {@link HttpCacheEntry} with variants.
|
||||
* @param requestDate
|
||||
* Date/time when the request was made (Used for age
|
||||
* calculations)
|
||||
* @param responseDate
|
||||
* Date/time that the response came back (Used for age
|
||||
* calculations)
|
||||
* @param statusLine
|
||||
* HTTP status line from origin response
|
||||
* @param responseHeaders
|
||||
* Header[] from original HTTP Response
|
||||
* @param resource representing origin response body
|
||||
* @param variantMap describing cache entries that are variants
|
||||
* of this parent entry; this maps a "variant key" (derived
|
||||
* from the varying request headers) to a "cache key" (where
|
||||
* in the cache storage the particular variant is located)
|
||||
*/
|
||||
public HttpCacheEntry(
|
||||
final Date requestDate,
|
||||
final Date responseDate,
|
||||
final StatusLine statusLine,
|
||||
final Header[] responseHeaders,
|
||||
final Resource resource,
|
||||
final Map<String,String> variantMap) {
|
||||
super();
|
||||
Args.notNull(requestDate, "Request date");
|
||||
Args.notNull(responseDate, "Response date");
|
||||
Args.notNull(statusLine, "Status line");
|
||||
Args.notNull(responseHeaders, "Response headers");
|
||||
this.requestDate = requestDate;
|
||||
this.responseDate = responseDate;
|
||||
this.statusLine = statusLine;
|
||||
this.responseHeaders = new HeaderGroup();
|
||||
this.responseHeaders.setHeaders(responseHeaders);
|
||||
this.resource = resource;
|
||||
this.variantMap = variantMap != null
|
||||
? new HashMap<String,String>(variantMap)
|
||||
: null;
|
||||
this.date = parseDate();
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a new {@link HttpCacheEntry}.
|
||||
*
|
||||
* @param requestDate
|
||||
* Date/time when the request was made (Used for age
|
||||
* calculations)
|
||||
* @param responseDate
|
||||
* Date/time that the response came back (Used for age
|
||||
* calculations)
|
||||
* @param statusLine
|
||||
* HTTP status line from origin response
|
||||
* @param responseHeaders
|
||||
* Header[] from original HTTP Response
|
||||
* @param resource representing origin response body
|
||||
*/
|
||||
public HttpCacheEntry(final Date requestDate, final Date responseDate, final StatusLine statusLine,
|
||||
final Header[] responseHeaders, final Resource resource) {
|
||||
this(requestDate, responseDate, statusLine, responseHeaders, resource,
|
||||
new HashMap<String,String>());
|
||||
}
|
||||
|
||||
/**
|
||||
* Find the "Date" response header and parse it into a java.util.Date
|
||||
* @return the Date value of the header or null if the header is not present
|
||||
*/
|
||||
private Date parseDate() {
|
||||
final Header dateHdr = getFirstHeader(HTTP.DATE_HEADER);
|
||||
if (dateHdr == null) {
|
||||
return null;
|
||||
}
|
||||
return DateUtils.parseDate(dateHdr.getValue());
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link StatusLine} from the origin
|
||||
* {@link ch.boye.httpclientandroidlib.HttpResponse}.
|
||||
*/
|
||||
public StatusLine getStatusLine() {
|
||||
return this.statusLine;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link ProtocolVersion} from the origin
|
||||
* {@link ch.boye.httpclientandroidlib.HttpResponse}.
|
||||
*/
|
||||
public ProtocolVersion getProtocolVersion() {
|
||||
return this.statusLine.getProtocolVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the reason phrase from the origin
|
||||
* {@link ch.boye.httpclientandroidlib.HttpResponse}, for example, "Not Modified".
|
||||
*/
|
||||
public String getReasonPhrase() {
|
||||
return this.statusLine.getReasonPhrase();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the HTTP response code from the origin
|
||||
* {@link ch.boye.httpclientandroidlib.HttpResponse}.
|
||||
*/
|
||||
public int getStatusCode() {
|
||||
return this.statusLine.getStatusCode();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time the associated origin request was initiated by the
|
||||
* caching module.
|
||||
* @return {@link Date}
|
||||
*/
|
||||
public Date getRequestDate() {
|
||||
return requestDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the time the origin response was received by the caching module.
|
||||
* @return {@link Date}
|
||||
*/
|
||||
public Date getResponseDate() {
|
||||
return responseDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all the headers that were on the origin response.
|
||||
*/
|
||||
public Header[] getAllHeaders() {
|
||||
return responseHeaders.getAllHeaders();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the first header from the origin response with the given
|
||||
* name.
|
||||
*/
|
||||
public Header getFirstHeader(final String name) {
|
||||
return responseHeaders.getFirstHeader(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets all the headers with the given name that were on the origin
|
||||
* response.
|
||||
*/
|
||||
public Header[] getHeaders(final String name) {
|
||||
return responseHeaders.getHeaders(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the Date value of the "Date" header or null if the header is missing or cannot be
|
||||
* parsed.
|
||||
*
|
||||
* @since 4.3
|
||||
*/
|
||||
public Date getDate() {
|
||||
return date;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the {@link Resource} containing the origin response body.
|
||||
*/
|
||||
public Resource getResource() {
|
||||
return this.resource;
|
||||
}
|
||||
|
||||
/**
|
||||
* Indicates whether the origin response indicated the associated
|
||||
* resource had variants (i.e. that the Vary header was set on the
|
||||
* origin response).
|
||||
* @return {@code true} if this cached response was a variant
|
||||
*/
|
||||
public boolean hasVariants() {
|
||||
return getFirstHeader(HeaderConstants.VARY) != null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an index about where in the cache different variants for
|
||||
* a given resource are stored. This maps "variant keys" to "cache keys",
|
||||
* where the variant key is derived from the varying request headers,
|
||||
* and the cache key is the location in the
|
||||
* {@link ch.boye.httpclientandroidlib.client.cache.HttpCacheStorage} where that
|
||||
* particular variant is stored. The first variant returned is used as
|
||||
* the "parent" entry to hold this index of the other variants.
|
||||
*/
|
||||
public Map<String, String> getVariantMap() {
|
||||
return Collections.unmodifiableMap(variantMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a string representation of this instance suitable for
|
||||
* human consumption.
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
return "[request date=" + this.requestDate + "; response date=" + this.responseDate
|
||||
+ "; statusLine=" + this.statusLine + "]";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/*
|
||||
* ====================================================================
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you under the Apache License, Version 2.0 (the
|
||||
* "License"); you may not use this file except in compliance
|
||||
* with the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
* ====================================================================
|
||||
*
|
||||
* This software consists of voluntary contributions made by many
|
||||
* individuals on behalf of the Apache Software Foundation. For more
|
||||
* information on the Apache Software Foundation, please see
|
||||
* <http://www.apache.org/>.
|
||||
*
|
||||
*/
|
||||
package ch.boye.httpclientandroidlib.client.cache;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* Thrown if serialization or deserialization of an {@link HttpCacheEntry}
|
||||
* fails.
|
||||
*/
|
||||
public class HttpCacheEntrySerializationException extends IOException {
|
||||
|
||||
private static final long serialVersionUID = 9219188365878433519L;
|
||||
|
||||
public HttpCacheEntrySerializationException(final String message) {
|
||||
super();
|
||||
}
|
||||
|
||||
public HttpCacheEntrySerializationException(final String message, final Throwable cause) {
|
||||
super(message);
|
||||
initCause(cause);
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue