python - Tornado - What is the difference between RequestHandler's get_argument(), get_query_argument() and get_body_argument()? -


when use requesthandler.get_argument(), requesthandler.get_query_argument() , requesthandler.get_body_argument()?

what use-case each of them?

also request.body , request.argument in these cases? used in scenarios?

and, there request.query or similar too?

most http requests store parameters (say, form values) in 1 of 2 places: url (in form of ?foo=bar&spam=eggs query string), or in request body (when using post request , either application/x-www-form-urlencoded or multipart/form-data mime type).

the request.get_query_argument() looks url parameters, requesthandler.get_body_argument() lets retrieve parameters set in post body. requesthandler.get_argument() method retrieves either body or url parameter (in order).

you use request.get_argument() when explicitly don't care parameter comes , endpoint supports both , post parameters. otherwise, use 1 of other methods, keep explicit parameters come from.

the request.get_*_argument methods use request.body_arguments , request.query_arguments values (with request.arguments being aggregate), decoded unicode. request.body undecoded, unparsed raw request body; , yes, there equivalent self.query containing query string url.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -