2017-04-12 65 views

回答

1

Gunicorn提供了工人掛鉤,可以在這個實例中使用它來在工人關閉時發送Connection:close標題。請嘗試以下鉤在gunicorn.conf文件:

def pre_request(worker, req): 

    if not worker.alive: 
     header_dict = dict(req.headers) 
     header_dict['CONNECTION'] = 'close' 
     req.headers = header_dict.items() 

Gunicorn店頭的元組的列表,所以很簡單的轉換成dictonary,覆蓋/插入連接頭和放回的對象的列表元組一旦完成。