cordova-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From agri...@apache.org
Subject [27/50] [abbrv] android commit: CB-6630 Delete bundled (and outdated) copy of OkHttp
Date Wed, 28 Jan 2015 14:59:18 GMT
http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/http/ResponseHeaders.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/http/ResponseHeaders.java b/framework/src/com/squareup/okhttp/internal/http/ResponseHeaders.java
deleted file mode 100755
index 69e8656..0000000
--- a/framework/src/com/squareup/okhttp/internal/http/ResponseHeaders.java
+++ /dev/null
@@ -1,512 +0,0 @@
-/*
- * Copyright (C) 2011 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 com.squareup.okhttp.internal.http;
-
-import com.squareup.okhttp.ResponseSource;
-import com.squareup.okhttp.internal.Platform;
-import java.io.IOException;
-import java.net.HttpURLConnection;
-import java.net.URI;
-import java.util.Collections;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import java.util.concurrent.TimeUnit;
-
-import static com.squareup.okhttp.internal.Util.equal;
-
-/** Parsed HTTP response headers. */
-public final class ResponseHeaders {
-
-  /** HTTP header name for the local time when the request was sent. */
-  private static final String SENT_MILLIS = Platform.get().getPrefix() + "-Sent-Millis";
-
-  /** HTTP header name for the local time when the response was received. */
-  private static final String RECEIVED_MILLIS = Platform.get().getPrefix() + "-Received-Millis";
-
-  /** HTTP synthetic header with the response source. */
-  static final String RESPONSE_SOURCE = Platform.get().getPrefix() + "-Response-Source";
-
-  /** HTTP synthetic header with the selected transport (spdy/3, http/1.1, etc). */
-  static final String SELECTED_TRANSPORT = Platform.get().getPrefix() + "-Selected-Transport";
-
-  private final URI uri;
-  private final RawHeaders headers;
-
-  /** The server's time when this response was served, if known. */
-  private Date servedDate;
-
-  /** The last modified date of the response, if known. */
-  private Date lastModified;
-
-  /**
-   * The expiration date of the response, if known. If both this field and the
-   * max age are set, the max age is preferred.
-   */
-  private Date expires;
-
-  /**
-   * Extension header set by HttpURLConnectionImpl specifying the timestamp
-   * when the HTTP request was first initiated.
-   */
-  private long sentRequestMillis;
-
-  /**
-   * Extension header set by HttpURLConnectionImpl specifying the timestamp
-   * when the HTTP response was first received.
-   */
-  private long receivedResponseMillis;
-
-  /**
-   * In the response, this field's name "no-cache" is misleading. It doesn't
-   * prevent us from caching the response; it only means we have to validate
-   * the response with the origin server before returning it. We can do this
-   * with a conditional get.
-   */
-  private boolean noCache;
-
-  /** If true, this response should not be cached. */
-  private boolean noStore;
-
-  /**
-   * The duration past the response's served date that it can be served
-   * without validation.
-   */
-  private int maxAgeSeconds = -1;
-
-  /**
-   * The "s-maxage" directive is the max age for shared caches. Not to be
-   * confused with "max-age" for non-shared caches, As in Firefox and Chrome,
-   * this directive is not honored by this cache.
-   */
-  private int sMaxAgeSeconds = -1;
-
-  /**
-   * This request header field's name "only-if-cached" is misleading. It
-   * actually means "do not use the network". It is set by a client who only
-   * wants to make a request if it can be fully satisfied by the cache.
-   * Cached responses that would require validation (ie. conditional gets) are
-   * not permitted if this header is set.
-   */
-  private boolean isPublic;
-  private boolean mustRevalidate;
-  private String etag;
-  private int ageSeconds = -1;
-
-  /** Case-insensitive set of field names. */
-  private Set<String> varyFields = Collections.emptySet();
-
-  private String contentEncoding;
-  private String transferEncoding;
-  private long contentLength = -1;
-  private String connection;
-  private String contentType;
-
-  public ResponseHeaders(URI uri, RawHeaders headers) {
-    this.uri = uri;
-    this.headers = headers;
-
-    HeaderParser.CacheControlHandler handler = new HeaderParser.CacheControlHandler() {
-      @Override public void handle(String directive, String parameter) {
-        if ("no-cache".equalsIgnoreCase(directive)) {
-          noCache = true;
-        } else if ("no-store".equalsIgnoreCase(directive)) {
-          noStore = true;
-        } else if ("max-age".equalsIgnoreCase(directive)) {
-          maxAgeSeconds = HeaderParser.parseSeconds(parameter);
-        } else if ("s-maxage".equalsIgnoreCase(directive)) {
-          sMaxAgeSeconds = HeaderParser.parseSeconds(parameter);
-        } else if ("public".equalsIgnoreCase(directive)) {
-          isPublic = true;
-        } else if ("must-revalidate".equalsIgnoreCase(directive)) {
-          mustRevalidate = true;
-        }
-      }
-    };
-
-    for (int i = 0; i < headers.length(); i++) {
-      String fieldName = headers.getFieldName(i);
-      String value = headers.getValue(i);
-      if ("Cache-Control".equalsIgnoreCase(fieldName)) {
-        HeaderParser.parseCacheControl(value, handler);
-      } else if ("Date".equalsIgnoreCase(fieldName)) {
-        servedDate = HttpDate.parse(value);
-      } else if ("Expires".equalsIgnoreCase(fieldName)) {
-        expires = HttpDate.parse(value);
-      } else if ("Last-Modified".equalsIgnoreCase(fieldName)) {
-        lastModified = HttpDate.parse(value);
-      } else if ("ETag".equalsIgnoreCase(fieldName)) {
-        etag = value;
-      } else if ("Pragma".equalsIgnoreCase(fieldName)) {
-        if ("no-cache".equalsIgnoreCase(value)) {
-          noCache = true;
-        }
-      } else if ("Age".equalsIgnoreCase(fieldName)) {
-        ageSeconds = HeaderParser.parseSeconds(value);
-      } else if ("Vary".equalsIgnoreCase(fieldName)) {
-        // Replace the immutable empty set with something we can mutate.
-        if (varyFields.isEmpty()) {
-          varyFields = new TreeSet<String>(String.CASE_INSENSITIVE_ORDER);
-        }
-        for (String varyField : value.split(",")) {
-          varyFields.add(varyField.trim());
-        }
-      } else if ("Content-Encoding".equalsIgnoreCase(fieldName)) {
-        contentEncoding = value;
-      } else if ("Transfer-Encoding".equalsIgnoreCase(fieldName)) {
-        transferEncoding = value;
-      } else if ("Content-Length".equalsIgnoreCase(fieldName)) {
-        try {
-          contentLength = Long.parseLong(value);
-        } catch (NumberFormatException ignored) {
-        }
-      } else if ("Content-Type".equalsIgnoreCase(fieldName)) {
-        contentType = value;
-      } else if ("Connection".equalsIgnoreCase(fieldName)) {
-        connection = value;
-      } else if (SENT_MILLIS.equalsIgnoreCase(fieldName)) {
-        sentRequestMillis = Long.parseLong(value);
-      } else if (RECEIVED_MILLIS.equalsIgnoreCase(fieldName)) {
-        receivedResponseMillis = Long.parseLong(value);
-      }
-    }
-  }
-
-  public boolean isContentEncodingGzip() {
-    return "gzip".equalsIgnoreCase(contentEncoding);
-  }
-
-  public void stripContentEncoding() {
-    contentEncoding = null;
-    headers.removeAll("Content-Encoding");
-  }
-
-  public void stripContentLength() {
-    contentLength = -1;
-    headers.removeAll("Content-Length");
-  }
-
-  public boolean isChunked() {
-    return "chunked".equalsIgnoreCase(transferEncoding);
-  }
-
-  public boolean hasConnectionClose() {
-    return "close".equalsIgnoreCase(connection);
-  }
-
-  public URI getUri() {
-    return uri;
-  }
-
-  public RawHeaders getHeaders() {
-    return headers;
-  }
-
-  public Date getServedDate() {
-    return servedDate;
-  }
-
-  public Date getLastModified() {
-    return lastModified;
-  }
-
-  public Date getExpires() {
-    return expires;
-  }
-
-  public boolean isNoCache() {
-    return noCache;
-  }
-
-  public boolean isNoStore() {
-    return noStore;
-  }
-
-  public int getMaxAgeSeconds() {
-    return maxAgeSeconds;
-  }
-
-  public int getSMaxAgeSeconds() {
-    return sMaxAgeSeconds;
-  }
-
-  public boolean isPublic() {
-    return isPublic;
-  }
-
-  public boolean isMustRevalidate() {
-    return mustRevalidate;
-  }
-
-  public String getEtag() {
-    return etag;
-  }
-
-  public Set<String> getVaryFields() {
-    return varyFields;
-  }
-
-  public String getContentEncoding() {
-    return contentEncoding;
-  }
-
-  public long getContentLength() {
-    return contentLength;
-  }
-
-  public String getContentType() {
-    return contentType;
-  }
-
-  public String getConnection() {
-    return connection;
-  }
-
-  public void setLocalTimestamps(long sentRequestMillis, long receivedResponseMillis) {
-    this.sentRequestMillis = sentRequestMillis;
-    headers.add(SENT_MILLIS, Long.toString(sentRequestMillis));
-    this.receivedResponseMillis = receivedResponseMillis;
-    headers.add(RECEIVED_MILLIS, Long.toString(receivedResponseMillis));
-  }
-
-  public void setResponseSource(ResponseSource responseSource) {
-    headers.set(RESPONSE_SOURCE, responseSource.toString() + " " + headers.getResponseCode());
-  }
-
-  public void setTransport(String transport) {
-    headers.set(SELECTED_TRANSPORT, transport);
-  }
-
-  /**
-   * Returns the current age of the response, in milliseconds. The calculation
-   * is specified by RFC 2616, 13.2.3 Age Calculations.
-   */
-  private long computeAge(long nowMillis) {
-    long apparentReceivedAge =
-        servedDate != null ? Math.max(0, receivedResponseMillis - servedDate.getTime()) : 0;
-    long receivedAge =
-        ageSeconds != -1 ? Math.max(apparentReceivedAge, TimeUnit.SECONDS.toMillis(ageSeconds))
-            : apparentReceivedAge;
-    long responseDuration = receivedResponseMillis - sentRequestMillis;
-    long residentDuration = nowMillis - receivedResponseMillis;
-    return receivedAge + responseDuration + residentDuration;
-  }
-
-  /**
-   * Returns the number of milliseconds that the response was fresh for,
-   * starting from the served date.
-   */
-  private long computeFreshnessLifetime() {
-    if (maxAgeSeconds != -1) {
-      return TimeUnit.SECONDS.toMillis(maxAgeSeconds);
-    } else if (expires != null) {
-      long servedMillis = servedDate != null ? servedDate.getTime() : receivedResponseMillis;
-      long delta = expires.getTime() - servedMillis;
-      return delta > 0 ? delta : 0;
-    } else if (lastModified != null && uri.getRawQuery() == null) {
-      // As recommended by the HTTP RFC and implemented in Firefox, the
-      // max age of a document should be defaulted to 10% of the
-      // document's age at the time it was served. Default expiration
-      // dates aren't used for URIs containing a query.
-      long servedMillis = servedDate != null ? servedDate.getTime() : sentRequestMillis;
-      long delta = servedMillis - lastModified.getTime();
-      return delta > 0 ? (delta / 10) : 0;
-    }
-    return 0;
-  }
-
-  /**
-   * Returns true if computeFreshnessLifetime used a heuristic. If we used a
-   * heuristic to serve a cached response older than 24 hours, we are required
-   * to attach a warning.
-   */
-  private boolean isFreshnessLifetimeHeuristic() {
-    return maxAgeSeconds == -1 && expires == null;
-  }
-
-  /**
-   * Returns true if this response can be stored to later serve another
-   * request.
-   */
-  public boolean isCacheable(RequestHeaders request) {
-    // Always go to network for uncacheable response codes (RFC 2616, 13.4),
-    // This implementation doesn't support caching partial content.
-    int responseCode = headers.getResponseCode();
-    if (responseCode != HttpURLConnection.HTTP_OK
-        && responseCode != HttpURLConnection.HTTP_NOT_AUTHORITATIVE
-        && responseCode != HttpURLConnection.HTTP_MULT_CHOICE
-        && responseCode != HttpURLConnection.HTTP_MOVED_PERM
-        && responseCode != HttpURLConnection.HTTP_GONE) {
-      return false;
-    }
-
-    // Responses to authorized requests aren't cacheable unless they include
-    // a 'public', 'must-revalidate' or 's-maxage' directive.
-    if (request.hasAuthorization() && !isPublic && !mustRevalidate && sMaxAgeSeconds == -1) {
-      return false;
-    }
-
-    if (noStore) {
-      return false;
-    }
-
-    return true;
-  }
-
-  /**
-   * Returns true if a Vary header contains an asterisk. Such responses cannot
-   * be cached.
-   */
-  public boolean hasVaryAll() {
-    return varyFields.contains("*");
-  }
-
-  /**
-   * Returns true if none of the Vary headers on this response have changed
-   * between {@code cachedRequest} and {@code newRequest}.
-   */
-  public boolean varyMatches(Map<String, List<String>> cachedRequest,
-      Map<String, List<String>> newRequest) {
-    for (String field : varyFields) {
-      if (!equal(cachedRequest.get(field), newRequest.get(field))) {
-        return false;
-      }
-    }
-    return true;
-  }
-
-  /** Returns the source to satisfy {@code request} given this cached response. */
-  public ResponseSource chooseResponseSource(long nowMillis, RequestHeaders request) {
-    // If this response shouldn't have been stored, it should never be used
-    // as a response source. This check should be redundant as long as the
-    // persistence store is well-behaved and the rules are constant.
-    if (!isCacheable(request)) {
-      return ResponseSource.NETWORK;
-    }
-
-    if (request.isNoCache() || request.hasConditions()) {
-      return ResponseSource.NETWORK;
-    }
-
-    long ageMillis = computeAge(nowMillis);
-    long freshMillis = computeFreshnessLifetime();
-
-    if (request.getMaxAgeSeconds() != -1) {
-      freshMillis = Math.min(freshMillis, TimeUnit.SECONDS.toMillis(request.getMaxAgeSeconds()));
-    }
-
-    long minFreshMillis = 0;
-    if (request.getMinFreshSeconds() != -1) {
-      minFreshMillis = TimeUnit.SECONDS.toMillis(request.getMinFreshSeconds());
-    }
-
-    long maxStaleMillis = 0;
-    if (!mustRevalidate && request.getMaxStaleSeconds() != -1) {
-      maxStaleMillis = TimeUnit.SECONDS.toMillis(request.getMaxStaleSeconds());
-    }
-
-    if (!noCache && ageMillis + minFreshMillis < freshMillis + maxStaleMillis) {
-      if (ageMillis + minFreshMillis >= freshMillis) {
-        headers.add("Warning", "110 HttpURLConnection \"Response is stale\"");
-      }
-      long oneDayMillis = 24 * 60 * 60 * 1000L;
-      if (ageMillis > oneDayMillis && isFreshnessLifetimeHeuristic()) {
-        headers.add("Warning", "113 HttpURLConnection \"Heuristic expiration\"");
-      }
-      return ResponseSource.CACHE;
-    }
-
-    if (lastModified != null) {
-      request.setIfModifiedSince(lastModified);
-    } else if (servedDate != null) {
-      request.setIfModifiedSince(servedDate);
-    }
-
-    if (etag != null) {
-      request.setIfNoneMatch(etag);
-    }
-
-    return request.hasConditions() ? ResponseSource.CONDITIONAL_CACHE : ResponseSource.NETWORK;
-  }
-
-  /**
-   * Returns true if this cached response should be used; false if the
-   * network response should be used.
-   */
-  public boolean validate(ResponseHeaders networkResponse) {
-    if (networkResponse.headers.getResponseCode() == HttpURLConnection.HTTP_NOT_MODIFIED) {
-      return true;
-    }
-
-    // The HTTP spec says that if the network's response is older than our
-    // cached response, we may return the cache's response. Like Chrome (but
-    // unlike Firefox), this client prefers to return the newer response.
-    if (lastModified != null
-        && networkResponse.lastModified != null
-        && networkResponse.lastModified.getTime() < lastModified.getTime()) {
-      return true;
-    }
-
-    return false;
-  }
-
-  /**
-   * Combines this cached header with a network header as defined by RFC 2616,
-   * 13.5.3.
-   */
-  public ResponseHeaders combine(ResponseHeaders network) throws IOException {
-    RawHeaders result = new RawHeaders();
-    result.setStatusLine(headers.getStatusLine());
-
-    for (int i = 0; i < headers.length(); i++) {
-      String fieldName = headers.getFieldName(i);
-      String value = headers.getValue(i);
-      if ("Warning".equals(fieldName) && value.startsWith("1")) {
-        continue; // drop 100-level freshness warnings
-      }
-      if (!isEndToEnd(fieldName) || network.headers.get(fieldName) == null) {
-        result.add(fieldName, value);
-      }
-    }
-
-    for (int i = 0; i < network.headers.length(); i++) {
-      String fieldName = network.headers.getFieldName(i);
-      if (isEndToEnd(fieldName)) {
-        result.add(fieldName, network.headers.getValue(i));
-      }
-    }
-
-    return new ResponseHeaders(uri, result);
-  }
-
-  /**
-   * Returns true if {@code fieldName} is an end-to-end HTTP header, as
-   * defined by RFC 2616, 13.5.1.
-   */
-  private static boolean isEndToEnd(String fieldName) {
-    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);
-  }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/http/RetryableOutputStream.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/http/RetryableOutputStream.java b/framework/src/com/squareup/okhttp/internal/http/RetryableOutputStream.java
deleted file mode 100755
index 5eb6b76..0000000
--- a/framework/src/com/squareup/okhttp/internal/http/RetryableOutputStream.java
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * 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 com.squareup.okhttp.internal.http;
-
-import com.squareup.okhttp.internal.AbstractOutputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.net.ProtocolException;
-
-import static com.squareup.okhttp.internal.Util.checkOffsetAndCount;
-
-/**
- * An HTTP request body that's completely buffered in memory. This allows
- * the post body to be transparently re-sent if the HTTP request must be
- * sent multiple times.
- */
-final class RetryableOutputStream extends AbstractOutputStream {
-  private final int limit;
-  private final ByteArrayOutputStream content;
-
-  public RetryableOutputStream(int limit) {
-    this.limit = limit;
-    this.content = new ByteArrayOutputStream(limit);
-  }
-
-  public RetryableOutputStream() {
-    this.limit = -1;
-    this.content = new ByteArrayOutputStream();
-  }
-
-  @Override public synchronized void close() throws IOException {
-    if (closed) {
-      return;
-    }
-    closed = true;
-    if (content.size() < limit) {
-      throw new ProtocolException(
-          "content-length promised " + limit + " bytes, but received " + content.size());
-    }
-  }
-
-  @Override public synchronized void write(byte[] buffer, int offset, int count)
-      throws IOException {
-    checkNotClosed();
-    checkOffsetAndCount(buffer.length, offset, count);
-    if (limit != -1 && content.size() > limit - count) {
-      throw new ProtocolException("exceeded content-length limit of " + limit + " bytes");
-    }
-    content.write(buffer, offset, count);
-  }
-
-  public synchronized int contentLength() throws IOException {
-    close();
-    return content.size();
-  }
-
-  public void writeToSocket(OutputStream socketOut) throws IOException {
-    content.writeTo(socketOut);
-  }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/http/RouteSelector.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/http/RouteSelector.java b/framework/src/com/squareup/okhttp/internal/http/RouteSelector.java
deleted file mode 100755
index 1055e4f..0000000
--- a/framework/src/com/squareup/okhttp/internal/http/RouteSelector.java
+++ /dev/null
@@ -1,269 +0,0 @@
-/*
- * Copyright (C) 2012 Square, Inc.
- *
- * 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 com.squareup.okhttp.internal.http;
-
-import com.squareup.okhttp.Address;
-import com.squareup.okhttp.Connection;
-import com.squareup.okhttp.ConnectionPool;
-import com.squareup.okhttp.Route;
-import com.squareup.okhttp.RouteDatabase;
-import com.squareup.okhttp.internal.Dns;
-import java.io.IOException;
-import java.net.InetAddress;
-import java.net.InetSocketAddress;
-import java.net.Proxy;
-import java.net.ProxySelector;
-import java.net.SocketAddress;
-import java.net.URI;
-import java.net.UnknownHostException;
-import java.util.Iterator;
-import java.util.LinkedList;
-import java.util.List;
-import java.util.NoSuchElementException;
-
-import static com.squareup.okhttp.internal.Util.getEffectivePort;
-
-/**
- * Selects routes to connect to an origin server. Each connection requires a
- * choice of proxy server, IP address, and TLS mode. Connections may also be
- * recycled.
- */
-public final class RouteSelector {
-  /** Uses {@link com.squareup.okhttp.internal.Platform#enableTlsExtensions}. */
-  private static final int TLS_MODE_MODERN = 1;
-  /** Uses {@link com.squareup.okhttp.internal.Platform#supportTlsIntolerantServer}. */
-  private static final int TLS_MODE_COMPATIBLE = 0;
-  /** No TLS mode. */
-  private static final int TLS_MODE_NULL = -1;
-
-  private final Address address;
-  private final URI uri;
-  private final ProxySelector proxySelector;
-  private final ConnectionPool pool;
-  private final Dns dns;
-  private final RouteDatabase routeDatabase;
-
-  /* The most recently attempted route. */
-  private Proxy lastProxy;
-  private InetSocketAddress lastInetSocketAddress;
-
-  /* State for negotiating the next proxy to use. */
-  private boolean hasNextProxy;
-  private Proxy userSpecifiedProxy;
-  private Iterator<Proxy> proxySelectorProxies;
-
-  /* State for negotiating the next InetSocketAddress to use. */
-  private InetAddress[] socketAddresses;
-  private int nextSocketAddressIndex;
-  private int socketPort;
-
-  /* State for negotiating the next TLS configuration */
-  private int nextTlsMode = TLS_MODE_NULL;
-
-  /* State for negotiating failed routes */
-  private final List<Route> postponedRoutes;
-
-  public RouteSelector(Address address, URI uri, ProxySelector proxySelector, ConnectionPool pool,
-      Dns dns, RouteDatabase routeDatabase) {
-    this.address = address;
-    this.uri = uri;
-    this.proxySelector = proxySelector;
-    this.pool = pool;
-    this.dns = dns;
-    this.routeDatabase = routeDatabase;
-    this.postponedRoutes = new LinkedList<Route>();
-
-    resetNextProxy(uri, address.getProxy());
-  }
-
-  /**
-   * Returns true if there's another route to attempt. Every address has at
-   * least one route.
-   */
-  public boolean hasNext() {
-    return hasNextTlsMode() || hasNextInetSocketAddress() || hasNextProxy() || hasNextPostponed();
-  }
-
-  /**
-   * Returns the next route address to attempt.
-   *
-   * @throws NoSuchElementException if there are no more routes to attempt.
-   */
-  public Connection next(String method) throws IOException {
-    // Always prefer pooled connections over new connections.
-    for (Connection pooled; (pooled = pool.get(address)) != null; ) {
-      if (method.equals("GET") || pooled.isReadable()) return pooled;
-      pooled.close();
-    }
-
-    // Compute the next route to attempt.
-    if (!hasNextTlsMode()) {
-      if (!hasNextInetSocketAddress()) {
-        if (!hasNextProxy()) {
-          if (!hasNextPostponed()) {
-            throw new NoSuchElementException();
-          }
-          return new Connection(nextPostponed());
-        }
-        lastProxy = nextProxy();
-        resetNextInetSocketAddress(lastProxy);
-      }
-      lastInetSocketAddress = nextInetSocketAddress();
-      resetNextTlsMode();
-    }
-
-    boolean modernTls = nextTlsMode() == TLS_MODE_MODERN;
-    Route route = new Route(address, lastProxy, lastInetSocketAddress, modernTls);
-    if (routeDatabase.shouldPostpone(route)) {
-      postponedRoutes.add(route);
-      // We will only recurse in order to skip previously failed routes. They will be
-      // tried last.
-      return next(method);
-    }
-
-    return new Connection(route);
-  }
-
-  /**
-   * Clients should invoke this method when they encounter a connectivity
-   * failure on a connection returned by this route selector.
-   */
-  public void connectFailed(Connection connection, IOException failure) {
-    Route failedRoute = connection.getRoute();
-    if (failedRoute.getProxy().type() != Proxy.Type.DIRECT && proxySelector != null) {
-      // Tell the proxy selector when we fail to connect on a fresh connection.
-      proxySelector.connectFailed(uri, failedRoute.getProxy().address(), failure);
-    }
-
-    routeDatabase.failed(failedRoute, failure);
-  }
-
-  /** Resets {@link #nextProxy} to the first option. */
-  private void resetNextProxy(URI uri, Proxy proxy) {
-    this.hasNextProxy = true; // This includes NO_PROXY!
-    if (proxy != null) {
-      this.userSpecifiedProxy = proxy;
-    } else {
-      List<Proxy> proxyList = proxySelector.select(uri);
-      if (proxyList != null) {
-        this.proxySelectorProxies = proxyList.iterator();
-      }
-    }
-  }
-
-  /** Returns true if there's another proxy to try. */
-  private boolean hasNextProxy() {
-    return hasNextProxy;
-  }
-
-  /** Returns the next proxy to try. May be PROXY.NO_PROXY but never null. */
-  private Proxy nextProxy() {
-    // If the user specifies a proxy, try that and only that.
-    if (userSpecifiedProxy != null) {
-      hasNextProxy = false;
-      return userSpecifiedProxy;
-    }
-
-    // Try each of the ProxySelector choices until one connection succeeds. If none succeed
-    // then we'll try a direct connection below.
-    if (proxySelectorProxies != null) {
-      while (proxySelectorProxies.hasNext()) {
-        Proxy candidate = proxySelectorProxies.next();
-        if (candidate.type() != Proxy.Type.DIRECT) {
-          return candidate;
-        }
-      }
-    }
-
-    // Finally try a direct connection.
-    hasNextProxy = false;
-    return Proxy.NO_PROXY;
-  }
-
-  /** Resets {@link #nextInetSocketAddress} to the first option. */
-  private void resetNextInetSocketAddress(Proxy proxy) throws UnknownHostException {
-    socketAddresses = null; // Clear the addresses. Necessary if getAllByName() below throws!
-
-    String socketHost;
-    if (proxy.type() == Proxy.Type.DIRECT) {
-      socketHost = uri.getHost();
-      socketPort = getEffectivePort(uri);
-    } else {
-      SocketAddress proxyAddress = proxy.address();
-      if (!(proxyAddress instanceof InetSocketAddress)) {
-        throw new IllegalArgumentException(
-            "Proxy.address() is not an " + "InetSocketAddress: " + proxyAddress.getClass());
-      }
-      InetSocketAddress proxySocketAddress = (InetSocketAddress) proxyAddress;
-      socketHost = proxySocketAddress.getHostName();
-      socketPort = proxySocketAddress.getPort();
-    }
-
-    // Try each address for best behavior in mixed IPv4/IPv6 environments.
-    socketAddresses = dns.getAllByName(socketHost);
-    nextSocketAddressIndex = 0;
-  }
-
-  /** Returns true if there's another socket address to try. */
-  private boolean hasNextInetSocketAddress() {
-    return socketAddresses != null;
-  }
-
-  /** Returns the next socket address to try. */
-  private InetSocketAddress nextInetSocketAddress() throws UnknownHostException {
-    InetSocketAddress result =
-        new InetSocketAddress(socketAddresses[nextSocketAddressIndex++], socketPort);
-    if (nextSocketAddressIndex == socketAddresses.length) {
-      socketAddresses = null; // So that hasNextInetSocketAddress() returns false.
-      nextSocketAddressIndex = 0;
-    }
-
-    return result;
-  }
-
-  /** Resets {@link #nextTlsMode} to the first option. */
-  private void resetNextTlsMode() {
-    nextTlsMode = (address.getSslSocketFactory() != null) ? TLS_MODE_MODERN : TLS_MODE_COMPATIBLE;
-  }
-
-  /** Returns true if there's another TLS mode to try. */
-  private boolean hasNextTlsMode() {
-    return nextTlsMode != TLS_MODE_NULL;
-  }
-
-  /** Returns the next TLS mode to try. */
-  private int nextTlsMode() {
-    if (nextTlsMode == TLS_MODE_MODERN) {
-      nextTlsMode = TLS_MODE_COMPATIBLE;
-      return TLS_MODE_MODERN;
-    } else if (nextTlsMode == TLS_MODE_COMPATIBLE) {
-      nextTlsMode = TLS_MODE_NULL;  // So that hasNextTlsMode() returns false.
-      return TLS_MODE_COMPATIBLE;
-    } else {
-      throw new AssertionError();
-    }
-  }
-
-  /** Returns true if there is another postponed route to try. */
-  private boolean hasNextPostponed() {
-    return !postponedRoutes.isEmpty();
-  }
-
-  /** Returns the next postponed route to try. */
-  private Route nextPostponed() {
-    return postponedRoutes.remove(0);
-  }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/http/SpdyTransport.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/http/SpdyTransport.java b/framework/src/com/squareup/okhttp/internal/http/SpdyTransport.java
deleted file mode 100755
index 471539a..0000000
--- a/framework/src/com/squareup/okhttp/internal/http/SpdyTransport.java
+++ /dev/null
@@ -1,103 +0,0 @@
-/*
- * Copyright (C) 2012 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 com.squareup.okhttp.internal.http;
-
-import com.squareup.okhttp.internal.spdy.ErrorCode;
-import com.squareup.okhttp.internal.spdy.SpdyConnection;
-import com.squareup.okhttp.internal.spdy.SpdyStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.CacheRequest;
-import java.net.URL;
-import java.util.List;
-
-public final class SpdyTransport implements Transport {
-  private final HttpEngine httpEngine;
-  private final SpdyConnection spdyConnection;
-  private SpdyStream stream;
-
-  public SpdyTransport(HttpEngine httpEngine, SpdyConnection spdyConnection) {
-    this.httpEngine = httpEngine;
-    this.spdyConnection = spdyConnection;
-  }
-
-  @Override public OutputStream createRequestBody() throws IOException {
-    long fixedContentLength = httpEngine.policy.getFixedContentLength();
-    if (fixedContentLength != -1) {
-      httpEngine.requestHeaders.setContentLength(fixedContentLength);
-    }
-    // TODO: if we aren't streaming up to the server, we should buffer the whole request
-    writeRequestHeaders();
-    return stream.getOutputStream();
-  }
-
-  @Override public void writeRequestHeaders() throws IOException {
-    if (stream != null) {
-      return;
-    }
-    httpEngine.writingRequestHeaders();
-    RawHeaders requestHeaders = httpEngine.requestHeaders.getHeaders();
-    String version = httpEngine.connection.getHttpMinorVersion() == 1 ? "HTTP/1.1" : "HTTP/1.0";
-    URL url = httpEngine.policy.getURL();
-    requestHeaders.addSpdyRequestHeaders(httpEngine.method, HttpEngine.requestPath(url), version,
-        HttpEngine.getOriginAddress(url), httpEngine.uri.getScheme());
-    boolean hasRequestBody = httpEngine.hasRequestBody();
-    boolean hasResponseBody = true;
-    stream = spdyConnection.newStream(requestHeaders.toNameValueBlock(), hasRequestBody,
-        hasResponseBody);
-    stream.setReadTimeout(httpEngine.client.getReadTimeout());
-  }
-
-  @Override public void writeRequestBody(RetryableOutputStream requestBody) throws IOException {
-    throw new UnsupportedOperationException();
-  }
-
-  @Override public void flushRequest() throws IOException {
-    stream.getOutputStream().close();
-  }
-
-  @Override public ResponseHeaders readResponseHeaders() throws IOException {
-    List<String> nameValueBlock = stream.getResponseHeaders();
-    RawHeaders rawHeaders = RawHeaders.fromNameValueBlock(nameValueBlock);
-    httpEngine.receiveHeaders(rawHeaders);
-
-    ResponseHeaders headers = new ResponseHeaders(httpEngine.uri, rawHeaders);
-    headers.setTransport("spdy/3");
-    return headers;
-  }
-
-  @Override public InputStream getTransferStream(CacheRequest cacheRequest) throws IOException {
-    return new UnknownLengthHttpInputStream(stream.getInputStream(), cacheRequest, httpEngine);
-  }
-
-  @Override public boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut,
-      InputStream responseBodyIn) {
-    if (streamCanceled) {
-      if (stream != null) {
-        stream.closeLater(ErrorCode.CANCEL);
-        return true;
-      } else {
-        // If stream is null, it either means that writeRequestHeaders wasn't called
-        // or that SpdyConnection#newStream threw an IOException. In both cases there's
-        // nothing to do here and this stream can't be reused.
-        return false;
-      }
-    }
-    return true;
-  }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/http/Transport.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/http/Transport.java b/framework/src/com/squareup/okhttp/internal/http/Transport.java
deleted file mode 100755
index d408bfe..0000000
--- a/framework/src/com/squareup/okhttp/internal/http/Transport.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*
- * Copyright (C) 2012 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 com.squareup.okhttp.internal.http;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.CacheRequest;
-
-interface Transport {
-  /**
-   * Returns an output stream where the request body can be written. The
-   * returned stream will of one of two types:
-   * <ul>
-   * <li><strong>Direct.</strong> Bytes are written to the socket and
-   * forgotten. This is most efficient, particularly for large request
-   * bodies. The returned stream may be buffered; the caller must call
-   * {@link #flushRequest} before reading the response.</li>
-   * <li><strong>Buffered.</strong> Bytes are written to an in memory
-   * buffer, and must be explicitly flushed with a call to {@link
-   * #writeRequestBody}. This allows HTTP authorization (401, 407)
-   * responses to be retransmitted transparently.</li>
-   * </ul>
-   */
-  // TODO: don't bother retransmitting the request body? It's quite a corner
-  // case and there's uncertainty whether Firefox or Chrome do this
-  OutputStream createRequestBody() throws IOException;
-
-  /** This should update the HTTP engine's sentRequestMillis field. */
-  void writeRequestHeaders() throws IOException;
-
-  /**
-   * Sends the request body returned by {@link #createRequestBody} to the
-   * remote peer.
-   */
-  void writeRequestBody(RetryableOutputStream requestBody) throws IOException;
-
-  /** Flush the request body to the underlying socket. */
-  void flushRequest() throws IOException;
-
-  /** Read response headers and update the cookie manager. */
-  ResponseHeaders readResponseHeaders() throws IOException;
-
-  // TODO: make this the content stream?
-  InputStream getTransferStream(CacheRequest cacheRequest) throws IOException;
-
-  /** Returns true if the underlying connection can be recycled. */
-  boolean makeReusable(boolean streamCanceled, OutputStream requestBodyOut,
-      InputStream responseBodyIn);
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/http/UnknownLengthHttpInputStream.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/http/UnknownLengthHttpInputStream.java b/framework/src/com/squareup/okhttp/internal/http/UnknownLengthHttpInputStream.java
deleted file mode 100755
index ca6bb59..0000000
--- a/framework/src/com/squareup/okhttp/internal/http/UnknownLengthHttpInputStream.java
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- * Copyright (C) 2012 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 com.squareup.okhttp.internal.http;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.CacheRequest;
-
-import static com.squareup.okhttp.internal.Util.checkOffsetAndCount;
-
-/** An HTTP message body terminated by the end of the underlying stream. */
-final class UnknownLengthHttpInputStream extends AbstractHttpInputStream {
-  private boolean inputExhausted;
-
-  UnknownLengthHttpInputStream(InputStream in, CacheRequest cacheRequest, HttpEngine httpEngine)
-      throws IOException {
-    super(in, httpEngine, cacheRequest);
-  }
-
-  @Override public int read(byte[] buffer, int offset, int count) throws IOException {
-    checkOffsetAndCount(buffer.length, offset, count);
-    checkNotClosed();
-    if (in == null || inputExhausted) {
-      return -1;
-    }
-    int read = in.read(buffer, offset, count);
-    if (read == -1) {
-      inputExhausted = true;
-      endOfInput();
-      return -1;
-    }
-    cacheWrite(buffer, offset, read);
-    return read;
-  }
-
-  @Override public int available() throws IOException {
-    checkNotClosed();
-    return in == null ? 0 : in.available();
-  }
-
-  @Override public void close() throws IOException {
-    if (closed) {
-      return;
-    }
-    closed = true;
-    if (!inputExhausted) {
-      unexpectedEndOfInput();
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/spdy/ErrorCode.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/spdy/ErrorCode.java b/framework/src/com/squareup/okhttp/internal/spdy/ErrorCode.java
deleted file mode 100755
index 9394b69..0000000
--- a/framework/src/com/squareup/okhttp/internal/spdy/ErrorCode.java
+++ /dev/null
@@ -1,83 +0,0 @@
-/*
- * Copyright (C) 2012 Square, Inc.
- *
- * 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 com.squareup.okhttp.internal.spdy;
-
-public enum ErrorCode {
-  /** Not an error! For SPDY stream resets, prefer null over NO_ERROR. */
-  NO_ERROR(0, -1, 0),
-
-  PROTOCOL_ERROR(1, 1, 1),
-
-  /** A subtype of PROTOCOL_ERROR used by SPDY. */
-  INVALID_STREAM(1, 2, -1),
-
-  /** A subtype of PROTOCOL_ERROR used by SPDY. */
-  UNSUPPORTED_VERSION(1, 4, -1),
-
-  /** A subtype of PROTOCOL_ERROR used by SPDY. */
-  STREAM_IN_USE(1, 8, -1),
-
-  /** A subtype of PROTOCOL_ERROR used by SPDY. */
-  STREAM_ALREADY_CLOSED(1, 9, -1),
-
-  INTERNAL_ERROR(2, 6, 2),
-
-  FLOW_CONTROL_ERROR(3, 7, -1),
-
-  STREAM_CLOSED(5, -1, -1),
-
-  FRAME_TOO_LARGE(6, 11, -1),
-
-  REFUSED_STREAM(7, 3, -1),
-
-  CANCEL(8, 5, -1),
-
-  COMPRESSION_ERROR(9, -1, -1),
-
-  INVALID_CREDENTIALS(-1, 10, -1);
-
-  public final int httpCode;
-  public final int spdyRstCode;
-  public final int spdyGoAwayCode;
-
-  private ErrorCode(int httpCode, int spdyRstCode, int spdyGoAwayCode) {
-    this.httpCode = httpCode;
-    this.spdyRstCode = spdyRstCode;
-    this.spdyGoAwayCode = spdyGoAwayCode;
-  }
-
-  public static ErrorCode fromSpdy3Rst(int code) {
-    for (ErrorCode errorCode : ErrorCode.values()) {
-      if (errorCode.spdyRstCode == code) return errorCode;
-    }
-    return null;
-  }
-
-  public static ErrorCode fromHttp2(int code) {
-    for (ErrorCode errorCode : ErrorCode.values()) {
-      if (errorCode.httpCode == code) return errorCode;
-    }
-    return null;
-  }
-
-  public static ErrorCode fromSpdyGoAway(int code) {
-    for (ErrorCode errorCode : ErrorCode.values()) {
-      if (errorCode.spdyGoAwayCode == code) return errorCode;
-    }
-    return null;
-  }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/spdy/FrameReader.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/spdy/FrameReader.java b/framework/src/com/squareup/okhttp/internal/spdy/FrameReader.java
deleted file mode 100755
index 1371262..0000000
--- a/framework/src/com/squareup/okhttp/internal/spdy/FrameReader.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * Copyright (C) 2011 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 com.squareup.okhttp.internal.spdy;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.List;
-
-/** Reads transport frames for SPDY/3 or HTTP/2.0. */
-public interface FrameReader extends Closeable {
-  void readConnectionHeader() throws IOException;
-  boolean nextFrame(Handler handler) throws IOException;
-
-  public interface Handler {
-    void data(boolean inFinished, int streamId, InputStream in, int length) throws IOException;
-    /**
-     * Create or update incoming headers, creating the corresponding streams
-     * if necessary. Frames that trigger this are SPDY SYN_STREAM, HEADERS, and
-     * SYN_REPLY, and HTTP/2.0 HEADERS and PUSH_PROMISE.
-     *
-     * @param inFinished true if the sender will not send further frames.
-     * @param outFinished true if the receiver should not send further frames.
-     * @param streamId the stream owning these headers.
-     * @param associatedStreamId the stream that triggered the sender to create
-     *     this stream.
-     * @param priority or -1 for no priority. For SPDY, priorities range from 0
-     *     (highest) thru 7 (lowest). For HTTP/2.0, priorities range from 0
-     *     (highest) thru 2**31-1 (lowest).
-     */
-    void headers(boolean outFinished, boolean inFinished, int streamId, int associatedStreamId,
-        int priority, List<String> nameValueBlock, HeadersMode headersMode);
-    void rstStream(int streamId, ErrorCode errorCode);
-    void settings(boolean clearPrevious, Settings settings);
-    void noop();
-    void ping(boolean reply, int payload1, int payload2);
-    void goAway(int lastGoodStreamId, ErrorCode errorCode);
-    void windowUpdate(int streamId, int deltaWindowSize, boolean endFlowControl);
-    void priority(int streamId, int priority);
-  }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/spdy/FrameWriter.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/spdy/FrameWriter.java b/framework/src/com/squareup/okhttp/internal/spdy/FrameWriter.java
deleted file mode 100755
index 354f43d..0000000
--- a/framework/src/com/squareup/okhttp/internal/spdy/FrameWriter.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * Copyright (C) 2011 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 com.squareup.okhttp.internal.spdy;
-
-import java.io.Closeable;
-import java.io.IOException;
-import java.util.List;
-
-/** Writes transport frames for SPDY/3 or HTTP/2.0. */
-public interface FrameWriter extends Closeable {
-  /** HTTP/2.0 only. */
-  void connectionHeader() throws IOException;
-
-  /** SPDY/3 only. */
-  void flush() throws IOException;
-  void synStream(boolean outFinished, boolean inFinished, int streamId, int associatedStreamId,
-      int priority, int slot, List<String> nameValueBlock) throws IOException;
-  void synReply(boolean outFinished, int streamId, List<String> nameValueBlock) throws IOException;
-  void headers(int streamId, List<String> nameValueBlock) throws IOException;
-  void rstStream(int streamId, ErrorCode errorCode) throws IOException;
-  void data(boolean outFinished, int streamId, byte[] data) throws IOException;
-  void data(boolean outFinished, int streamId, byte[] data, int offset, int byteCount)
-      throws IOException;
-  void settings(Settings settings) throws IOException;
-  void noop() throws IOException;
-  void ping(boolean reply, int payload1, int payload2) throws IOException;
-  void goAway(int lastGoodStreamId, ErrorCode errorCode) throws IOException;
-  void windowUpdate(int streamId, int deltaWindowSize) throws IOException;
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/spdy/HeadersMode.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/spdy/HeadersMode.java b/framework/src/com/squareup/okhttp/internal/spdy/HeadersMode.java
deleted file mode 100755
index e16e176..0000000
--- a/framework/src/com/squareup/okhttp/internal/spdy/HeadersMode.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
- * Copyright (C) 2013 Square, Inc.
- *
- * 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 com.squareup.okhttp.internal.spdy;
-
-enum HeadersMode {
-  SPDY_SYN_STREAM,
-  SPDY_REPLY,
-  SPDY_HEADERS,
-  HTTP_20_HEADERS;
-
-  /** Returns true if it is an error these headers to create a new stream. */
-  public boolean failIfStreamAbsent() {
-    return this == SPDY_REPLY || this == SPDY_HEADERS;
-  }
-
-  /** Returns true if it is an error these headers to update an existing stream. */
-  public boolean failIfStreamPresent() {
-    return this == SPDY_SYN_STREAM;
-  }
-
-  /**
-   * Returns true if it is an error these headers to be the initial headers of a
-   * response.
-   */
-  public boolean failIfHeadersAbsent() {
-    return this == SPDY_HEADERS;
-  }
-
-  /**
-   * Returns true if it is an error these headers to be update existing headers
-   * of a response.
-   */
-  public boolean failIfHeadersPresent() {
-    return this == SPDY_REPLY;
-  }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/spdy/Hpack.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/spdy/Hpack.java b/framework/src/com/squareup/okhttp/internal/spdy/Hpack.java
deleted file mode 100755
index 9eaeebd..0000000
--- a/framework/src/com/squareup/okhttp/internal/spdy/Hpack.java
+++ /dev/null
@@ -1,387 +0,0 @@
-/*
- * Copyright (C) 2012 Square, Inc.
- *
- * 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 com.squareup.okhttp.internal.spdy;
-
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.BitSet;
-import java.util.List;
-
-/**
- * Read and write HPACK v03.
- * http://tools.ietf.org/html/draft-ietf-httpbis-header-compression-03
- */
-final class Hpack {
-
-  static class HeaderEntry {
-    private final String name;
-    private final String value;
-
-    HeaderEntry(String name, String value) {
-      this.name = name;
-      this.value = value;
-    }
-
-    // TODO: This needs to be the length in UTF-8 bytes, not the length in chars.
-    int length() {
-      return 32 + name.length() + value.length();
-    }
-  }
-
-  static final int PREFIX_5_BITS = 0x1f;
-  static final int PREFIX_6_BITS = 0x3f;
-  static final int PREFIX_7_BITS = 0x7f;
-  static final int PREFIX_8_BITS = 0xff;
-
-  static final List<HeaderEntry> INITIAL_CLIENT_TO_SERVER_HEADER_TABLE = Arrays.asList(
-      new HeaderEntry(":scheme", "http"),
-      new HeaderEntry(":scheme", "https"),
-      new HeaderEntry(":host", ""),
-      new HeaderEntry(":path", "/"),
-      new HeaderEntry(":method", "GET"),
-      new HeaderEntry("accept", ""),
-      new HeaderEntry("accept-charset", ""),
-      new HeaderEntry("accept-encoding", ""),
-      new HeaderEntry("accept-language", ""),
-      new HeaderEntry("cookie", ""),
-      new HeaderEntry("if-modified-since", ""),
-      new HeaderEntry("user-agent", ""),
-      new HeaderEntry("referer", ""),
-      new HeaderEntry("authorization", ""),
-      new HeaderEntry("allow", ""),
-      new HeaderEntry("cache-control", ""),
-      new HeaderEntry("connection", ""),
-      new HeaderEntry("content-length", ""),
-      new HeaderEntry("content-type", ""),
-      new HeaderEntry("date", ""),
-      new HeaderEntry("expect", ""),
-      new HeaderEntry("from", ""),
-      new HeaderEntry("if-match", ""),
-      new HeaderEntry("if-none-match", ""),
-      new HeaderEntry("if-range", ""),
-      new HeaderEntry("if-unmodified-since", ""),
-      new HeaderEntry("max-forwards", ""),
-      new HeaderEntry("proxy-authorization", ""),
-      new HeaderEntry("range", ""),
-      new HeaderEntry("via", "")
-  );
-
-  static final List<HeaderEntry> INITIAL_SERVER_TO_CLIENT_HEADER_TABLE = Arrays.asList(
-      new HeaderEntry(":status", "200"),
-      new HeaderEntry("age", ""),
-      new HeaderEntry("cache-control", ""),
-      new HeaderEntry("content-length", ""),
-      new HeaderEntry("content-type", ""),
-      new HeaderEntry("date", ""),
-      new HeaderEntry("etag", ""),
-      new HeaderEntry("expires", ""),
-      new HeaderEntry("last-modified", ""),
-      new HeaderEntry("server", ""),
-      new HeaderEntry("set-cookie", ""),
-      new HeaderEntry("vary", ""),
-      new HeaderEntry("via", ""),
-      new HeaderEntry("access-control-allow-origin", ""),
-      new HeaderEntry("accept-ranges", ""),
-      new HeaderEntry("allow", ""),
-      new HeaderEntry("connection", ""),
-      new HeaderEntry("content-disposition", ""),
-      new HeaderEntry("content-encoding", ""),
-      new HeaderEntry("content-language", ""),
-      new HeaderEntry("content-location", ""),
-      new HeaderEntry("content-range", ""),
-      new HeaderEntry("link", ""),
-      new HeaderEntry("location", ""),
-      new HeaderEntry("proxy-authenticate", ""),
-      new HeaderEntry("refresh", ""),
-      new HeaderEntry("retry-after", ""),
-      new HeaderEntry("strict-transport-security", ""),
-      new HeaderEntry("transfer-encoding", ""),
-      new HeaderEntry("www-authenticate", "")
-  );
-
-  // Update these when initial tables change to sum of each entry length.
-  static final int INITIAL_CLIENT_TO_SERVER_HEADER_TABLE_LENGTH = 1262;
-  static final int INITIAL_SERVER_TO_CLIENT_HEADER_TABLE_LENGTH = 1304;
-
-  private Hpack() {
-  }
-
-  static class Reader {
-    private final long maxBufferSize = 4096; // TODO: needs to come from settings.
-    private final DataInputStream in;
-
-    private final BitSet referenceSet = new BitSet();
-    private final List<HeaderEntry> headerTable;
-    private final List<String> emittedHeaders = new ArrayList<String>();
-    private long bufferSize = 0;
-    private long bytesLeft = 0;
-
-    Reader(DataInputStream in, boolean client) {
-      this.in = in;
-      if (client) {  // we are reading from the server
-        this.headerTable = new ArrayList<HeaderEntry>(INITIAL_SERVER_TO_CLIENT_HEADER_TABLE);
-        this.bufferSize = INITIAL_SERVER_TO_CLIENT_HEADER_TABLE_LENGTH;
-      } else {
-        this.headerTable = new ArrayList<HeaderEntry>(INITIAL_CLIENT_TO_SERVER_HEADER_TABLE);
-        this.bufferSize = INITIAL_CLIENT_TO_SERVER_HEADER_TABLE_LENGTH;
-      }
-    }
-
-    /**
-     * Read {@code byteCount} bytes of headers from the source stream into the
-     * set of emitted headers.
-     */
-    public void readHeaders(int byteCount) throws IOException {
-      bytesLeft += byteCount;
-      // TODO: limit to 'byteCount' bytes?
-
-      while (bytesLeft > 0) {
-        int b = readByte();
-
-        if ((b & 0x80) != 0) {
-          int index = readInt(b, PREFIX_7_BITS);
-          readIndexedHeader(index);
-        } else if (b == 0x60) {
-          readLiteralHeaderWithoutIndexingNewName();
-        } else if ((b & 0xe0) == 0x60) {
-          int index = readInt(b, PREFIX_5_BITS);
-          readLiteralHeaderWithoutIndexingIndexedName(index - 1);
-        } else if (b == 0x40) {
-          readLiteralHeaderWithIncrementalIndexingNewName();
-        } else if ((b & 0xe0) == 0x40) {
-          int index = readInt(b, PREFIX_5_BITS);
-          readLiteralHeaderWithIncrementalIndexingIndexedName(index - 1);
-        } else if (b == 0) {
-          readLiteralHeaderWithSubstitutionIndexingNewName();
-        } else if ((b & 0xc0) == 0) {
-          int index = readInt(b, PREFIX_6_BITS);
-          readLiteralHeaderWithSubstitutionIndexingIndexedName(index - 1);
-        } else {
-          throw new AssertionError();
-        }
-      }
-    }
-
-    public void emitReferenceSet() {
-      for (int i = referenceSet.nextSetBit(0); i != -1; i = referenceSet.nextSetBit(i + 1)) {
-        emittedHeaders.add(getName(i));
-        emittedHeaders.add(getValue(i));
-      }
-    }
-
-    /**
-     * Returns all headers emitted since they were last cleared, then clears the
-     * emitted headers.
-     */
-    public List<String> getAndReset() {
-      List<String> result = new ArrayList<String>(emittedHeaders);
-      emittedHeaders.clear();
-      return result;
-    }
-
-    private void readIndexedHeader(int index) {
-      if (referenceSet.get(index)) {
-        referenceSet.clear(index);
-      } else {
-        referenceSet.set(index);
-      }
-    }
-
-    private void readLiteralHeaderWithoutIndexingIndexedName(int index)
-        throws IOException {
-      String name = getName(index);
-      String value = readString();
-      emittedHeaders.add(name);
-      emittedHeaders.add(value);
-    }
-
-    private void readLiteralHeaderWithoutIndexingNewName()
-        throws IOException {
-      String name = readString();
-      String value = readString();
-      emittedHeaders.add(name);
-      emittedHeaders.add(value);
-    }
-
-    private void readLiteralHeaderWithIncrementalIndexingIndexedName(int nameIndex)
-        throws IOException {
-      String name = getName(nameIndex);
-      String value = readString();
-      int index = headerTable.size(); // append to tail
-      insertIntoHeaderTable(index, new HeaderEntry(name, value));
-    }
-
-    private void readLiteralHeaderWithIncrementalIndexingNewName() throws IOException {
-      String name = readString();
-      String value = readString();
-      int index = headerTable.size(); // append to tail
-      insertIntoHeaderTable(index, new HeaderEntry(name, value));
-    }
-
-    private void readLiteralHeaderWithSubstitutionIndexingIndexedName(int nameIndex)
-        throws IOException {
-      int index = readInt(readByte(), PREFIX_8_BITS);
-      String name = getName(nameIndex);
-      String value = readString();
-      insertIntoHeaderTable(index, new HeaderEntry(name, value));
-    }
-
-    private void readLiteralHeaderWithSubstitutionIndexingNewName() throws IOException {
-      String name = readString();
-      int index = readInt(readByte(), PREFIX_8_BITS);
-      String value = readString();
-      insertIntoHeaderTable(index, new HeaderEntry(name, value));
-    }
-
-    private String getName(int index) {
-      return headerTable.get(index).name;
-    }
-
-    private String getValue(int index) {
-      return headerTable.get(index).value;
-    }
-
-    private void insertIntoHeaderTable(int index, HeaderEntry entry) {
-      int delta = entry.length();
-      if (index != headerTable.size()) {
-        delta -= headerTable.get(index).length();
-      }
-
-      // if the new or replacement header is too big, drop all entries.
-      if (delta > maxBufferSize) {
-        headerTable.clear();
-        bufferSize = 0;
-        // emit the large header to the callback.
-        emittedHeaders.add(entry.name);
-        emittedHeaders.add(entry.value);
-        return;
-      }
-
-      // Prune headers to the required length.
-      while (bufferSize + delta > maxBufferSize) {
-        remove(0);
-        index--;
-      }
-
-      if (index < 0) { // we pruned it, so insert at beginning
-        index = 0;
-        headerTable.add(index, entry);
-      } else if (index == headerTable.size()) { // append to the end
-        headerTable.add(index, entry);
-      } else { // replace value at same position
-        headerTable.set(index, entry);
-      }
-
-      bufferSize += delta;
-      referenceSet.set(index);
-    }
-
-    private void remove(int index) {
-      bufferSize -= headerTable.remove(index).length();
-    }
-
-    private int readByte() throws IOException {
-      bytesLeft--;
-      return in.readByte() & 0xff;
-    }
-
-    int readInt(int firstByte, int prefixMask) throws IOException {
-      int prefix = firstByte & prefixMask;
-      if (prefix < prefixMask) {
-        return prefix; // This was a single byte value.
-      }
-
-      // This is a multibyte value. Read 7 bits at a time.
-      int result = prefixMask;
-      int shift = 0;
-      while (true) {
-        int b = readByte();
-        if ((b & 0x80) != 0) { // Equivalent to (b >= 128) since b is in [0..255].
-          result += (b & 0x7f) << shift;
-          shift += 7;
-        } else {
-          result += b << shift; // Last byte.
-          break;
-        }
-      }
-      return result;
-    }
-
-    /**
-     * Reads a UTF-8 encoded string. Since ASCII is a subset of UTF-8, this method
-     * may be used to read strings that are known to be ASCII-only.
-     */
-    public String readString() throws IOException {
-      int firstByte = readByte();
-      int length = readInt(firstByte, PREFIX_8_BITS);
-      byte[] encoded = new byte[length];
-      bytesLeft -= length;
-      in.readFully(encoded);
-      return new String(encoded, "UTF-8");
-    }
-  }
-
-  static class Writer {
-    private final OutputStream out;
-
-    Writer(OutputStream out) {
-      this.out = out;
-    }
-
-    public void writeHeaders(List<String> nameValueBlock) throws IOException {
-      // TODO: implement a compression strategy.
-      for (int i = 0, size = nameValueBlock.size(); i < size; i += 2) {
-        out.write(0x60); // Literal Header without Indexing - New Name.
-        writeString(nameValueBlock.get(i));
-        writeString(nameValueBlock.get(i + 1));
-      }
-    }
-
-    public void writeInt(int value, int prefixMask, int bits) throws IOException {
-      // Write the raw value for a single byte value.
-      if (value < prefixMask) {
-        out.write(bits | value);
-        return;
-      }
-
-      // Write the mask to start a multibyte value.
-      out.write(bits | prefixMask);
-      value -= prefixMask;
-
-      // Write 7 bits at a time 'til we're done.
-      while (value >= 0x80) {
-        int b = value & 0x7f;
-        out.write(b | 0x80);
-        value >>>= 7;
-      }
-      out.write(value);
-    }
-
-    /**
-     * Writes a UTF-8 encoded string. Since ASCII is a subset of UTF-8, this
-     * method can be used to write strings that are known to be ASCII-only.
-     */
-    public void writeString(String headerName) throws IOException {
-      byte[] bytes = headerName.getBytes("UTF-8");
-      writeInt(bytes.length, PREFIX_8_BITS, 0);
-      out.write(bytes);
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/spdy/Http20Draft06.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/spdy/Http20Draft06.java b/framework/src/com/squareup/okhttp/internal/spdy/Http20Draft06.java
deleted file mode 100755
index 3d53f48..0000000
--- a/framework/src/com/squareup/okhttp/internal/spdy/Http20Draft06.java
+++ /dev/null
@@ -1,385 +0,0 @@
-/*
- * Copyright (C) 2013 Square, Inc.
- *
- * 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 com.squareup.okhttp.internal.spdy;
-
-import com.squareup.okhttp.internal.Util;
-import java.io.ByteArrayOutputStream;
-import java.io.DataInputStream;
-import java.io.DataOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.UnsupportedEncodingException;
-import java.util.Arrays;
-import java.util.List;
-
-/**
- * Read and write http/2 v06 frames.
- * http://tools.ietf.org/html/draft-ietf-httpbis-http2-06
- */
-final class Http20Draft06 implements Variant {
-  private static final byte[] CONNECTION_HEADER;
-  static {
-    try {
-      CONNECTION_HEADER = "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n".getBytes("UTF-8");
-    } catch (UnsupportedEncodingException e) {
-      throw new AssertionError();
-    }
-  }
-
-  static final int TYPE_DATA = 0x0;
-  static final int TYPE_HEADERS = 0x1;
-  static final int TYPE_PRIORITY = 0x2;
-  static final int TYPE_RST_STREAM = 0x3;
-  static final int TYPE_SETTINGS = 0x4;
-  static final int TYPE_PUSH_PROMISE = 0x5;
-  static final int TYPE_PING = 0x6;
-  static final int TYPE_GOAWAY = 0x7;
-  static final int TYPE_WINDOW_UPDATE = 0x9;
-  static final int TYPE_CONTINUATION = 0xa;
-
-  static final int FLAG_END_STREAM = 0x1;
-  /** Used for headers, push-promise and continuation. */
-  static final int FLAG_END_HEADERS = 0x4;
-  static final int FLAG_PRIORITY = 0x8;
-  static final int FLAG_PONG = 0x1;
-  static final int FLAG_END_FLOW_CONTROL = 0x1;
-
-  @Override public FrameReader newReader(InputStream in, boolean client) {
-    return new Reader(in, client);
-  }
-
-  @Override public FrameWriter newWriter(OutputStream out, boolean client) {
-    return new Writer(out, client);
-  }
-
-  static final class Reader implements FrameReader {
-    private final DataInputStream in;
-    private final boolean client;
-    private final Hpack.Reader hpackReader;
-
-    Reader(InputStream in, boolean client) {
-      this.in = new DataInputStream(in);
-      this.client = client;
-      this.hpackReader = new Hpack.Reader(this.in, client);
-    }
-
-    @Override public void readConnectionHeader() throws IOException {
-      if (client) return; // Nothing to read; servers don't send connection headers!
-      byte[] connectionHeader = new byte[CONNECTION_HEADER.length];
-      in.readFully(connectionHeader);
-      if (!Arrays.equals(connectionHeader, CONNECTION_HEADER)) {
-        throw ioException("Expected a connection header but was "
-            + Arrays.toString(connectionHeader));
-      }
-    }
-
-    @Override public boolean nextFrame(Handler handler) throws IOException {
-      int w1;
-      try {
-        w1 = in.readInt();
-      } catch (IOException e) {
-        return false; // This might be a normal socket close.
-      }
-      int w2 = in.readInt();
-
-      int length = (w1 & 0xffff0000) >> 16;
-      int type = (w1 & 0xff00) >> 8;
-      int flags = w1 & 0xff;
-      // boolean r = (w2 & 0x80000000) != 0; // Reserved.
-      int streamId = (w2 & 0x7fffffff);
-
-      switch (type) {
-        case TYPE_DATA:
-          readData(handler, flags, length, streamId);
-          return true;
-
-        case TYPE_HEADERS:
-          readHeaders(handler, flags, length, streamId);
-          return true;
-
-        case TYPE_PRIORITY:
-          readPriority(handler, flags, length, streamId);
-          return true;
-
-        case TYPE_RST_STREAM:
-          readRstStream(handler, flags, length, streamId);
-          return true;
-
-        case TYPE_SETTINGS:
-          readSettings(handler, flags, length, streamId);
-          return true;
-
-        case TYPE_PUSH_PROMISE:
-          readPushPromise(handler, flags, length, streamId);
-          return true;
-
-        case TYPE_PING:
-          readPing(handler, flags, length, streamId);
-          return true;
-
-        case TYPE_GOAWAY:
-          readGoAway(handler, flags, length, streamId);
-          return true;
-
-        case TYPE_WINDOW_UPDATE:
-          readWindowUpdate(handler, flags, length, streamId);
-          return true;
-      }
-
-      throw new UnsupportedOperationException("TODO");
-    }
-
-    private void readHeaders(Handler handler, int flags, int length, int streamId)
-        throws IOException {
-      if (streamId == 0) throw ioException("TYPE_HEADERS streamId == 0");
-
-      boolean inFinished = (flags & FLAG_END_STREAM) != 0;
-
-      while (true) {
-        hpackReader.readHeaders(length);
-
-        if ((flags & FLAG_END_HEADERS) != 0) {
-          hpackReader.emitReferenceSet();
-          List<String> namesAndValues = hpackReader.getAndReset();
-          int priority = -1; // TODO: priority
-          handler.headers(false, inFinished, streamId, -1, priority, namesAndValues,
-              HeadersMode.HTTP_20_HEADERS);
-          return;
-        }
-
-        // Read another continuation frame.
-        int w1 = in.readInt();
-        int w2 = in.readInt();
-
-        length = (w1 & 0xffff0000) >> 16;
-        int newType = (w1 & 0xff00) >> 8;
-        flags = w1 & 0xff;
-
-        // TODO: remove in draft 8: CONTINUATION no longer sets END_STREAM
-        inFinished = (flags & FLAG_END_STREAM) != 0;
-
-        // boolean u = (w2 & 0x80000000) != 0; // Unused.
-        int newStreamId = (w2 & 0x7fffffff);
-
-        if (newType != TYPE_CONTINUATION) {
-          throw ioException("TYPE_CONTINUATION didn't have FLAG_END_HEADERS");
-        }
-        if (newStreamId != streamId) throw ioException("TYPE_CONTINUATION streamId changed");
-      }
-    }
-
-    private void readData(Handler handler, int flags, int length, int streamId) throws IOException {
-      boolean inFinished = (flags & FLAG_END_STREAM) != 0;
-      handler.data(inFinished, streamId, in, length);
-    }
-
-    private void readPriority(Handler handler, int flags, int length, int streamId)
-        throws IOException {
-      if (length != 4) throw ioException("TYPE_PRIORITY length: %d != 4", length);
-      if (streamId == 0) throw ioException("TYPE_PRIORITY streamId == 0");
-      int w1 = in.readInt();
-      // boolean r = (w1 & 0x80000000) != 0; // Reserved.
-      int priority = (w1 & 0x7fffffff);
-      handler.priority(streamId, priority);
-    }
-
-    private void readRstStream(Handler handler, int flags, int length, int streamId)
-        throws IOException {
-      if (length != 4) throw ioException("TYPE_RST_STREAM length: %d != 4", length);
-      if (streamId == 0) throw ioException("TYPE_RST_STREAM streamId == 0");
-      int errorCodeInt = in.readInt();
-      ErrorCode errorCode = ErrorCode.fromHttp2(errorCodeInt);
-      if (errorCode == null) {
-        throw ioException("TYPE_RST_STREAM unexpected error code: %d", errorCodeInt);
-      }
-      handler.rstStream(streamId, errorCode);
-    }
-
-    private void readSettings(Handler handler, int flags, int length, int streamId)
-        throws IOException {
-      if (length % 8 != 0) throw ioException("TYPE_SETTINGS length %% 8 != 0: %s", length);
-      if (streamId != 0) throw ioException("TYPE_SETTINGS streamId != 0");
-      Settings settings = new Settings();
-      for (int i = 0; i < length; i += 8) {
-        int w1 = in.readInt();
-        int value = in.readInt();
-        // int r = (w1 & 0xff000000) >>> 24; // Reserved.
-        int id = w1 & 0xffffff;
-        settings.set(id, 0, value);
-      }
-      handler.settings(false, settings);
-    }
-
-    private void readPushPromise(Handler handler, int flags, int length, int streamId) {
-      // TODO:
-    }
-
-    private void readPing(Handler handler, int flags, int length, int streamId) throws IOException {
-      if (length != 8) throw ioException("TYPE_PING length != 8: %s", length);
-      if (streamId != 0) throw ioException("TYPE_PING streamId != 0");
-      int payload1 = in.readInt();
-      int payload2 = in.readInt();
-      boolean reply = (flags & FLAG_PONG) != 0;
-      handler.ping(reply, payload1, payload2);
-    }
-
-    private void readGoAway(Handler handler, int flags, int length, int streamId)
-        throws IOException {
-      if (length < 8) throw ioException("TYPE_GOAWAY length < 8: %s", length);
-      int lastStreamId = in.readInt();
-      int errorCodeInt = in.readInt();
-      int opaqueDataLength = length - 8;
-      ErrorCode errorCode = ErrorCode.fromHttp2(errorCodeInt);
-      if (errorCode == null) {
-        throw ioException("TYPE_RST_STREAM unexpected error code: %d", errorCodeInt);
-      }
-      if (Util.skipByReading(in, opaqueDataLength) != opaqueDataLength) {
-        throw new IOException("TYPE_GOAWAY opaque data was truncated");
-      }
-      handler.goAway(lastStreamId, errorCode);
-    }
-
-    private void readWindowUpdate(Handler handler, int flags, int length, int streamId)
-        throws IOException {
-      int w1 = in.readInt();
-      // boolean r = (w1 & 0x80000000) != 0; // Reserved.
-      int windowSizeIncrement = (w1 & 0x7fffffff);
-      boolean endFlowControl = (flags & FLAG_END_FLOW_CONTROL) != 0;
-      handler.windowUpdate(streamId, windowSizeIncrement, endFlowControl);
-    }
-
-    private static IOException ioException(String message, Object... args) throws IOException {
-      throw new IOException(String.format(message, args));
-    }
-
-    @Override public void close() throws IOException {
-      in.close();
-    }
-  }
-
-  static final class Writer implements FrameWriter {
-    private final DataOutputStream out;
-    private final boolean client;
-    private final ByteArrayOutputStream hpackBuffer;
-    private final Hpack.Writer hpackWriter;
-
-    Writer(OutputStream out, boolean client) {
-      this.out = new DataOutputStream(out);
-      this.client = client;
-      this.hpackBuffer = new ByteArrayOutputStream();
-      this.hpackWriter = new Hpack.Writer(hpackBuffer);
-    }
-
-    @Override public synchronized void flush() throws IOException {
-      out.flush();
-    }
-
-    @Override public synchronized void connectionHeader() throws IOException {
-      if (!client) return; // Nothing to write; servers don't send connection headers!
-      out.write(CONNECTION_HEADER);
-    }
-
-    @Override public synchronized void synStream(boolean outFinished, boolean inFinished,
-        int streamId, int associatedStreamId, int priority, int slot, List<String> nameValueBlock)
-        throws IOException {
-      if (inFinished) throw new UnsupportedOperationException();
-      headers(outFinished, streamId, priority, nameValueBlock);
-    }
-
-    @Override public synchronized void synReply(boolean outFinished, int streamId,
-        List<String> nameValueBlock) throws IOException {
-      headers(outFinished, streamId, -1, nameValueBlock);
-    }
-
-    @Override public synchronized void headers(int streamId, List<String> nameValueBlock)
-        throws IOException {
-      headers(false, streamId, -1, nameValueBlock);
-    }
-
-    private void headers(boolean outFinished, int streamId, int priority,
-        List<String> nameValueBlock) throws IOException {
-      hpackBuffer.reset();
-      hpackWriter.writeHeaders(nameValueBlock);
-      int type = TYPE_HEADERS;
-      // TODO: implement CONTINUATION
-      int length = hpackBuffer.size();
-      int flags = FLAG_END_HEADERS;
-      if (outFinished) flags |= FLAG_END_STREAM;
-      if (priority != -1) flags |= FLAG_PRIORITY;
-      out.writeInt((length & 0xffff) << 16 | (type & 0xff) << 8 | (flags & 0xff));
-      out.writeInt(streamId & 0x7fffffff);
-      if (priority != -1) out.writeInt(priority & 0x7fffffff);
-      hpackBuffer.writeTo(out);
-    }
-
-    @Override public synchronized void rstStream(int streamId, ErrorCode errorCode)
-        throws IOException {
-      throw new UnsupportedOperationException("TODO");
-    }
-
-    @Override public void data(boolean outFinished, int streamId, byte[] data) throws IOException {
-      data(outFinished, streamId, data, 0, data.length);
-    }
-
-    @Override public synchronized void data(boolean outFinished, int streamId, byte[] data,
-        int offset, int byteCount) throws IOException {
-      int type = TYPE_DATA;
-      int flags = 0;
-      if (outFinished) flags |= FLAG_END_STREAM;
-      out.writeInt((byteCount & 0xffff) << 16 | (type & 0xff) << 8 | (flags & 0xff));
-      out.writeInt(streamId & 0x7fffffff);
-      out.write(data, offset, byteCount);
-    }
-
-    @Override public synchronized void settings(Settings settings) throws IOException {
-      int type = TYPE_SETTINGS;
-      int length = settings.size() * 8;
-      int flags = 0;
-      int streamId = 0;
-      out.writeInt((length & 0xffff) << 16 | (type & 0xff) << 8 | (flags & 0xff));
-      out.writeInt(streamId & 0x7fffffff);
-      for (int i = 0; i < Settings.COUNT; i++) {
-        if (!settings.isSet(i)) continue;
-        out.writeInt(i & 0xffffff);
-        out.writeInt(settings.get(i));
-      }
-    }
-
-    @Override public synchronized void noop() throws IOException {
-      throw new UnsupportedOperationException();
-    }
-
-    @Override public synchronized void ping(boolean reply, int payload1, int payload2)
-        throws IOException {
-      // TODO
-    }
-
-    @Override public synchronized void goAway(int lastGoodStreamId, ErrorCode errorCode)
-        throws IOException {
-      // TODO
-    }
-
-    @Override public synchronized void windowUpdate(int streamId, int deltaWindowSize)
-        throws IOException {
-      // TODO
-    }
-
-    @Override public void close() throws IOException {
-      out.close();
-    }
-  }
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/spdy/IncomingStreamHandler.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/spdy/IncomingStreamHandler.java b/framework/src/com/squareup/okhttp/internal/spdy/IncomingStreamHandler.java
deleted file mode 100755
index 44d4ea2..0000000
--- a/framework/src/com/squareup/okhttp/internal/spdy/IncomingStreamHandler.java
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- * Copyright (C) 2011 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 com.squareup.okhttp.internal.spdy;
-
-import java.io.IOException;
-
-/** Listener to be notified when a connected peer creates a new stream. */
-public interface IncomingStreamHandler {
-  IncomingStreamHandler REFUSE_INCOMING_STREAMS = new IncomingStreamHandler() {
-    @Override public void receive(SpdyStream stream) throws IOException {
-      stream.close(ErrorCode.REFUSED_STREAM);
-    }
-  };
-
-  /**
-   * Handle a new stream from this connection's peer. Implementations should
-   * respond by either {@link SpdyStream#reply replying to the stream} or
-   * {@link SpdyStream#close closing it}. This response does not need to be
-   * synchronous.
-   */
-  void receive(SpdyStream stream) throws IOException;
-}

http://git-wip-us.apache.org/repos/asf/cordova-android/blob/c6b171ba/framework/src/com/squareup/okhttp/internal/spdy/NameValueBlockReader.java
----------------------------------------------------------------------
diff --git a/framework/src/com/squareup/okhttp/internal/spdy/NameValueBlockReader.java b/framework/src/com/squareup/okhttp/internal/spdy/NameValueBlockReader.java
deleted file mode 100755
index b731a6d..0000000
--- a/framework/src/com/squareup/okhttp/internal/spdy/NameValueBlockReader.java
+++ /dev/null
@@ -1,139 +0,0 @@
-/*
- * Copyright (C) 2012 Square, Inc.
- *
- * 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 com.squareup.okhttp.internal.spdy;
-
-import com.squareup.okhttp.internal.Util;
-import java.io.Closeable;
-import java.io.DataInputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.zip.DataFormatException;
-import java.util.zip.Inflater;
-import java.util.zip.InflaterInputStream;
-
-/**
- * Reads a SPDY/3 Name/Value header block. This class is made complicated by the
- * requirement that we're strict with which bytes we put in the compressed bytes
- * buffer. We need to put all compressed bytes into that buffer -- but no other
- * bytes.
- */
-class NameValueBlockReader implements Closeable {
-  private final DataInputStream nameValueBlockIn;
-  private final FillableInflaterInputStream fillableInflaterInputStream;
-  private int compressedLimit;
-
-  NameValueBlockReader(final InputStream in) {
-    // Limit the inflater input stream to only those bytes in the Name/Value block. We cut the
-    // inflater off at its source because we can't predict the ratio of compressed bytes to
-    // uncompressed bytes.
-    InputStream throttleStream = new InputStream() {
-      @Override public int read() throws IOException {
-        return Util.readSingleByte(this);
-      }
-
-      @Override public int read(byte[] buffer, int offset, int byteCount) throws IOException {
-        byteCount = Math.min(byteCount, compressedLimit);
-        int consumed = in.read(buffer, offset, byteCount);
-        compressedLimit -= consumed;
-        return consumed;
-      }
-
-      @Override public void close() throws IOException {
-        in.close();
-      }
-    };
-
-    // Subclass inflater to install a dictionary when it's needed.
-    Inflater inflater = new Inflater() {
-      @Override public int inflate(byte[] buffer, int offset, int count)
-          throws DataFormatException {
-        int result = super.inflate(buffer, offset, count);
-        if (result == 0 && needsDictionary()) {
-          setDictionary(Spdy3.DICTIONARY);
-          result = super.inflate(buffer, offset, count);
-        }
-        return result;
-      }
-    };
-
-    fillableInflaterInputStream = new FillableInflaterInputStream(throttleStream, inflater);
-    nameValueBlockIn = new DataInputStream(fillableInflaterInputStream);
-  }
-
-  /** Extend the inflater stream so we can eagerly fill the compressed bytes buffer if necessary. */
-  static class FillableInflaterInputStream extends InflaterInputStream {
-    public FillableInflaterInputStream(InputStream in, Inflater inf) {
-      super(in, inf);
-    }
-
-    @Override public void fill() throws IOException {
-      super.fill(); // This method is protected in the superclass.
-    }
-  }
-
-  public List<String> readNameValueBlock(int length) throws IOException {
-    this.compressedLimit += length;
-    try {
-      int numberOfPairs = nameValueBlockIn.readInt();
-      if (numberOfPairs < 0) {
-        throw new IOException("numberOfPairs < 0: " + numberOfPairs);
-      }
-      if (numberOfPairs > 1024) {
-        throw new IOException("numberOfPairs > 1024: " + numberOfPairs);
-      }
-      List<String> entries = new ArrayList<String>(numberOfPairs * 2);
-      for (int i = 0; i < numberOfPairs; i++) {
-        String name = readString();
-        String values = readString();
-        if (name.length() == 0) throw new IOException("name.length == 0");
-        entries.add(name);
-        entries.add(values);
-      }
-
-      doneReading();
-
-      return entries;
-    } catch (DataFormatException e) {
-      throw new IOException(e.getMessage());
-    }
-  }
-
-  private void doneReading() throws IOException {
-    if (compressedLimit == 0) return;
-
-    // Read any outstanding unread bytes. One side-effect of deflate compression is that sometimes
-    // there are bytes remaining in the stream after we've consumed all of the content.
-    fillableInflaterInputStream.fill();
-
-    if (compressedLimit != 0) {
-      throw new IOException("compressedLimit > 0: " + compressedLimit);
-    }
-  }
-
-  private String readString() throws DataFormatException, IOException {
-    int length = nameValueBlockIn.readInt();
-    byte[] bytes = new byte[length];
-    Util.readFully(nameValueBlockIn, bytes);
-    return new String(bytes, 0, length, "UTF-8");
-  }
-
-  @Override public void close() throws IOException {
-    nameValueBlockIn.close();
-  }
-}


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org


Mime
View raw message