Open Stronking opened 7 months ago
why is the body_arguments attribute initialized as an empty dictionary {}?
What alternative do you have in mind?
This design choice necessitates developers to manually parse the request.body when handling POST request bodies,
Ah, are you talking about parsing JSON or other body formats? The (query|body)_argument(s)
attributes and methods are specific to HTML forms, and they inherit a lot of quirks from the limitations of the form-encoded format. If you're using something other than HTML form-encoded data, just ignore all of this and do something like self.json_args = parse(self.request.body)
in an override of prepare()
.
Will this issue be addressed or improved in future versions?
I have no plans for changes here. I have vague interest in some sort of middleware scheme that would let you centralize request parsing but no concrete plans.
In the tornado.httputil.HTTPServerRequest class, why is the body_arguments attribute initialized as an empty dictionary {}? This design choice necessitates developers to manually parse the request.body when handling POST request bodies, and it precludes the use of parameter assertions. Consequently, when utilizing the tornado.web.RequestHandler.get_body_argument[s]() methods, a MissingArgumentError is consistently thrown if the corresponding parameter is missing from the request body. Will this issue be addressed or improved in future versions? This problem can hinder user experience and code robustness, especially for developers who are new to the Tornado framework. It may increase the difficulty of understanding and using the framework. It would be appreciated if the development team could consider optimizing this issue or providing clearer documentation on how to handle it.