Package 

Class HttpClient


  • 
    public final class HttpClient
    
                        

    Low-level executor for a single HTTP request over the platform HttpURLConnection — the sole network transport for every SDK-to-server exchange (attribution, in-app events, conversion data, remote config, purchase validation, OneLink). The SDK deliberately uses HttpURLConnection and not OkHttp, so no third-party networking dependency is pulled in (feature F-013).

    A fresh connection is opened and disconnected per call — there is no connection pooling. Application code never touches this class directly: a Task builds a Call through ApiCallFactory, and Call.execute() is what reaches executeRequest.

    • Constructor Summary

      Constructors 
      Constructor Description
      HttpClient(Integer requestTimeoutMillis)
    • Method Summary

      Modifier and Type Method Description
      final Response<String> executeRequest(Request request) Opens the connection, applies the request's method/headers/timeout/cache/redirect settings, writes the body (if any), reads the response, and returns it on the calling thread.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • HttpClient

        HttpClient(Integer requestTimeoutMillis)
        Parameters:
        requestTimeoutMillis - default connect/read timeout applied to every request, unless the individual Request overrides it via Request.timeoutMillis.
    • Method Detail

      • executeRequest

         final Response<String> executeRequest(Request request)

        Opens the connection, applies the request's method/headers/timeout/cache/redirect settings, writes the body (if any), reads the response, and returns it on the calling thread. The Content-Type is application/octet-stream for encrypted payloads and application/json otherwise. A 2xx status marks the Response as successful.

        The whole body is wrapped in try/catch (Throwable), not catch (Exception): a java.lang.Error subclass thrown by the underlying stack (e.g. NoClassDefFoundError, OutOfMemoryError) must be caught here and surfaced as an HttpException so it never escapes a background SDK task and crashes the host app — see IC-141. The connection is always disconnected in finally.