MBXHttpServiceInterface

@protocol MBXHttpServiceInterface

Interface to the HTTP service. This interface provides basic functionality that allows exchanging HTTP requests/responses between client and server in an asynchronous way.

  • Set an interceptor for the HttpService’s function calls.

    Declaration

    Objective-C

    - (void)setInterceptorForInterceptor:
        (nullable id<MBXHttpServiceInterceptorInterface>)interceptor;

    Parameters

    interceptor

    The interceptor to be set.

  • Set maximum number of requests to a single host.

    Default value for cURL is 0 (which means unlimited) Default value for OkHttp is unspecified Default value for NSURLSession is 8

    Declaration

    Objective-C

    - (void)setMaxRequestsPerHostForMax:(uint8_t)max;

    Parameters

    max

    Maximum number of requests.

  • Sends (or enqueues) a platform’s native HTTP Request.

    Declaration

    Objective-C

    - (uint64_t)requestForRequest:(nonnull MBXHttpRequest *)request
                         callback:(nonnull MBXHttpResponseCallback)callback;

    Parameters

    request

    HttpRequest to provide url, headers and other information.

    callback

    Callback to be called in response to the request.

    Return Value

    ID handle to cancel the request.

  • Cancels a pending or running request (or download request). In case of success, the result of the HttpResponse in the requests callback will hold the error RequestCancelled

    Declaration

    Objective-C

    - (void)cancelRequestForId:(uint64_t)id
                      callback:(nonnull MBXResultCallback)callback;

    Parameters

    id

    Handle given by request() or download() methods.

    callback

    Callback to be called after attempt to cancel requests. Use this for error handling related to the id. It does not report if the request gets actually cancelled.

  • Returns true when the HTTP service supports the keepCompression flag for HTTP requests, false otherwise.

    Declaration

    Objective-C

    - (BOOL)supportsKeepCompression;
  • Send the download request. Successful request initiates download session to fetch requested resource.

    Declaration

    Objective-C

    - (uint64_t)downloadForOptions:(nonnull MBXDownloadOptions *)options
                          callback:(nonnull MBXDownloadStatusCallback)callback;

    Parameters

    options

    Download options describing url to download from and place on the disk where to save.

    callback

    Callback to report status of download session.

    Return Value

    Download id to observe and to cancel the download session.