login about faq

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:

loChilkat.PostBinary(lcURL, lcRawData, "what/ever", 0, 0)

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.

asked Mar 12 at 21:35

commaender's gravatar image


edited Mar 13 at 11:42

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

chilkat's gravatar image

chilkat ♦♦

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported



Asked: Mar 12 at 21:35

Seen: 516 times

Last updated: Mar 14 at 21:06

powered by OSQA