         return count
         
     }
+    
+    /// libCurl callback to recieve header sent by the server. Being called per each header line.
+    fileprivate func curlHeaderCallback(_ buf: UnsafeMutablePointer<Int8>, size: Int) -> Int {
+        // If the header status line begins with 'HTTP/2 ' we replace it with 'HTTP/2.0' because
+        // otherwise the CHTTPParser will parse this line incorrectly and won't extract the status code
+        ClientRequest.Http2StatusLineVersion.withUnsafeBytes() { (ptr: UnsafePointer<UInt8>) -> Void in
+            if memcmp(ptr, buf, ClientRequest.Http2StatusLineVersion.count) == 0 {
+                ClientRequest.Http2StatusLineVersionWithMinor.withUnsafeBytes() { (p: UnsafePointer<UInt8>) -> Void in
+                    response?.responseBuffers.append(bytes: p, length: ClientRequest.Http2StatusLineVersionWithMinor.count)
+                    response?.responseBuffers.append(bytes: UnsafeRawPointer(buf).assumingMemoryBound(to: UInt8.self) + ClientRequest.Http2StatusLineVersion.count,
+                                                     length: size - ClientRequest.Http2StatusLineVersion.count)
+                }
+            }
+            else {
+                response?.responseBuffers.append(bytes: UnsafeRawPointer(buf).assumingMemoryBound(to: UInt8.self), length: size)
+            }
+        }
+        
+        return size
+        
+    }
 
     /// libCurl callback invoked when a redirect is about to be done
     fileprivate func prepareForRedirect() {

            self.maxRedirects = maxRedirects
        case .disableSSLVerification:
            self.disableSSLVerification = true
        }
    }



        // To see the messages sent by libCurl, uncomment the next line of code
        //curlHelperSetOptInt(handle, CURLOPT_VERBOSE, 1)
		
        if useHTTP2 {
            curlHelperSetOptInt(handle!, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_2_0)
        }
    }

    /// Sets the HTTP method and Content-Length in libCurl
