AsyncHTTPClient 1.4.1 Docs (89% documented)
AsyncHTTPClient Reference
HTTPClient Class Reference
publicclassHTTPClientHTTPClient class provides API for request execution.
Example:
letclient=HTTPClient(eventLoopGroupProvider:.createNew)client.get(url:"https://swift.org",deadline:.now()+.seconds(1)).whenComplete{resultinswitchresult{case.failure(leterror):// process errorcase.success(letresponse):ifletresponse.status==.ok{// handle response}else{// handle remote error}}}It is important to close the client instance, for example in a defer statement, after use to cleanly shutdown the underlying NIOEventLoopGroup:
tryclient.syncShutdown()Undocumented
Swift
publicleteventLoopGroup:EventLoopGroupCreate anHTTPClient with specifiedEventLoopGroup provider and configuration.
Swift
publicconvenienceinit(eventLoopGroupProvider:EventLoopGroupProvider,configuration:Configuration=Configuration())eventLoopGroupProvider | Specify how |
configuration | Client configuration. |
Create anHTTPClient with specifiedEventLoopGroup provider and configuration.
Swift
publicrequiredinit(eventLoopGroupProvider:EventLoopGroupProvider,configuration:Configuration=Configuration(),backgroundActivityLogger:Logger)eventLoopGroupProvider | Specify how |
configuration | Client configuration. |
Shuts down the client andEventLoopGroup if it was created by the client.
Swift
publicfuncsyncShutdown()throwsShuts down the client and event loop gracefully. This function is clearly an outlier in that it uses a completioncallback instead of an EventLoopFuture. The reason for that is that NIO’s EventLoopFutures will call back on an event loop.The virtue of this function is to shut the event loop down. To work around that we call back on a DispatchQueueinstead.
Swift
publicfuncshutdown(queue:DispatchQueue=.global(),_callback:@escaping(Error?)->Void)ExecuteGET request using specified URL.
Swift
publicfuncget(url:String,deadline:NIODeadline?=nil)->EventLoopFuture<Response>url | Remote URL. |
deadline | Point in time by which the request must complete. |
ExecuteGET request using specified URL.
Swift
publicfuncget(url:String,deadline:NIODeadline?=nil,logger:Logger)->EventLoopFuture<Response>url | Remote URL. |
deadline | Point in time by which the request must complete. |
logger | The logger to use for this request. |
ExecutePOST request using specified URL.
url | Remote URL. |
body | Request body. |
deadline | Point in time by which the request must complete. |
ExecutePOST request using specified URL.
url | Remote URL. |
body | Request body. |
deadline | Point in time by which the request must complete. |
logger | The logger to use for this request. |
ExecutePATCH request using specified URL.
url | Remote URL. |
body | Request body. |
deadline | Point in time by which the request must complete. |
ExecutePATCH request using specified URL.
url | Remote URL. |
body | Request body. |
deadline | Point in time by which the request must complete. |
logger | The logger to use for this request. |
ExecutePUT request using specified URL.
url | Remote URL. |
body | Request body. |
deadline | Point in time by which the request must complete. |
ExecutePUT request using specified URL.
url | Remote URL. |
body | Request body. |
deadline | Point in time by which the request must complete. |
logger | The logger to use for this request. |
ExecuteDELETE request using specified URL.
Swift
publicfuncdelete(url:String,deadline:NIODeadline?=nil)->EventLoopFuture<Response>url | Remote URL. |
deadline | The time when the request must have been completed by. |
ExecuteDELETE request using specified URL.
Swift
publicfuncdelete(url:String,deadline:NIODeadline?=nil,logger:Logger)->EventLoopFuture<Response>url | Remote URL. |
deadline | The time when the request must have been completed by. |
logger | The logger to use for this request. |
Execute arbitrary HTTP request using specified URL.
method | Request method. |
url | Request url. |
body | Request body. |
deadline | Point in time by which the request must complete. |
logger | The logger to use for this request. |
Execute arbitrary HTTP+UNIX request to a unix domain socket path, using the specified URL as the request to send to the server.
method | Request method. |
socketPath | The path to the unix domain socket to connect to. |
urlPath | The URL path and query that will be sent to the server. |
body | Request body. |
deadline | Point in time by which the request must complete. |
logger | The logger to use for this request. |
Execute arbitrary HTTPS+UNIX request to a unix domain socket path over TLS, using the specified URL as the request to send to the server.
method | Request method. |
secureSocketPath | The path to the unix domain socket to connect to. |
urlPath | The URL path and query that will be sent to the server. |
body | Request body. |
deadline | Point in time by which the request must complete. |
logger | The logger to use for this request. |
Execute arbitrary HTTP request using specified URL.
request | HTTP request to execute. |
deadline | Point in time by which the request must complete. |
Execute arbitrary HTTP request using specified URL.
request | HTTP request to execute. |
deadline | Point in time by which the request must complete. |
logger | The logger to use for this request. |
Execute arbitrary HTTP request using specified URL.
Swift
publicfuncexecute(request:Request,eventLoop:EventLoopPreference,deadline:NIODeadline?=nil)->EventLoopFuture<Response>request | HTTP request to execute. |
eventLoop | NIO Event Loop preference. |
deadline | Point in time by which the request must complete. |
Execute arbitrary HTTP request and handle response processing using provided delegate.
Swift
publicfuncexecute(request:Request,eventLoopeventLoopPreference:EventLoopPreference,deadline:NIODeadline?=nil,logger:Logger?)->EventLoopFuture<Response>request | HTTP request to execute. |
eventLoop | NIO Event Loop preference. |
deadline | Point in time by which the request must complete. |
logger | The logger to use for this request. |
Execute arbitrary HTTP request and handle response processing using provided delegate.
Swift
publicfuncexecute<Delegate:HTTPClientResponseDelegate>(request:Request,delegate:Delegate,deadline:NIODeadline?=nil)->Task<Delegate.Response>request | HTTP request to execute. |
delegate | Delegate to process response parts. |
deadline | Point in time by which the request must complete. |
Execute arbitrary HTTP request and handle response processing using provided delegate.
Swift
publicfuncexecute<Delegate:HTTPClientResponseDelegate>(request:Request,delegate:Delegate,deadline:NIODeadline?=nil,logger:Logger)->Task<Delegate.Response>request | HTTP request to execute. |
delegate | Delegate to process response parts. |
deadline | Point in time by which the request must complete. |
logger | The logger to use for this request. |
Execute arbitrary HTTP request and handle response processing using provided delegate.
Swift
publicfuncexecute<Delegate:HTTPClientResponseDelegate>(request:Request,delegate:Delegate,eventLoopeventLoopPreference:EventLoopPreference,deadline:NIODeadline?=nil)->Task<Delegate.Response>request | HTTP request to execute. |
delegate | Delegate to process response parts. |
eventLoop | NIO Event Loop preference. |
deadline | Point in time by which the request must complete. |
logger | The logger to use for this request. |
Execute arbitrary HTTP request and handle response processing using provided delegate.
Swift
publicfuncexecute<Delegate:HTTPClientResponseDelegate>(request:Request,delegate:Delegate,eventLoopeventLoopPreference:EventLoopPreference,deadline:NIODeadline?=nil,loggeroriginalLogger:Logger?)->Task<Delegate.Response>request | HTTP request to execute. |
delegate | Delegate to process response parts. |
eventLoop | NIO Event Loop preference. |
deadline | Point in time by which the request must complete. |
HTTPClient configuration.
Swift
publicstructConfigurationSpecifies howEventLoopGroup will be created and establishes lifecycle ownership.
Swift
publicenumEventLoopGroupProviderSpecifies how the library will treat event loop passed by the user.
See moreSpecifies decompression settings.
See moreSwift
publicenumDecompressionA representation of an HTTP cookie.
See moreSwift
publicstructCookieRepresent HTTP response.
See moreSwift
publicstructResponseRepresent request body.
See moreSwift
publicstructBodyRepresent HTTP request.
See moreSwift
publicstructRequestHTTP authentication
See moreSwift
publicstructAuthorization:Hashable© 2023AsyncHTTPClient team. All rights reserved. (Last updated: 2023-01-17)
Generated byjazzy ♪♫ v0.14.3, aRealm project.