Module: Perfect-CURL
class CURL
This class is a wrapper around the CURL library. It permits network operations to be completed using cURL in a block or non-blocking manner.
var responseCode: Int
The CURLINFO_RESPONSE_CODE for the last operation.
var url: String
Get or set the current URL.
func init()
Initialize the CURL request.
func convenience init(url: String)
Initialize the CURL request with a given URL.
func init(dupeCurl: CURL)
Duplicate the given request into a new CURL object.
func reset()
Clean up and reset the CURL object.
func perform(closure: @escaping (Int, [UInt8], [UInt8]) -> ())
Perform the CURL request in a non-blocking manner. The closure will be called with the resulting code, header and body data.
func performFully() -> (Int, [UInt8], [UInt8])
Performs the request, blocking the current thread until it completes.
- returns: A tuple consisting of: Int - the result code, [UInt8] - the header bytes if any, [UInt8] - the body bytes if any
func perform() -> (Bool, Int, [UInt8]?, [UInt8]?)
Performs a bit of work on the current request.
- returns: A tuple consisting of: Bool - should perform() be called again, Int - the result code, [UInt8] - the header bytes if any, [UInt8] - the body bytes if any
func strError(code cod: CURLcode) -> String
Returns the String message for the given CURL result code.
func getInfo(_ info: CURLINFO) -> (Int, CURLcode)
Returns the Int value for the given CURLINFO.
func getInfo(_ info: CURLINFO) -> (String, CURLcode)
Returns the String value for the given CURLINFO.
func setOption(_ option: CURLoption, v: UnsafeMutableRawPointer) -> CURLcode
Sets the pointer option value.
Note that the pointer value is not copied or otherwise manipulated or saved.
It is up to the caller to ensure the pointer value has a lifetime which corresponds to its usage.
func close()
Cleanup and close the CURL request.