- Codelab to demonstrate networking on Android and JVM using OkHttp and Retrofit.
- OkHttp and Retrofit libraries
- Basics of HTTP - headers, path, queries, timeouts
- Modifying requests by interceptors
- Authentication, SSL, Certificate Pinning
- OkHttp internals and philosophy
- Caching
- Cache-Control Headers and their use cases
- Etag usage
- Testing Networking code
- Using MockWebServer
- Testing whole repositories
- Complex networking scenarios with parallel requests
- Client network strategies
- Simple retries
- Exponential backoff
- Network throttling
- All code is in the default branch.
- You can find the unit tests within the
codelab
directory in the formatTest{Number}{Topic}
- Each test has comments with instructions and references to guide to the solution.
- There is a solution package having identical
Test{Number}{Topic}
name with working code. - Other key classes to look at are:
HttpModule
,HttpBinClient
,GitHubUsersClient
- Most of the methods use the Retrofit
Call
and we move to Coroutinessuspend
functions through the codelab.
- HTTP in a Hostile World, Slides
- Okio powering OkHttp I/O
- Android Studio Network Inspector
- Cache-Control & ETag, OkHttp Caching
- Gzip, Content-Length header
- Exponential Backoff
- OkHttp retries requests by default
- URL encoding
- Client network throttling
- Bearer authentication
- Android Network Config certificate pinning