http_data_cb typedef

Callbacks should return non-zero to indicate an error. The parser will then halt execution.

The one exception is on_headers_complete. In a HTTP_RESPONSE parser returning '1' from on_headers_complete will tell the parser that it should not expect a body. This is used when receiving a response to a HEAD request which may contain 'Content-Length' or 'Transfer-Encoding: chunked' headers that indicate the presence of a body.

Returning 2 from on_headers_complete will tell parser that it should not expect neither a body nor any futher responses on this connection. This is useful for handling responses to a CONNECT request which may not contain Upgrade or Connection: upgrade headers.

http_data_cb does not return data chunks. It will be called arbitrarily many times for each string. E.G. you might get 10 callbacks for "on_url" each providing just a few characters more data.

Implementation

typedef http_data_cb = ffi.Pointer<ffi.NativeFunction<http_data_cbFunction>>;