POST request without leads to SEGFAULT
Opened this issue · 3 comments
ldsmoreira commented
In this section of code, when the post request body comes empty the application breaks. Is it the expected behavior ?
else if (request.method == method_t::POST) {
try {
if (request.body.empty())
throw;
possible_prime = std::stoul(request.body);
} catch (...) {
throw std::runtime_error(
"POST requests should have a path of 'is_prime' and a body with 'SOME_NUMBER'");
}
nilsnolde commented
Why POST if there's nothing to POST? I personally find that acceptable:)
kevinkreiser commented
i mean the program is just for testing really, to show how to write an example application using prime_server. indeed the correct response is http400 which is easily done but also not all that important
ldsmoreira commented
Yes, it's definitely understandable! :)
Since I was already working on the shortcircuiters PR and using prime_serverd as my go-to test binary, I fixed it by throwing a runtime_error exception in one of my most recent commits.