PaolaJ.
PaolaJ.

Reputation: 11562

How to read from Tornado handler if that key, value pair exists?

I am adding on client key, value pair to header request (in POST and GET request) like

'version', '2.2.9'

nad I want to check on server. How to read from Tornado handler if that key, value pair exists and what is value if exists ?

Upvotes: 0

Views: 635

Answers (1)

jcfaracco
jcfaracco

Reputation: 894

You can do this on Server side:

Your sample class...

class SampleController(tornado.web.RequestHandler):

And get the key,value doing...

    def get(self, **kwargs):
        version = self.request.headers.get('version')
        if version == '2.2.9':
            # your own code

    def post(self, **kwargs):
        version = self.request.headers.get('version')
        if version == '2.2.9':
            # your own code

You can test you server side application using a REST plugin/addon. Postman for chrome or RESTClient for firefox.

Upvotes: 1

Related Questions