Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot send binary payload #24

Open
neilyoung opened this issue Dec 11, 2016 · 0 comments
Open

Cannot send binary payload #24

neilyoung opened this issue Dec 11, 2016 · 0 comments

Comments

@neilyoung
Copy link

neilyoung commented Dec 11, 2016

Hi,

trying to HTTP PUT a binary buffer.

http.put('http://example.com/api/v1/target',
    'Content-Type: application/octet-stream\r\n',
    payload,
    function(code, data)
        if (code < 0) then
            print("HTTP request failed")
        else
            print(code, data)
        end
end)

The payload sent is always cut off after the first "0" byte in the payload stream. How can I send binary data?

PS: I think the problem is buried in line 194 of http_client.c

    if ( req->post_data != NULL ) /* If there is data then add Content-Length header. */ {
	os_sprintf( post_headers, "Content-Length: %d\r\n", strlen( req->post_data ) );
}

strlen takes the 0 byte seriously...

PPS: The GET API has no problem with binary data at all...

PPPS: And your module is that fixed on "strlen(blabla)", that I suppose it will not be possible at all...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant