Search code examples
pythonpython-3.xhttptornado

How can I set custom Server header with Tornado?


I noticed that my app returns this HTTP response header:

Server: TornadoServer/4.5.2

Is it possible to change it to custom?


Solution

  • You can use the RequestHandler.set_header() for the headers you want to add or change. Here is an example

        RequestHandler.set_header('Access-Control-Allow-Origin', '*')
        RequestHandler.set_header('Access-Control-Allow-Methods', 'POST, GET, PUT, DELETE, OPTIONS')
        RequestHandler.set_header('Access-Control-Max-Age', 1000)