mirror of
https://github.com/square/okhttp.git
synced 2026-01-24 04:02:07 +03:00
Merge pull request #9 from square/project-cleanup
General project clean-up and tweaks.
This commit is contained in:
26
.gitignore
vendored
26
.gitignore
vendored
@@ -1,6 +1,22 @@
|
||||
*.class
|
||||
.classpath
|
||||
.project
|
||||
.settings
|
||||
eclipsebin
|
||||
|
||||
# Package Files #
|
||||
*.jar
|
||||
*.war
|
||||
*.ear
|
||||
bin
|
||||
gen
|
||||
build
|
||||
out
|
||||
lib
|
||||
|
||||
target
|
||||
pom.xml.*
|
||||
release.properties
|
||||
|
||||
.idea
|
||||
*.iml
|
||||
classes
|
||||
|
||||
obj
|
||||
|
||||
.DS_Store
|
||||
|
||||
55
README.md
55
README.md
@@ -1,4 +1,57 @@
|
||||
okhttp
|
||||
======
|
||||
|
||||
An HTTP+SPDY client for Android and Java applications
|
||||
An HTTP+SPDY client for Android and Java applications.
|
||||
|
||||
|
||||
Download
|
||||
--------
|
||||
|
||||
Downloadable .jars can be found on the [GitHub download page][1].
|
||||
|
||||
You can also depend on the .jar through Maven:
|
||||
|
||||
```xml
|
||||
<dependency>
|
||||
<groupId>com.squareup</groupId>
|
||||
<artifactId>okhttp</artifactId>
|
||||
<version>(insert latest version)</version>
|
||||
</dependency>
|
||||
```
|
||||
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
If you would like to contribute code to OKHTTP you can do so through GitHub by
|
||||
forking the repository and sending a pull request.
|
||||
|
||||
When submitting code, please make every effort to follow existing conventions
|
||||
and style in order to keep the code as readable as possible. Please also make
|
||||
sure your code compiles by running `mvn clean verify`. Checkstyle failures
|
||||
during compilation indicate errors in your style and can be viewed in the
|
||||
`checkstyle-result.xml` file.
|
||||
|
||||
Before your code can be accepted into the project you must also sign the
|
||||
[Individual Contributor License Agreement (CLA)][2].
|
||||
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
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.
|
||||
|
||||
|
||||
|
||||
[1]: http://github.com/square/okhttp/downloads
|
||||
[2]: https://spreadsheets.google.com/spreadsheet/viewform?formkey=dDViT2xzUHAwRkI3X3k5Z0lQM091OGc6MQ&ndplr=1
|
||||
120
checkstyle.xml
Normal file
120
checkstyle.xml
Normal file
@@ -0,0 +1,120 @@
|
||||
<?xml version="1.0"?>
|
||||
<!DOCTYPE module PUBLIC
|
||||
"-//Puppy Crawl//DTD Check Configuration 1.2//EN"
|
||||
"http://www.puppycrawl.com/dtds/configuration_1_2.dtd">
|
||||
|
||||
<module name="Checker">
|
||||
<module name="NewlineAtEndOfFile"/>
|
||||
<module name="FileLength"/>
|
||||
<module name="FileTabCharacter"/>
|
||||
|
||||
<!-- Trailing spaces -->
|
||||
<module name="RegexpSingleline">
|
||||
<property name="format" value="\s+$"/>
|
||||
<property name="message" value="Line has trailing spaces."/>
|
||||
</module>
|
||||
|
||||
<module name="TreeWalker">
|
||||
<property name="cacheFile" value="${checkstyle.cache.file}"/>
|
||||
|
||||
<!-- Checks for Javadoc comments. -->
|
||||
<!-- See http://checkstyle.sf.net/config_javadoc.html -->
|
||||
<!--module name="JavadocMethod"/-->
|
||||
<!--module name="JavadocType"/-->
|
||||
<!--module name="JavadocVariable"/-->
|
||||
<module name="JavadocStyle"/>
|
||||
|
||||
|
||||
<!-- Checks for Naming Conventions. -->
|
||||
<!-- See http://checkstyle.sf.net/config_naming.html -->
|
||||
<module name="ConstantName"/>
|
||||
<module name="LocalFinalVariableName"/>
|
||||
<module name="LocalVariableName"/>
|
||||
<module name="MemberName"/>
|
||||
<module name="MethodName"/>
|
||||
<module name="PackageName"/>
|
||||
<module name="ParameterName"/>
|
||||
<module name="StaticVariableName"/>
|
||||
<module name="TypeName"/>
|
||||
|
||||
|
||||
<!-- Checks for imports -->
|
||||
<!-- See http://checkstyle.sf.net/config_import.html -->
|
||||
<module name="AvoidStarImport"/>
|
||||
<module name="IllegalImport"/> <!-- defaults to sun.* packages -->
|
||||
<module name="RedundantImport"/>
|
||||
<module name="UnusedImports"/>
|
||||
|
||||
|
||||
<!-- Checks for Size Violations. -->
|
||||
<!-- See http://checkstyle.sf.net/config_sizes.html -->
|
||||
<module name="LineLength">
|
||||
<property name="max" value="120"/>
|
||||
</module>
|
||||
<module name="MethodLength"/>
|
||||
<module name="ParameterNumber"/>
|
||||
|
||||
|
||||
<!-- Checks for whitespace -->
|
||||
<!-- See http://checkstyle.sf.net/config_whitespace.html -->
|
||||
<module name="GenericWhitespace"/>
|
||||
<module name="EmptyForIteratorPad"/>
|
||||
<module name="MethodParamPad"/>
|
||||
<module name="NoWhitespaceAfter"/>
|
||||
<module name="NoWhitespaceBefore"/>
|
||||
<module name="OperatorWrap"/>
|
||||
<module name="ParenPad"/>
|
||||
<module name="TypecastParenPad"/>
|
||||
<module name="WhitespaceAfter"/>
|
||||
<module name="WhitespaceAround"/>
|
||||
|
||||
|
||||
<!-- Modifier Checks -->
|
||||
<!-- See http://checkstyle.sf.net/config_modifiers.html -->
|
||||
<!--module name="ModifierOrder"/-->
|
||||
<module name="RedundantModifier"/>
|
||||
|
||||
|
||||
<!-- Checks for blocks. You know, those {}'s -->
|
||||
<!-- See http://checkstyle.sf.net/config_blocks.html -->
|
||||
<module name="AvoidNestedBlocks"/>
|
||||
<!--module name="EmptyBlock"/-->
|
||||
<module name="LeftCurly"/>
|
||||
<module name="NeedBraces"/>
|
||||
<module name="RightCurly"/>
|
||||
|
||||
|
||||
<!-- Checks for common coding problems -->
|
||||
<!-- See http://checkstyle.sf.net/config_coding.html -->
|
||||
<!--module name="AvoidInlineConditionals"/-->
|
||||
<module name="CovariantEquals"/>
|
||||
<module name="DoubleCheckedLocking"/>
|
||||
<module name="EmptyStatement"/>
|
||||
<module name="EqualsAvoidNull"/>
|
||||
<module name="EqualsHashCode"/>
|
||||
<!--module name="HiddenField"/-->
|
||||
<module name="IllegalInstantiation"/>
|
||||
<!--module name="InnerAssignment"/-->
|
||||
<!--module name="MagicNumber"/-->
|
||||
<!--module name="MissingSwitchDefault"/-->
|
||||
<module name="RedundantThrows"/>
|
||||
<module name="SimplifyBooleanExpression"/>
|
||||
<module name="SimplifyBooleanReturn"/>
|
||||
|
||||
<!-- Checks for class design -->
|
||||
<!-- See http://checkstyle.sf.net/config_design.html -->
|
||||
<!--module name="DesignForExtension"/-->
|
||||
<module name="FinalClass"/>
|
||||
<module name="HideUtilityClassConstructor"/>
|
||||
<module name="InterfaceIsType"/>
|
||||
<!--s/module name="VisibilityModifier"/-->
|
||||
|
||||
|
||||
<!-- Miscellaneous other checks. -->
|
||||
<!-- See http://checkstyle.sf.net/config_misc.html -->
|
||||
<module name="ArrayTypeStyle"/>
|
||||
<!--module name="FinalParameters"/-->
|
||||
<!--module name="TodoComment"/-->
|
||||
<module name="UpperEll"/>
|
||||
</module>
|
||||
</module>
|
||||
22
pom.xml
22
pom.xml
@@ -96,6 +96,7 @@
|
||||
<plugin>
|
||||
<groupId>org.sonatype.plugins</groupId>
|
||||
<artifactId>jarjar-maven-plugin</artifactId>
|
||||
<version>1.5</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>package</phase>
|
||||
@@ -118,7 +119,9 @@
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-surefire-plugin</artifactId>
|
||||
<version>2.9</version>
|
||||
<configuration>
|
||||
<argLine>-Xbootclasspath/p:${settings.localRepository}/org/mortbay/jetty/npn/npn-boot/${npn.version}/npn-boot-${npn.version}.jar</argLine>
|
||||
</configuration>
|
||||
@@ -137,6 +140,7 @@
|
||||
-->
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-enforcer-plugin</artifactId>
|
||||
<version>1.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>enforce-java</id>
|
||||
@@ -153,6 +157,24 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||
<version>2.9.1</version>
|
||||
<configuration>
|
||||
<failsOnError>true</failsOnError>
|
||||
<configLocation>checkstyle.xml</configLocation>
|
||||
<excludes>**/OsConstants.java</excludes>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>verify</phase>
|
||||
<goals>
|
||||
<goal>checkstyle</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
||||
@@ -328,157 +328,157 @@ public abstract class OkHttpConnection extends URLConnection {
|
||||
// 4XX: client error
|
||||
// 5XX: server error
|
||||
/**
|
||||
* Numeric status code, 202: Accepted
|
||||
* Numeric status code, 202: Accepted.
|
||||
*/
|
||||
public static final int HTTP_ACCEPTED = 202;
|
||||
|
||||
/**
|
||||
* Numeric status code, 502: Bad Gateway
|
||||
* Numeric status code, 502: Bad Gateway.
|
||||
*/
|
||||
public static final int HTTP_BAD_GATEWAY = 502;
|
||||
|
||||
/**
|
||||
* Numeric status code, 405: Bad Method
|
||||
* Numeric status code, 405: Bad Method.
|
||||
*/
|
||||
public static final int HTTP_BAD_METHOD = 405;
|
||||
|
||||
/**
|
||||
* Numeric status code, 400: Bad Request
|
||||
* Numeric status code, 400: Bad Request.
|
||||
*/
|
||||
public static final int HTTP_BAD_REQUEST = 400;
|
||||
|
||||
/**
|
||||
* Numeric status code, 408: Client Timeout
|
||||
* Numeric status code, 408: Client Timeout.
|
||||
*/
|
||||
public static final int HTTP_CLIENT_TIMEOUT = 408;
|
||||
|
||||
/**
|
||||
* Numeric status code, 409: Conflict
|
||||
* Numeric status code, 409: Conflict.
|
||||
*/
|
||||
public static final int HTTP_CONFLICT = 409;
|
||||
|
||||
/**
|
||||
* Numeric status code, 201: Created
|
||||
* Numeric status code, 201: Created.
|
||||
*/
|
||||
public static final int HTTP_CREATED = 201;
|
||||
|
||||
/**
|
||||
* Numeric status code, 413: Entity too large
|
||||
* Numeric status code, 413: Entity too large.
|
||||
*/
|
||||
public static final int HTTP_ENTITY_TOO_LARGE = 413;
|
||||
|
||||
/**
|
||||
* Numeric status code, 403: Forbidden
|
||||
* Numeric status code, 403: Forbidden.
|
||||
*/
|
||||
public static final int HTTP_FORBIDDEN = 403;
|
||||
|
||||
/**
|
||||
* Numeric status code, 504: Gateway timeout
|
||||
* Numeric status code, 504: Gateway timeout.
|
||||
*/
|
||||
public static final int HTTP_GATEWAY_TIMEOUT = 504;
|
||||
|
||||
/**
|
||||
* Numeric status code, 410: Gone
|
||||
* Numeric status code, 410: Gone.
|
||||
*/
|
||||
public static final int HTTP_GONE = 410;
|
||||
|
||||
/**
|
||||
* Numeric status code, 500: Internal error
|
||||
* Numeric status code, 500: Internal error.
|
||||
*/
|
||||
public static final int HTTP_INTERNAL_ERROR = 500;
|
||||
|
||||
/**
|
||||
* Numeric status code, 411: Length required
|
||||
* Numeric status code, 411: Length required.
|
||||
*/
|
||||
public static final int HTTP_LENGTH_REQUIRED = 411;
|
||||
|
||||
/**
|
||||
* Numeric status code, 301 Moved permanently
|
||||
* Numeric status code, 301 Moved permanently.
|
||||
*/
|
||||
public static final int HTTP_MOVED_PERM = 301;
|
||||
|
||||
/**
|
||||
* Numeric status code, 302: Moved temporarily
|
||||
* Numeric status code, 302: Moved temporarily.
|
||||
*/
|
||||
public static final int HTTP_MOVED_TEMP = 302;
|
||||
|
||||
/**
|
||||
* Numeric status code, 300: Multiple choices
|
||||
* Numeric status code, 300: Multiple choices.
|
||||
*/
|
||||
public static final int HTTP_MULT_CHOICE = 300;
|
||||
|
||||
/**
|
||||
* Numeric status code, 204: No content
|
||||
* Numeric status code, 204: No content.
|
||||
*/
|
||||
public static final int HTTP_NO_CONTENT = 204;
|
||||
|
||||
/**
|
||||
* Numeric status code, 406: Not acceptable
|
||||
* Numeric status code, 406: Not acceptable.
|
||||
*/
|
||||
public static final int HTTP_NOT_ACCEPTABLE = 406;
|
||||
|
||||
/**
|
||||
* Numeric status code, 203: Not authoritative
|
||||
* Numeric status code, 203: Not authoritative.
|
||||
*/
|
||||
public static final int HTTP_NOT_AUTHORITATIVE = 203;
|
||||
|
||||
/**
|
||||
* Numeric status code, 404: Not found
|
||||
* Numeric status code, 404: Not found.
|
||||
*/
|
||||
public static final int HTTP_NOT_FOUND = 404;
|
||||
|
||||
/**
|
||||
* Numeric status code, 501: Not implemented
|
||||
* Numeric status code, 501: Not implemented.
|
||||
*/
|
||||
public static final int HTTP_NOT_IMPLEMENTED = 501;
|
||||
|
||||
/**
|
||||
* Numeric status code, 304: Not modified
|
||||
* Numeric status code, 304: Not modified.
|
||||
*/
|
||||
public static final int HTTP_NOT_MODIFIED = 304;
|
||||
|
||||
/**
|
||||
* Numeric status code, 200: OK
|
||||
* Numeric status code, 200: OK.
|
||||
*/
|
||||
public static final int HTTP_OK = 200;
|
||||
|
||||
/**
|
||||
* Numeric status code, 206: Partial
|
||||
* Numeric status code, 206: Partial.
|
||||
*/
|
||||
public static final int HTTP_PARTIAL = 206;
|
||||
|
||||
/**
|
||||
* Numeric status code, 402: Payment required
|
||||
* Numeric status code, 402: Payment required.
|
||||
*/
|
||||
public static final int HTTP_PAYMENT_REQUIRED = 402;
|
||||
|
||||
/**
|
||||
* Numeric status code, 412: Precondition failed
|
||||
* Numeric status code, 412: Precondition failed.
|
||||
*/
|
||||
public static final int HTTP_PRECON_FAILED = 412;
|
||||
|
||||
/**
|
||||
* Numeric status code, 407: Proxy authentication required
|
||||
* Numeric status code, 407: Proxy authentication required.
|
||||
*/
|
||||
public static final int HTTP_PROXY_AUTH = 407;
|
||||
|
||||
/**
|
||||
* Numeric status code, 414: Request too long
|
||||
* Numeric status code, 414: Request too long.
|
||||
*/
|
||||
public static final int HTTP_REQ_TOO_LONG = 414;
|
||||
|
||||
/**
|
||||
* Numeric status code, 205: Reset
|
||||
* Numeric status code, 205: Reset.
|
||||
*/
|
||||
public static final int HTTP_RESET = 205;
|
||||
|
||||
/**
|
||||
* Numeric status code, 303: See other
|
||||
* Numeric status code, 303: See other.
|
||||
*/
|
||||
public static final int HTTP_SEE_OTHER = 303;
|
||||
|
||||
/**
|
||||
* Numeric status code, 500: Internal error
|
||||
* Numeric status code, 500: Internal error.
|
||||
*
|
||||
* @deprecated Use {@link #HTTP_INTERNAL_ERROR}
|
||||
*/
|
||||
@@ -495,22 +495,22 @@ public abstract class OkHttpConnection extends URLConnection {
|
||||
public static final int HTTP_USE_PROXY = 305;
|
||||
|
||||
/**
|
||||
* Numeric status code, 401: Unauthorized
|
||||
* Numeric status code, 401: Unauthorized.
|
||||
*/
|
||||
public static final int HTTP_UNAUTHORIZED = 401;
|
||||
|
||||
/**
|
||||
* Numeric status code, 415: Unsupported type
|
||||
* Numeric status code, 415: Unsupported type.
|
||||
*/
|
||||
public static final int HTTP_UNSUPPORTED_TYPE = 415;
|
||||
|
||||
/**
|
||||
* Numeric status code, 503: Unavailable
|
||||
* Numeric status code, 503: Unavailable.
|
||||
*/
|
||||
public static final int HTTP_UNAVAILABLE = 503;
|
||||
|
||||
/**
|
||||
* Numeric status code, 505: Version not supported
|
||||
* Numeric status code, 505: Version not supported.
|
||||
*/
|
||||
public static final int HTTP_VERSION = 505;
|
||||
|
||||
@@ -687,8 +687,8 @@ public abstract class OkHttpConnection extends URLConnection {
|
||||
}
|
||||
}
|
||||
// if none matches, then throw ProtocolException
|
||||
throw new ProtocolException("Unknown method '" + method + "'; must be one of " +
|
||||
Arrays.toString(PERMITTED_USER_METHODS));
|
||||
throw new ProtocolException("Unknown method '" + method + "'; must be one of "
|
||||
+ Arrays.toString(PERMITTED_USER_METHODS));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -112,7 +112,7 @@ public abstract class OkHttpsConnection extends OkHttpConnection {
|
||||
|
||||
private static SSLSocketFactory defaultSSLSocketFactory = (SSLSocketFactory) SSLSocketFactory
|
||||
.getDefault();
|
||||
|
||||
|
||||
public static OkHttpsConnection open(URL url) {
|
||||
return new libcore.net.http.HttpsURLConnectionImpl(url, 443);
|
||||
}
|
||||
|
||||
@@ -50,11 +50,11 @@ public final class Base64 {
|
||||
byte chr;
|
||||
// compute the number of the padding characters
|
||||
// and adjust the length of the input
|
||||
for (;;len--) {
|
||||
chr = in[len-1];
|
||||
for (;; len--) {
|
||||
chr = in[len - 1];
|
||||
// skip the neutral characters
|
||||
if ((chr == '\n') || (chr == '\r') ||
|
||||
(chr == ' ') || (chr == '\t')) {
|
||||
if ((chr == '\n') || (chr == '\r')
|
||||
|| (chr == ' ') || (chr == '\t')) {
|
||||
continue;
|
||||
}
|
||||
if (chr == '=') {
|
||||
@@ -71,11 +71,11 @@ public final class Base64 {
|
||||
int bits = 0;
|
||||
// holds the value of the input quantum
|
||||
int quantum = 0;
|
||||
for (int i=0; i<len; i++) {
|
||||
for (int i = 0; i < len; i++) {
|
||||
chr = in[i];
|
||||
// skip the neutral characters
|
||||
if ((chr == '\n') || (chr == '\r') ||
|
||||
(chr == ' ') || (chr == '\t')) {
|
||||
if ((chr == '\n') || (chr == '\r')
|
||||
|| (chr == ' ') || (chr == '\t')) {
|
||||
continue;
|
||||
}
|
||||
if ((chr >= 'A') && (chr <= 'Z')) {
|
||||
@@ -102,7 +102,7 @@ public final class Base64 {
|
||||
}
|
||||
// append the value to the quantum
|
||||
quantum = (quantum << 6) | (byte) bits;
|
||||
if (inIndex%4 == 3) {
|
||||
if (inIndex % 4 == 3) {
|
||||
// 4 characters were read, so make the output:
|
||||
out[outIndex++] = (byte) (quantum >> 16);
|
||||
out[outIndex++] = (byte) (quantum >> 8);
|
||||
@@ -112,7 +112,7 @@ public final class Base64 {
|
||||
}
|
||||
if (pad > 0) {
|
||||
// adjust the quantum value according to the padding
|
||||
quantum = quantum << (6*pad);
|
||||
quantum = quantum << (6 * pad);
|
||||
// make output
|
||||
out[outIndex++] = (byte) (quantum >> 16);
|
||||
if (pad == 1) {
|
||||
@@ -125,7 +125,7 @@ public final class Base64 {
|
||||
return result;
|
||||
}
|
||||
|
||||
private static final byte[] map = new byte[]
|
||||
private static final byte[] MAP = new byte[]
|
||||
{'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',
|
||||
@@ -137,22 +137,22 @@ public final class Base64 {
|
||||
byte[] out = new byte[length];
|
||||
int index = 0, end = in.length - in.length % 3;
|
||||
for (int i = 0; i < end; i += 3) {
|
||||
out[index++] = map[(in[i] & 0xff) >> 2];
|
||||
out[index++] = map[((in[i] & 0x03) << 4) | ((in[i+1] & 0xff) >> 4)];
|
||||
out[index++] = map[((in[i+1] & 0x0f) << 2) | ((in[i+2] & 0xff) >> 6)];
|
||||
out[index++] = map[(in[i+2] & 0x3f)];
|
||||
out[index++] = MAP[(in[i] & 0xff) >> 2];
|
||||
out[index++] = MAP[((in[i] & 0x03) << 4) | ((in[i + 1] & 0xff) >> 4)];
|
||||
out[index++] = MAP[((in[i + 1] & 0x0f) << 2) | ((in[i + 2] & 0xff) >> 6)];
|
||||
out[index++] = MAP[(in[i + 2] & 0x3f)];
|
||||
}
|
||||
switch (in.length % 3) {
|
||||
case 1:
|
||||
out[index++] = map[(in[end] & 0xff) >> 2];
|
||||
out[index++] = map[(in[end] & 0x03) << 4];
|
||||
out[index++] = MAP[(in[end] & 0xff) >> 2];
|
||||
out[index++] = MAP[(in[end] & 0x03) << 4];
|
||||
out[index++] = '=';
|
||||
out[index++] = '=';
|
||||
break;
|
||||
case 2:
|
||||
out[index++] = map[(in[end] & 0xff) >> 2];
|
||||
out[index++] = map[((in[end] & 0x03) << 4) | ((in[end+1] & 0xff) >> 4)];
|
||||
out[index++] = map[((in[end+1] & 0x0f) << 2)];
|
||||
out[index++] = MAP[(in[end] & 0xff) >> 2];
|
||||
out[index++] = MAP[((in[end] & 0x03) << 4) | ((in[end + 1] & 0xff) >> 4)];
|
||||
out[index++] = MAP[((in[end + 1] & 0x0f) << 2)];
|
||||
out[index++] = '=';
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -293,7 +293,7 @@ public final class DiskLruCache implements Closeable {
|
||||
*/
|
||||
private void processJournal() throws IOException {
|
||||
deleteIfExists(journalFileTmp);
|
||||
for (Iterator<Entry> i = lruEntries.values().iterator(); i.hasNext(); ) {
|
||||
for (Iterator<Entry> i = lruEntries.values().iterator(); i.hasNext();) {
|
||||
Entry entry = i.next();
|
||||
if (entry.currentEditor == null) {
|
||||
for (int t = 0; t < valueCount; t++) {
|
||||
@@ -499,8 +499,8 @@ public final class DiskLruCache implements Closeable {
|
||||
* and eliminate at least 2000 ops.
|
||||
*/
|
||||
private boolean journalRebuildRequired() {
|
||||
final int REDUNDANT_OP_COMPACT_THRESHOLD = 2000;
|
||||
return redundantOpCount >= REDUNDANT_OP_COMPACT_THRESHOLD
|
||||
final int redundantOpCompactThreshold = 2000;
|
||||
return redundantOpCount >= redundantOpCompactThreshold
|
||||
&& redundantOpCount >= lruEntries.size();
|
||||
}
|
||||
|
||||
@@ -735,7 +735,7 @@ public final class DiskLruCache implements Closeable {
|
||||
completeEdit(this, false);
|
||||
}
|
||||
|
||||
private class FaultHidingOutputStream extends FilterOutputStream {
|
||||
private final class FaultHidingOutputStream extends FilterOutputStream {
|
||||
private FaultHidingOutputStream(OutputStream out) {
|
||||
super(out);
|
||||
}
|
||||
@@ -780,7 +780,7 @@ public final class DiskLruCache implements Closeable {
|
||||
/** Lengths of this entry's files. */
|
||||
private final long[] lengths;
|
||||
|
||||
/** True if this entry has ever been published */
|
||||
/** True if this entry has ever been published. */
|
||||
private boolean readable;
|
||||
|
||||
/** The ongoing edit or null if this entry is not being edited. */
|
||||
|
||||
@@ -29,7 +29,8 @@ import libcore.util.Libcore;
|
||||
public final class Streams {
|
||||
private static AtomicReference<byte[]> skipBuffer = new AtomicReference<byte[]>();
|
||||
|
||||
private Streams() {}
|
||||
private Streams() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements InputStream.read(int) in terms of InputStream.read(byte[], int, int).
|
||||
|
||||
@@ -29,9 +29,9 @@ import java.util.Properties;
|
||||
* Used to implement java.net.URLConnection and android.webkit.MimeTypeMap.
|
||||
*/
|
||||
public final class MimeUtils {
|
||||
private static final Map<String, String> mimeTypeToExtensionMap = new HashMap<String, String>();
|
||||
private static final Map<String, String> MIME_TYPE_TO_EXTENSION_MAP = new HashMap<String, String>();
|
||||
|
||||
private static final Map<String, String> extensionToMimeTypeMap = new HashMap<String, String>();
|
||||
private static final Map<String, String> EXTENSION_TO_MIME_TYPE_MAP = new HashMap<String, String>();
|
||||
|
||||
static {
|
||||
// The following table is based on /etc/mime.types data minus
|
||||
@@ -364,10 +364,10 @@ public final class MimeUtils {
|
||||
// the first extension is considered the most popular and is
|
||||
// added first; we do not want to overwrite it later).
|
||||
//
|
||||
if (!mimeTypeToExtensionMap.containsKey(mimeType)) {
|
||||
mimeTypeToExtensionMap.put(mimeType, extension);
|
||||
if (!MIME_TYPE_TO_EXTENSION_MAP.containsKey(mimeType)) {
|
||||
MIME_TYPE_TO_EXTENSION_MAP.put(mimeType, extension);
|
||||
}
|
||||
extensionToMimeTypeMap.put(extension, mimeType);
|
||||
EXTENSION_TO_MIME_TYPE_MAP.put(extension, mimeType);
|
||||
}
|
||||
|
||||
private static InputStream getContentTypesPropertiesStream() {
|
||||
@@ -437,7 +437,7 @@ public final class MimeUtils {
|
||||
if (mimeType == null || mimeType.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return mimeTypeToExtensionMap.containsKey(mimeType);
|
||||
return MIME_TYPE_TO_EXTENSION_MAP.containsKey(mimeType);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -449,7 +449,7 @@ public final class MimeUtils {
|
||||
if (extension == null || extension.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return extensionToMimeTypeMap.get(extension);
|
||||
return EXTENSION_TO_MIME_TYPE_MAP.get(extension);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -461,7 +461,7 @@ public final class MimeUtils {
|
||||
if (extension == null || extension.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
return extensionToMimeTypeMap.containsKey(extension);
|
||||
return EXTENSION_TO_MIME_TYPE_MAP.containsKey(extension);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -475,6 +475,6 @@ public final class MimeUtils {
|
||||
if (mimeType == null || mimeType.isEmpty()) {
|
||||
return null;
|
||||
}
|
||||
return mimeTypeToExtensionMap.get(mimeType);
|
||||
return MIME_TYPE_TO_EXTENSION_MAP.get(mimeType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -29,7 +29,7 @@ abstract class AbstractHttpOutputStream extends OutputStream {
|
||||
protected boolean closed;
|
||||
|
||||
@Override public final void write(int data) throws IOException {
|
||||
write(new byte[] { (byte) data });
|
||||
write(new byte[] {(byte) data});
|
||||
}
|
||||
|
||||
protected final void checkNotClosed() throws IOException {
|
||||
|
||||
@@ -160,4 +160,7 @@ final class HeaderParser {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
private HeaderParser() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -88,4 +88,7 @@ public final class HttpDate {
|
||||
public static String format(Date value) {
|
||||
return STANDARD_DATE_FORMAT.get().format(value);
|
||||
}
|
||||
|
||||
private HttpDate() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -120,7 +120,7 @@ public class HttpEngine {
|
||||
|
||||
final RequestHeaders requestHeaders;
|
||||
|
||||
/** Null until a response is received from the network or the cache */
|
||||
/** Null until a response is received from the network or the cache. */
|
||||
ResponseHeaders responseHeaders;
|
||||
|
||||
/*
|
||||
|
||||
@@ -260,7 +260,7 @@ final class HttpTransport implements Transport {
|
||||
/**
|
||||
* An HTTP body with a fixed length known in advance.
|
||||
*/
|
||||
private static class FixedLengthOutputStream extends AbstractHttpOutputStream {
|
||||
private static final class FixedLengthOutputStream extends AbstractHttpOutputStream {
|
||||
private final OutputStream socketOut;
|
||||
private int bytesRemaining;
|
||||
|
||||
@@ -303,15 +303,15 @@ final class HttpTransport implements Transport {
|
||||
* buffered until {@code maxChunkLength} bytes are ready, at which point the
|
||||
* chunk is written and the buffer is cleared.
|
||||
*/
|
||||
private static class ChunkedOutputStream extends AbstractHttpOutputStream {
|
||||
private static final byte[] CRLF = { '\r', '\n' };
|
||||
private static final class ChunkedOutputStream extends AbstractHttpOutputStream {
|
||||
private static final byte[] CRLF = {'\r', '\n'};
|
||||
private static final byte[] HEX_DIGITS = {
|
||||
'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f'
|
||||
};
|
||||
private static final byte[] FINAL_CHUNK = new byte[] { '0', '\r', '\n', '\r', '\n' };
|
||||
private static final byte[] FINAL_CHUNK = new byte[] {'0', '\r', '\n', '\r', '\n'};
|
||||
|
||||
/** Scratch space for up to 8 hex digits, and then a constant CRLF */
|
||||
private final byte[] hex = { 0, 0, 0, 0, 0, 0, 0, 0, '\r', '\n' };
|
||||
/** Scratch space for up to 8 hex digits, and then a constant CRLF. */
|
||||
private final byte[] hex = {0, 0, 0, 0, 0, 0, 0, 0, '\r', '\n'};
|
||||
|
||||
private final OutputStream socketOut;
|
||||
private final int maxChunkLength;
|
||||
@@ -554,7 +554,7 @@ final class HttpTransport implements Transport {
|
||||
/**
|
||||
* An HTTP payload terminated by the end of the socket stream.
|
||||
*/
|
||||
private static class UnknownLengthHttpInputStream extends AbstractHttpInputStream {
|
||||
private static final class UnknownLengthHttpInputStream extends AbstractHttpInputStream {
|
||||
private boolean inputExhausted;
|
||||
|
||||
private UnknownLengthHttpInputStream(InputStream is, CacheRequest cacheRequest,
|
||||
|
||||
@@ -24,7 +24,6 @@ import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.Authenticator;
|
||||
import java.net.HttpRetryException;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.InetAddress;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.PasswordAuthentication;
|
||||
@@ -463,12 +462,12 @@ public class HttpURLConnectionImpl extends OkHttpConnection {
|
||||
return defaultPort;
|
||||
}
|
||||
|
||||
/** @see HttpURLConnection#setFixedLengthStreamingMode(int) */
|
||||
/** @see java.net.HttpURLConnection#setFixedLengthStreamingMode(int) */
|
||||
final int getFixedContentLength() {
|
||||
return fixedContentLength;
|
||||
}
|
||||
|
||||
/** @see HttpURLConnection#setChunkedStreamingMode(int) */
|
||||
/** @see java.net.HttpURLConnection#setChunkedStreamingMode(int) */
|
||||
final int getChunkLength() {
|
||||
return chunkLength;
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ import javax.net.ssl.SSLSocketFactory;
|
||||
|
||||
public final class HttpsURLConnectionImpl extends OkHttpsConnection {
|
||||
|
||||
/** HttpUrlConnectionDelegate allows reuse of HttpURLConnectionImpl */
|
||||
/** HttpUrlConnectionDelegate allows reuse of HttpURLConnectionImpl. */
|
||||
private final HttpUrlConnectionDelegate delegate;
|
||||
|
||||
public HttpsURLConnectionImpl(URL url, int port) {
|
||||
@@ -397,7 +397,7 @@ public final class HttpsURLConnectionImpl extends OkHttpsConnection {
|
||||
}
|
||||
}
|
||||
|
||||
private static class HttpsEngine extends HttpEngine {
|
||||
private static final class HttpsEngine extends HttpEngine {
|
||||
|
||||
/**
|
||||
* Local stash of HttpsEngine.connection.sslSocket for answering
|
||||
|
||||
@@ -68,7 +68,8 @@ public final class RawHeaders {
|
||||
private int responseCode = -1;
|
||||
private String responseMessage;
|
||||
|
||||
public RawHeaders() {}
|
||||
public RawHeaders() {
|
||||
}
|
||||
|
||||
public RawHeaders(RawHeaders copyFrom) {
|
||||
namesAndValues.addAll(copyFrom.namesAndValues);
|
||||
@@ -112,9 +113,9 @@ public final class RawHeaders {
|
||||
String version = null;
|
||||
for (int i = 0; i < namesAndValues.size(); i += 2) {
|
||||
String name = namesAndValues.get(i);
|
||||
if (name.equals("status")) {
|
||||
if ("status".equals(name)) {
|
||||
status = namesAndValues.get(i + 1);
|
||||
} else if (name.equals("version")) {
|
||||
} else if ("version".equals(name)) {
|
||||
version = namesAndValues.get(i + 1);
|
||||
}
|
||||
}
|
||||
@@ -374,7 +375,7 @@ public final class RawHeaders {
|
||||
for (int i = 0; i < nameValueBlock.size(); i += 2) {
|
||||
String name = nameValueBlock.get(i);
|
||||
String values = nameValueBlock.get(i + 1);
|
||||
for (int start = 0; start < values.length(); ) {
|
||||
for (int start = 0; start < values.length();) {
|
||||
int end = values.indexOf(start, '\0');
|
||||
if (end == -1) {
|
||||
end = values.length();
|
||||
|
||||
@@ -67,15 +67,15 @@ public final class RequestHeaders {
|
||||
|
||||
HeaderParser.CacheControlHandler handler = new HeaderParser.CacheControlHandler() {
|
||||
@Override public void handle(String directive, String parameter) {
|
||||
if (directive.equalsIgnoreCase("no-cache")) {
|
||||
if ("no-cache".equalsIgnoreCase(directive)) {
|
||||
noCache = true;
|
||||
} else if (directive.equalsIgnoreCase("max-age")) {
|
||||
} else if ("max-age".equalsIgnoreCase(directive)) {
|
||||
maxAgeSeconds = HeaderParser.parseSeconds(parameter);
|
||||
} else if (directive.equalsIgnoreCase("max-stale")) {
|
||||
} else if ("max-stale".equalsIgnoreCase(directive)) {
|
||||
maxStaleSeconds = HeaderParser.parseSeconds(parameter);
|
||||
} else if (directive.equalsIgnoreCase("min-fresh")) {
|
||||
} else if ("min-fresh".equalsIgnoreCase(directive)) {
|
||||
minFreshSeconds = HeaderParser.parseSeconds(parameter);
|
||||
} else if (directive.equalsIgnoreCase("only-if-cached")) {
|
||||
} else if ("only-if-cached".equalsIgnoreCase(directive)) {
|
||||
onlyIfCached = true;
|
||||
}
|
||||
}
|
||||
@@ -87,7 +87,7 @@ public final class RequestHeaders {
|
||||
if ("Cache-Control".equalsIgnoreCase(fieldName)) {
|
||||
HeaderParser.parseCacheControl(value, handler);
|
||||
} else if ("Pragma".equalsIgnoreCase(fieldName)) {
|
||||
if (value.equalsIgnoreCase("no-cache")) {
|
||||
if ("no-cache".equalsIgnoreCase(value)) {
|
||||
noCache = true;
|
||||
}
|
||||
} else if ("If-None-Match".equalsIgnoreCase(fieldName)) {
|
||||
|
||||
@@ -116,17 +116,17 @@ public final class ResponseHeaders {
|
||||
|
||||
HeaderParser.CacheControlHandler handler = new HeaderParser.CacheControlHandler() {
|
||||
@Override public void handle(String directive, String parameter) {
|
||||
if (directive.equalsIgnoreCase("no-cache")) {
|
||||
if ("no-cache".equalsIgnoreCase(directive)) {
|
||||
noCache = true;
|
||||
} else if (directive.equalsIgnoreCase("no-store")) {
|
||||
} else if ("no-store".equalsIgnoreCase(directive)) {
|
||||
noStore = true;
|
||||
} else if (directive.equalsIgnoreCase("max-age")) {
|
||||
} else if ("max-age".equalsIgnoreCase(directive)) {
|
||||
maxAgeSeconds = HeaderParser.parseSeconds(parameter);
|
||||
} else if (directive.equalsIgnoreCase("s-maxage")) {
|
||||
} else if ("s-maxage".equalsIgnoreCase(directive)) {
|
||||
sMaxAgeSeconds = HeaderParser.parseSeconds(parameter);
|
||||
} else if (directive.equalsIgnoreCase("public")) {
|
||||
} else if ("public".equalsIgnoreCase(directive)) {
|
||||
isPublic = true;
|
||||
} else if (directive.equalsIgnoreCase("must-revalidate")) {
|
||||
} else if ("must-revalidate".equalsIgnoreCase(directive)) {
|
||||
mustRevalidate = true;
|
||||
}
|
||||
}
|
||||
@@ -146,7 +146,7 @@ public final class ResponseHeaders {
|
||||
} else if ("ETag".equalsIgnoreCase(fieldName)) {
|
||||
etag = value;
|
||||
} else if ("Pragma".equalsIgnoreCase(fieldName)) {
|
||||
if (value.equalsIgnoreCase("no-cache")) {
|
||||
if ("no-cache".equalsIgnoreCase(value)) {
|
||||
noCache = true;
|
||||
}
|
||||
} else if ("Age".equalsIgnoreCase(fieldName)) {
|
||||
@@ -468,7 +468,7 @@ public final class ResponseHeaders {
|
||||
for (int i = 0; i < headers.length(); i++) {
|
||||
String fieldName = headers.getFieldName(i);
|
||||
String value = headers.getValue(i);
|
||||
if (fieldName.equals("Warning") && value.startsWith("1")) {
|
||||
if ("Warning".equals(fieldName) && value.startsWith("1")) {
|
||||
continue; // drop 100-level freshness warnings
|
||||
}
|
||||
if (!isEndToEnd(fieldName) || network.headers.get(fieldName) == null) {
|
||||
@@ -491,13 +491,13 @@ public final class ResponseHeaders {
|
||||
* defined by RFC 2616, 13.5.1.
|
||||
*/
|
||||
private static boolean isEndToEnd(String fieldName) {
|
||||
return !fieldName.equalsIgnoreCase("Connection")
|
||||
&& !fieldName.equalsIgnoreCase("Keep-Alive")
|
||||
&& !fieldName.equalsIgnoreCase("Proxy-Authenticate")
|
||||
&& !fieldName.equalsIgnoreCase("Proxy-Authorization")
|
||||
&& !fieldName.equalsIgnoreCase("TE")
|
||||
&& !fieldName.equalsIgnoreCase("Trailers")
|
||||
&& !fieldName.equalsIgnoreCase("Transfer-Encoding")
|
||||
&& !fieldName.equalsIgnoreCase("Upgrade");
|
||||
return !"Connection".equalsIgnoreCase(fieldName)
|
||||
&& !"Keep-Alive".equalsIgnoreCase(fieldName)
|
||||
&& !"Proxy-Authenticate".equalsIgnoreCase(fieldName)
|
||||
&& !"Proxy-Authorization".equalsIgnoreCase(fieldName)
|
||||
&& !"TE".equalsIgnoreCase(fieldName)
|
||||
&& !"Trailers".equalsIgnoreCase(fieldName)
|
||||
&& !"Transfer-Encoding".equalsIgnoreCase(fieldName)
|
||||
&& !"Upgrade".equalsIgnoreCase(fieldName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ public final class SpdyConnection implements Closeable {
|
||||
static final int TYPE_HEADERS = 0x08;
|
||||
static final int VERSION = 2;
|
||||
|
||||
/** Guarded by this */
|
||||
/** Guarded by this. */
|
||||
private int nextStreamId;
|
||||
private final SpdyReader spdyReader;
|
||||
private final SpdyWriter spdyWriter;
|
||||
@@ -273,10 +273,11 @@ public final class SpdyConnection implements Closeable {
|
||||
case SpdyConnection.TYPE_GOAWAY:
|
||||
case SpdyConnection.TYPE_HEADERS:
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
// TODO: throw IOException here?
|
||||
return false;
|
||||
default:
|
||||
// TODO: throw IOException here?
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ public final class SpdyServer implements IncomingStreamHandler {
|
||||
String path = null;
|
||||
for (int i = 0; i < requestHeaders.size(); i += 2) {
|
||||
String s = requestHeaders.get(i);
|
||||
if (s.equals("url")) {
|
||||
if ("url".equals(s)) {
|
||||
path = requestHeaders.get(i + 1);
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -26,4 +26,7 @@ final class Threads {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private Threads() {
|
||||
}
|
||||
}
|
||||
|
||||
@@ -93,7 +93,8 @@ public class BasicLruCache<K, V> {
|
||||
* Called for entries that have reached the tail of the least recently used
|
||||
* queue and are be removed. The default implementation does nothing.
|
||||
*/
|
||||
protected void entryEvicted(K key, V value) {}
|
||||
protected void entryEvicted(K key, V value) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Called after a cache miss to compute a value for the corresponding key.
|
||||
|
||||
@@ -27,7 +27,7 @@ import java.nio.charset.Charset;
|
||||
*
|
||||
* @hide internal use only
|
||||
*/
|
||||
public class Charsets {
|
||||
public final class Charsets {
|
||||
/**
|
||||
* A cheap and type-safe constant for the ISO-8859-1 Charset.
|
||||
*/
|
||||
|
||||
@@ -17,14 +17,14 @@
|
||||
package libcore.util;
|
||||
|
||||
import java.lang.ref.Reference;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
|
||||
public final class CollectionUtils {
|
||||
private CollectionUtils() {}
|
||||
private CollectionUtils() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an iterator over the values referenced by the elements of {@code
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
package libcore.util;
|
||||
|
||||
public final class EmptyArray {
|
||||
private EmptyArray() {}
|
||||
private EmptyArray() {
|
||||
}
|
||||
|
||||
public static final boolean[] BOOLEAN = new boolean[0];
|
||||
public static final byte[] BYTE = new byte[0];
|
||||
|
||||
@@ -18,11 +18,14 @@ import org.eclipse.jetty.npn.NextProtoNego;
|
||||
* APIs for interacting with Android's core library. This mostly emulates the
|
||||
* Android core library for interoperability with other runtimes.
|
||||
*/
|
||||
public class Libcore {
|
||||
|
||||
public final class Libcore {
|
||||
|
||||
private Libcore() {
|
||||
}
|
||||
|
||||
public static void makeTlsTolerant(SSLSocket socket, String socketHost, boolean tlsTolerant) {
|
||||
if (!tlsTolerant) {
|
||||
socket.setEnabledProtocols(new String [] { "SSLv3" });
|
||||
socket.setEnabledProtocols(new String[] {"SSLv3"});
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -31,7 +34,7 @@ public class Libcore {
|
||||
"org.apache.harmony.xnet.provider.jsse.OpenSSLSocketImpl");
|
||||
if (openSslSocketClass.isInstance(socket)) {
|
||||
openSslSocketClass.getMethod("setEnabledCompressionMethods", String[].class)
|
||||
.invoke(socket, new Object[] { new String[]{"ZLIB"}});
|
||||
.invoke(socket, new Object[] {new String[] {"ZLIB"}});
|
||||
openSslSocketClass.getMethod("setUseSessionTickets", boolean.class)
|
||||
.invoke(socket, true);
|
||||
openSslSocketClass.getMethod("setHostname", String.class)
|
||||
@@ -47,7 +50,7 @@ public class Libcore {
|
||||
throw new AssertionError(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static byte[] getNpnSelectedProtocol(SSLSocket socket) {
|
||||
// First try Android's APIs.
|
||||
try {
|
||||
@@ -93,7 +96,7 @@ public class Libcore {
|
||||
|
||||
// Next try OpenJDK.
|
||||
List<String> strings = new ArrayList<String>();
|
||||
for (int i = 0; i < npnProtocols.length; ) {
|
||||
for (int i = 0; i < npnProtocols.length;) {
|
||||
int length = npnProtocols[i++];
|
||||
strings.add(new String(npnProtocols, i, length, Charsets.US_ASCII));
|
||||
i += length;
|
||||
@@ -139,7 +142,7 @@ public class Libcore {
|
||||
// okhttp-changed: was System.logw()
|
||||
System.out.println(warning);
|
||||
}
|
||||
|
||||
|
||||
public static int getEffectivePort(URI uri) {
|
||||
return getEffectivePort(uri.getScheme(), uri.getPort());
|
||||
}
|
||||
@@ -161,19 +164,19 @@ public class Libcore {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void checkOffsetAndCount(int arrayLength, int offset, int count) {
|
||||
if ((offset | count) < 0 || offset > arrayLength || arrayLength - offset < count) {
|
||||
throw new ArrayIndexOutOfBoundsException();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static void tagSocket(Socket socket) {
|
||||
}
|
||||
|
||||
|
||||
public static void untagSocket(Socket socket) throws SocketException {
|
||||
}
|
||||
|
||||
|
||||
public static URI toUriLenient(URL url) throws URISyntaxException {
|
||||
return url.toURI(); // this isn't as good as the built-in toUriLenient
|
||||
}
|
||||
|
||||
@@ -17,7 +17,8 @@
|
||||
package libcore.util;
|
||||
|
||||
public final class Objects {
|
||||
private Objects() {}
|
||||
private Objects() {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if two possibly-null objects are equal.
|
||||
|
||||
@@ -53,7 +53,8 @@ package libcore.util;
|
||||
* }</pre>
|
||||
*/
|
||||
public final class SneakyThrow {
|
||||
private SneakyThrow() {}
|
||||
private SneakyThrow() {
|
||||
}
|
||||
|
||||
public static void sneakyThrow(Throwable t) {
|
||||
SneakyThrow.<Error>sneakyThrow2(t);
|
||||
|
||||
Reference in New Issue
Block a user