         response.responseBuffers.appendBytes(UnsafePointer<UInt8>(buf), length: size)
         return size
     }
-    
+
     private func curlReadCallback(buf: UnsafeMutablePointer<Int8>, size: Int) -> Int {
         let count = writeBuffers.fillBuffer(UnsafeMutablePointer<UInt8>(buf), length: size)
         return count
     }
-    
+
     private func prepareForRedirect() {
         response.responseBuffers.reset()
         writeBuffers.rewind()

    func curlReadCallback(buf: UnsafeMutablePointer<Int8>, size: Int) -> Int
    func prepareForRedirect()
}


    private var handle: UnsafeMutablePointer<Void>
    private weak var delegate: CurlInvokerDelegate? = nil
    private let maxRedirects: Int

    private init(handle: UnsafeMutablePointer<Void>, maxRedirects: Int) {
        self.handle = handle
        self.maxRedirects = maxRedirects
    }

    private func invoke() -> CURLcode {
        var rc: CURLcode = CURLE_FAILED_INIT
        if  let _ = delegate {
            withUnsafeMutablePointer(&delegate) {ptr in
                self.prepareHandle(ptr)

                var redirected = false
                var redirectCount = 0
                repeat {
                    rc = curl_easy_perform(handle)

                    if  rc == CURLE_OK  {
                        var redirectUrl: UnsafeMutablePointer<Int8> = nil
                        let infoRc = curlHelperGetInfoCString(handle, CURLINFO_REDIRECT_URL, &redirectUrl)
