HTTP Integration (Android Only)#
Platform-only: Android.
This page covers HttpURLConnectionProvider timeouts and redirect handling at the Driver Layer. Cookie management is also required for any Android HAAPI integration — regardless of which layer you choose — and is documented under Android Platform Notes.
HttpURLConnectionProvider Timeouts#
When you implement your own HttpURLConnectionProvider to return HttpURLConnection instances, explicitly set connectTimeout and readTimeout. The driver applies sensible defaults when you do not (connectTimeout = 5s, readTimeout = 10s), but the defaults are not appropriate for every deployment.
class MyHttpURLConnectionProvider : HttpURLConnectionProvider {
override fun open(url: URL): HttpURLConnection {
return (url.openConnection() as HttpURLConnection).apply {
connectTimeout = 10_000 // 10 seconds
readTimeout = 30_000 // 30 seconds
// other transport-specific configuration
}
}
}
Explicit timeouts protect against indefinite hangs and let you tune behavior to your network profile — slower mobile networks may need higher read timeouts; high-volume backends may need lower ones.
Redirects#
Whatever your HttpURLConnectionProvider configures, the driver turns redirect following off on every connection it sends a request over, and refuses a 301, 302, 303, 307 or 308 response with a non-empty Location with haapi_redirect_refused, sending nothing to its target. A connection that follows a redirect despite the setting — a wrapping connection that does not pass it on, for example — is detected only when it reports the URL it reached through getURL(). The request has then already reached the redirect target, and the refusal’s statusCode is the status of the response the redirect led to. A connection that reports the URL it was opened with hides the redirect, and the response it reached is returned. See Upgrade — Redirects Are Refused.
Related: Android Driver · Android Platform Notes