The C++ REST SDK is a Microsoft project for cloud-based client-server communication in native code using a modern asynchronous C++ API design. This project aims to help C++ developers connect to and interact with services.
Other
7.97k
stars
1.65k
forks
source link
HEAD request crashes due to trying to send a body on OSX #1257
In our software we make HEAD requests before downloading files. In order to test this code, I created a small mocking server using cpprest. On Windows, I have no issues when setting the content length in the headers, but on OSX this causes the application to crash with an exception.
libc++abi.dylib: terminating with uncaught exception of type std::logic_error: uninitialized stream object
When use set_body with data instead it works just fine. So it seems that the reply task for a HEAD and GET request are equal, rather than specialized. What I also noticed is that the HEAD request is sent and received by the client, but I don't know if this is due to the async nature and that the body is attempted to be send afterwards.
Since it is just a mocking server, we can use this workaround, but this is not what a HEAD request should be doing if I read the specifications correctly.
In our software we make HEAD requests before downloading files. In order to test this code, I created a small mocking server using cpprest. On Windows, I have no issues when setting the content length in the headers, but on OSX this causes the application to crash with an exception.
libc++abi.dylib: terminating with uncaught exception of type std::logic_error: uninitialized stream object
When use
set_body
with data instead it works just fine. So it seems that the reply task for a HEAD and GET request are equal, rather than specialized. What I also noticed is that the HEAD request is sent and received by the client, but I don't know if this is due to the async nature and that the body is attempted to be send afterwards.Since it is just a mocking server, we can use this workaround, but this is not what a HEAD request should be doing if I read the specifications correctly.
code: