DeadlyFirex / PrimoTracker

Suite of tools to track your income over time of primo's.
GNU Affero General Public License v3.0
1 stars 0 forks source link

[Bug Report] Failure to close connection on endpoints w/body causes bad requests #18

Open DeadlyFirex opened 10 months ago

DeadlyFirex commented 10 months ago

From DeadlyFirex/PrimoTracker

Describe the bug Causing a connection to keep-alive will make the application not consume the request body on PUT, DELETE and POST for example. This only happens when the request exits, for example due to bad input before the body is consumed in the code. The {} will pass over to the next request, causing internal issues and malformed responses.

Steps to reproduce

  1. Start the application with proper configuration
  2. Send requests to endpoints that require a request body
  3. Requests should include keep-alive
  4. Send invalid data, so the endpoint exists the function prematurely

Expected behavior The body gets consumed, and not passed over.

Actual behavior The {} get passed over to the next request.

Screenshots N/A

Operating System: N/A

Additional context

When you set the request body to {} with Postman or any HTTP clients, the first request will return 200, while the second request will return a 405 error response. The log shows the request method is {}POST:

See the following issue: https://github.com/pallets/flask/issues/4507 for more information.

This can be avoided running a production WSGI server like gunicorn. Furthermore closing the connection while in the development version will fix the issue. Non operating system dependent.

DeadlyFirex commented 10 months ago

Reassigned priority as it's unknown if this is fixable due to the issue being Flask-dependant, but it's worth to note, and possibly to eventually work around.