Need to read response body into local char array

Jul 19, 2013 at 10:04 PM
I am changing legacy code to use Casablanca. We previously used curl lib. I need to read the response body obtained from a GET into a char array. Can you tell me how to do it without copying it twice?

Jul 19, 2013 at 10:11 PM
  1. Create the char array (with the right size...), and use it to create a rawptr_buffer<char> (#include "cpprest/rawptrstream.h").
  2. Get the http response and get the response stream from the htttp response.
  3. Use read_to_end(), passing the stream buffer from 1 as the target of the read.
  4. The data should now be in the char array.
Jul 20, 2013 at 2:50 PM
Thank you Niklas. That worked.

Our team is working on Windows7. We got Casablanca to work by installing via NuGet on codeplex. When I try to

include "cpprest/rawptrstream.h"

, the compiler can't find it. If I

include <rawptrstream.h>

, the compiler finds the include, and the program works. However, I am using
Is this a problem?

Jul 20, 2013 at 9:23 PM
If you are still using 1.0, this is what you should see -- we moved the header files to folders in v1.1. If you are on the latest version (which I highly recommend), then something's wrong.