I am trying to send raw data from my FoxPro App using Chilkat HTTP (latest version, downloaded today).
What I want to do: I have raw binary data saved in a local variable in my FoxPro App. This data has to be sent to a URL, that has some parameters, like: http://mydomain.com/datatransfer.php?file=xyz.jpg&start=0&end=500. The complete body of the POST must consist of the raw data, so I do not want to have it url-encoded and mixed with the other parameters.
I tried with:
But Chilkat converts my raw data to some unicode whatsoever. Instead of sending 500 bytes, in Fiddler I see it sends 1,000 bytes, with a 0 inserted after each byte.
Then I tried some workaround using SynchronousRequest(), because this was the only way I found to use my own HttpRequest-Object (except PostUrlEncoded, but I do not want any encoding). But whatever I use to build my request, it failed. AddBytesForUpload(), AddFileForUpload() and AddStringForUpload() all want to have a "name" for "filename". But I do not want it to add any name, just POST the raw data. LoadBodyFromBytes() again does some character encoding or conversion, it adds 0 again to every single byte. And LoadBodyFromString() wants to have some charset.
The only thing that worked for me, is StreamBodyFromFile(). This means, I have to write my raw data to a temp file, then stream the file to Chilkat HTTP, and then delete the temp file again. Seems to be a bad way to do the job...
Anyone having an idea how to solve my problem?
BTW: I am using Chilkat ActiveX DLL 32-Bit. FoxPro is also 32-Bit.
The fact that a 0 is every-other-byte looks a lot like a Unicode (utf-16) string. It must be that lcRawData is a string, and when one passes a string to an ActiveX, it is always passed as a BSTR (which is utf-16). Therefore, if you pass a string to a method expecting binary data for the argument, you'll get the binary bytes of the utf-16 string. Call PText instead...
answered Mar 14 at 21:06