pramsey/pgsql-http

Failed to POST binary data

Closed this issue · 1 comments

Hi, when try to do a post request with binary data as:

http(('POST', url, headers, 'application/octet-stream', http.bytea_to_text(data))::http.http_request);

It's failed to upload whole data , only few bytes received on server.

In the http.c file line 1203 shows:

CURL_SETOPT(g_http_handle, CURLOPT_POSTFIELDS, text_to_cstring(content_text));

This is only allow C-style null terminated data.

CURL_SETOPT(g_http_handle, CURLOPT_POSTFIELDS, (char *)(VARDATA(content_text)));
CURL_SETOPT(g_http_handle, CURLOPT_POSTFIELDSIZE, content_size);

The above 2 lines can fix this issue.

Thanks, your patch helped me.