How to pass the char *buffer into http_request body

Mar 11, 2015 at 6:03 PM

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?


Mar 11, 2015 at 6: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.

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