Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

POST request without leads to SEGFAULT #119

Open
ldsmoreira opened this issue Apr 4, 2023 · 3 comments
Open

POST request without leads to SEGFAULT #119

ldsmoreira opened this issue Apr 4, 2023 · 3 comments

Comments

@ldsmoreira
Copy link

ldsmoreira commented Apr 4, 2023

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
Copy link
Contributor

Why POST if there's nothing to POST? I personally find that acceptable:)

@kevinkreiser
Copy link
Owner

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
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants