treeform / puppy

Puppy fetches via HTTP and HTTPS
MIT License
185 stars 27 forks source link

can't send binary data in POST request #19

Closed veksha closed 2 years ago

veksha commented 3 years ago

this works:

  req.body = @[byte 32,32,32,32]  # just spaces

this doesn't:

  req.body = @[byte 0,0,32,32]

Current behavior:

request (WinHttp.WinHttpRequest.5.1) will be sent with an empty (or truncated) body and content-length header will be changed accordingly.

What I've tried:

editing puppy.nim like this:

        let AStream = CreateObject("ADODB.Stream")
        AStream.Type = 1 # binary
        AStream.Mode = 2 # write mode
        AStream.Open()
        AStream.Write( toVariant(COMBinary req.body) ) #Write data to stream object
        AStream.Flush()  

        obj.send(AStream)

No luck! Don't know how to work with COM so I need your help :)

PS: in libcurl mode - same thing. EDIT: had to add curl.easy_setopt(OPT_POSTFIELDSIZE_LARGE, req.body.len) to make it somewhat work, but still getting SIGSEGV on curl.easy_perform()

treeform commented 2 years ago

Thank you for reporting the bug.

I think we fixed this. Can you try and confirm?

treeform commented 2 years ago

Feel free to reopen if its still an issue.

guzba commented 2 years ago

Puppy version 1.2.1 tested with this fixed. As treeform said, pls reopen if issues remain.