How to pass the char *buffer into http_request body

Mar 11, 2015 at 7:03 PM
Hi,

I have a scenario where char * pointing to large buffer ( say 100MB), and I know the length of the buffer, but I don't want to copy the data to vector<char> etc to pass into request body as it doubles the memory usage during that phase.

Any idea we can handle the scenario in a better way?


Thanks,

Gouse
Mar 11, 2015 at 7:49 PM
Hi Gouse,

Yes this is an important scenario in some cases to avoid copying the memory unnecessarily. In our library we create a streambuffer/stream that can be created from an existing chunk of memory. Take a look at the rawptr_stream in rawptrstream.h. Basically what you need to do is construct an input stream using rawptr_stream::open_istream(...) and then you can use that as the HTTP request body.

Steve
Mar 12, 2015 at 7:25 PM
Thanks Steve.. That really worked:)

-Gouse