1)
I get this http response header()
(L"Cache-Control", L"no-cache")
(L"Content-Encoding", L"gzip")
(L"Content-Length", L"792")
(L"Content-Type", L"application/json;charset=utf-8")
(L"Date", L"Sat, 16 Aug 2014 12:28:30 GMT")
I get the following http response:
auto v = response.extract_vector().get(); // throws system_error
//or
auto v = response.extract_vector().get();
return std::string(v.cbegin(), v.cend()); //mangled data
I suspect maybe you dont support gzip?
2)
My large application on window works with std::string, as all the 3rd party libraries and HTTP servers use that. I dont understand why Casablanca forces me to use std::wstring? It becomes inefficient for me to convert back and fort just to be able to use this networking library. Cant you have a separate build for std::string (like on linux)?
Regards Petke
Comments: Hi Petke, Ok I tried running a couple variants of a smaller version of your program. Basically here is the situation. For Windows desktop we are building on top of WinHttp which doesn't provide any gzip compression/decompression functionality. We don't implement it either in the C++ Rest SDK on top. extract_string() fails because it is trying to convert what it thinks is utf-8 to utf-16, however it is actually just raw data that needs to be decompressed. What you can do is use extract_vector() or http_response::body() to access the raw response body data and then run that through another library or API that can decompress, like zlib. I don't think there is any issue or bug here. There is nothing wrong with the code that I can see, I'm changing this issue to a feature request for gzip support and updating the title to reflect as well. If this is a feature you're strongly interested in you could consider implementing and contributing back. Thanks, Steve
I get this http response header()
(L"Cache-Control", L"no-cache")
(L"Content-Encoding", L"gzip")
(L"Content-Length", L"792")
(L"Content-Type", L"application/json;charset=utf-8")
(L"Date", L"Sat, 16 Aug 2014 12:28:30 GMT")
I get the following http response:
auto v = response.extract_vector().get(); // throws system_error
//or
auto v = response.extract_vector().get();
return std::string(v.cbegin(), v.cend()); //mangled data
I suspect maybe you dont support gzip?
2)
My large application on window works with std::string, as all the 3rd party libraries and HTTP servers use that. I dont understand why Casablanca forces me to use std::wstring? It becomes inefficient for me to convert back and fort just to be able to use this networking library. Cant you have a separate build for std::string (like on linux)?
Regards Petke
Comments: Hi Petke, Ok I tried running a couple variants of a smaller version of your program. Basically here is the situation. For Windows desktop we are building on top of WinHttp which doesn't provide any gzip compression/decompression functionality. We don't implement it either in the C++ Rest SDK on top. extract_string() fails because it is trying to convert what it thinks is utf-8 to utf-16, however it is actually just raw data that needs to be decompressed. What you can do is use extract_vector() or http_response::body() to access the raw response body data and then run that through another library or API that can decompress, like zlib. I don't think there is any issue or bug here. There is nothing wrong with the code that I can see, I'm changing this issue to a feature request for gzip support and updating the title to reflect as well. If this is a feature you're strongly interested in you could consider implementing and contributing back. Thanks, Steve