Quantcast
Channel: WE MOVED to github.com/microsoft/cpprestsdk. This site is not monitored!
Viewing all articles
Browse latest Browse all 4845

Commented Issue: Exception: when request() is called with GET and body_send [4]

$
0
0
This is more of error checking than anything else. I inadvertently used methods::GET with body_data. I really wanted to use methods::POST.

test:

```
//
//this one will generate exception
//
http_client client(U("http://localhost"));
client.request(methods::GET, U("/"), U("blah=data")).then([=](http_response response)
{
wcout<<response.to_string();
}).wait();

//
//this one will work
//
http_client client(U("http://localhost"));
client.request(methods::POST, U("/"), U("blah=data")).then([=](http_response response)
{
wcout<<response.to_string();
}).wait();
```
Comments: c2c, If by "crash" you mean getting a C++ exception, then yes. In the HTTP library, specifically, we distinguish between errors coming back from a server in the form of a correctly formed message with a 4xx code, which do not result in exceptions, and errors such as network errors, or input argument errors, which result in exceptions. It was a general design decision of ours to leverage C++ exceptions to report errors, including incorrectly formed input. This design is used across the Casablanca library, not just in the HTTP client code. In fact, the next upcoming release will clean up some areas where this design principle was inconsistently applied in the streams library (incorrectly returning EOF when an error is encountered). Niklas

Viewing all articles
Browse latest Browse all 4845

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>