Safely read post body in http request handler?

491 Views Asked by At

How do you safely read the post body of an HTTP POST request in a HTTP Request Handler in Python 3.+

I keep seeing solutions like the one here.

That solution only works if the request includes the content-length header and that header is accurate. Many times content-length gets excluded and is unreliable, any solution based on that is just frail. How do you return data from the rfile buffer without causing it hang by trying to read non existent bytes?

0

There are 0 best solutions below