DO NOT MERGE: Fix URLConnectionTest.writeTimeouts with large receive buffers

This is upstream okhttp commit 8b19bc471f66ee45c5eed3df6817411d074aabe5.
https://github.com/square/okhttp/commit/8b19bc471f66ee45c5eed3df6817411d074aabe5
back-ported to Android's version of OkHttp.

From the upstream commit:

The test relies on small client send / server receive buffers
to force blocking and generate a timeout.

The switch to make MockWebServer a @Rule (commit
785d9e94387f404f571775a49c3a9438508bb659) moved the
MockWebServer.start() call earlier in the test execution.
Setting the ServerSocketFactory became a no-op so the server
receive buffer size was left as the default.

The test became reliant on either:
1) The default server socket receive buffer being small enough
(e.g. less than the data being transmitted).
2) The device being too slow to send the requested data in the
time allowed.

The test was recently made less reliable by:
1) The okio commit
f30955cb15eb234f874dd55819686832c960765b, which made the segment
size bigger (increasing throughput / transfer efficiency).
2) The OkHttp commit f30955cb15eb234f874dd55819686832c960765b,
which reduced the amount of data being sent in the test from
16MB to 2MB.
3) Recent Android devices have large default buffer sizes. e.g.
Nexus 5: 1MB, Nexus 5X: 6MB.

Bug: 25459708
Change-Id: Icaa3255d86d228302931baca0432ea9a5be1e7f0
2 files changed
tree: 46ea58defddafd334df47b6b217d2b6de951e0a6
  1. Android.mk
  2. CHANGELOG.md
  3. CONTRIBUTING.md
  4. LICENSE.txt
  5. MODULE_LICENSE_APACHE2
  6. README.android
  7. README.md
  8. android/
  9. benchmarks/
  10. checkstyle.xml
  11. deploy_website.sh
  12. jarjar-rules.txt
  13. mockwebserver/
  14. okcurl/
  15. okhttp-android-support/
  16. okhttp-apache/
  17. okhttp-hpacktests/
  18. okhttp-testing-support/
  19. okhttp-tests/
  20. okhttp-urlconnection/
  21. okhttp-ws-tests/
  22. okhttp-ws/
  23. okhttp/
  24. okio/
  25. pom.xml
  26. samples/
  27. website/
README.md

OkHttp

An HTTP & SPDY client for Android and Java applications. For more information see the website and the wiki.

Download

Download the latest JAR or grab via Maven:

<dependency>
  <groupId>com.squareup.okhttp</groupId>
  <artifactId>okhttp</artifactId>
  <version>2.3.0</version>
</dependency>

or Gradle:

compile 'com.squareup.okhttp:okhttp:2.3.0'

Snapshots of the development version are available in Sonatype's snapshots repository.

MockWebServer

A library for testing HTTP, HTTPS, HTTP/2.0, and SPDY clients.

MockWebServer coupling with OkHttp is essential for proper testing of SPDY and HTTP/2.0 so that code can be shared.

Download

Download the latest JAR or grab via Maven:

<dependency>
  <groupId>com.squareup.okhttp</groupId>
  <artifactId>mockwebserver</artifactId>
  <version>2.3.0</version>
  <scope>test</scope>
</dependency>

or Gradle:

testCompile 'com.squareup.okhttp:mockwebserver:2.3.0'

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.