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/
  2. benchmarks/
  3. mockwebserver/
  4. okcurl/
  5. okhttp/
  6. okhttp-android-support/
  7. okhttp-apache/
  8. okhttp-hpacktests/
  9. okhttp-testing-support/
  10. okhttp-tests/
  11. okhttp-urlconnection/
  12. okhttp-ws/
  13. okhttp-ws-tests/
  14. okio/
  15. samples/
  16. website/
  17. Android.mk
  18. CHANGELOG.md
  19. checkstyle.xml
  20. CONTRIBUTING.md
  21. deploy_website.sh
  22. jarjar-rules.txt
  23. LICENSE.txt
  24. MODULE_LICENSE_APACHE2
  25. pom.xml
  26. README.android
  27. README.md
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.