Signal1
Signal support.
HTTPRequest.swift:756class Signal1
Use the connect(flags:_:)
method to connect to the signal on the container object, and disconnect(_:)
to drop the connection.
You can also await the emitted
property for waiting for a single emission of the signal.
Other members in extension
View members
Hide members
This section is hidden by default because it contains too many (19) members.
Types
Type members
Instance members
var acceptGzip: Bool
If
true
, this header will be added to each request:Accept-Encoding: gzip, deflate
telling servers that it’s okay to compress response bodies.var bodySizeLimit: Int32
Maximum allowed size for response bodies. If the response body is compressed, this will be used as the maximum allowed size for the decompressed body.
var downloadChunkSize: Int32
The size of the buffer used and maximum bytes to read per iteration. See
readChunkSize
.var downloadFile: String
The file to download into. Will output any received file into it.
var maxRedirects: Int32
Maximum number of allowed redirects.
var requestCompleted: Signal1
Emitted when a request is completed.
var timeout: Double
The duration to wait in seconds before a request times out. If
timeout
is set to0.0
then the request will never time out. For simple requests, such as communication with a REST API, it is recommended thattimeout
is set to a value suitable for the server response time (e.g. between1.0
and10.0
). This will help prevent unwanted timeouts caused by variation in server response times while still allowing the application to detect when a request has timed out. For larger requests such as file downloads it is suggested thetimeout
be set to0.0
, disabling the timeout functionality. This will help to prevent large transfers from failing due to exceeding the timeout value.var useThreads: Bool
If
true
, multithreading is used to improve performance.func cancelRequest(
) Cancels the current request.
func getBodySize(
) -> Int32 Returns the response body length.
func getDownloadedBytes(
) -> Int32 Returns the number of bytes this HTTPRequest downloaded.
func getHttpClientStatus(
) -> HTTPClient.Status Returns the current status of the underlying
HTTPClient
. SeeHTTPClient.Status
.func request(url: String, customHeaders: PackedStringArray, method: HTTPClient.Method, requestData: String
) -> GodotError Creates request on the underlying
HTTPClient
. If there is no configuration errors, it tries to connect usingconnectToHost(_:port:tlsOptions:)
and passes parameters ontorequest(method:url:headers:body:)
.func requestRaw(url: String, customHeaders: PackedStringArray, method: HTTPClient.Method, requestDataRaw: PackedByteArray
) -> GodotError Creates request on the underlying
HTTPClient
using a raw array of bytes for the request body. If there is no configuration errors, it tries to connect usingconnectToHost(_:port:tlsOptions:)
and passes parameters ontorequest(method:url:headers:body:)
.func setHttpProxy(host: String, port: Int32
) Sets the proxy server for HTTP requests.
func setHttpsProxy(host: String, port: Int32
) Sets the proxy server for HTTPS requests.
func setTlsOptions(clientOptions: TLSOptions?
) Sets the
TLSOptions
to be used when connecting to an HTTPS server. Seeclient(trustedChain:commonNameOverride:)
.
Citizens in SwiftGodot
Instance members
var emitted: Void
You can await this property to wait for the signal to be emitted once
func connect(flags: Object.ConnectFlags, @escaping (_ result: Int64, _ responseCode: Int64, _ headers: PackedStringArray, _ body: PackedByteArray) -> ()
) -> Object Connects the signal to the specified callback
func disconnect(Object
) Disconnects a signal that was previously connected, the return value from calling
connect(flags:_:)