MBXHttpServiceInterface.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. // This file is generated and will be overwritten automatically.
  2. #import <Foundation/Foundation.h>
  3. #import <MapboxCommon/MBXDownloadStatusCallback.h>
  4. #import <MapboxCommon/MBXHttpResponseCallback.h>
  5. #import <MapboxCommon/MBXResultCallback.h>
  6. @class MBXDownloadOptions;
  7. @class MBXHttpRequest;
  8. @protocol MBXHttpServiceInterceptorInterface;
  9. /**
  10. * Interface to the HTTP service.
  11. * This interface provides basic functionality that allows exchanging HTTP requests/responses between client and server
  12. * in an asynchronous way.
  13. */
  14. NS_SWIFT_NAME(HttpServiceInterface)
  15. @protocol MBXHttpServiceInterface
  16. /**
  17. * Set an interceptor for the HttpService's function calls.
  18. *
  19. * @param interceptor The interceptor to be set.
  20. */
  21. - (void)setInterceptorForInterceptor:(nullable id<MBXHttpServiceInterceptorInterface>)interceptor;
  22. /**
  23. * Set maximum number of requests to a single host.
  24. *
  25. * @param max Maximum number of requests.
  26. *
  27. * Default value for cURL is 0 (which means unlimited)
  28. * Default value for OkHttp is unspecified
  29. * Default value for NSURLSession is 8
  30. */
  31. - (void)setMaxRequestsPerHostForMax:(uint8_t)max;
  32. /**
  33. * Sends (or enqueues) a platform's native HTTP Request.
  34. *
  35. * @param request HttpRequest to provide url, headers and other information.
  36. * @param callback Callback to be called in response to the request.
  37. *
  38. * @return ID handle to cancel the request.
  39. */
  40. - (uint64_t)requestForRequest:(nonnull MBXHttpRequest *)request
  41. callback:(nonnull MBXHttpResponseCallback)callback;
  42. /**
  43. * Cancels a pending or running request (or download request).
  44. * In case of success, the result of the HttpResponse in the requests callback will hold the error RequestCancelled
  45. *
  46. * @param id Handle given by request() or download() methods.
  47. * @param 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.
  48. */
  49. - (void)cancelRequestForId:(uint64_t)id
  50. callback:(nonnull MBXResultCallback)callback;
  51. /** Returns true when the HTTP service supports the keepCompression flag for HTTP requests, false otherwise. */
  52. - (BOOL)supportsKeepCompression;
  53. /**
  54. * Send the download request.
  55. * Successful request initiates download session to fetch requested resource.
  56. *
  57. * @param options Download options describing url to download from and place on the disk where to save.
  58. * @param callback Callback to report status of download session.
  59. *
  60. * @return Download id to observe and to cancel the download session.
  61. */
  62. - (uint64_t)downloadForOptions:(nonnull MBXDownloadOptions *)options
  63. callback:(nonnull MBXDownloadStatusCallback)callback;
  64. @end