Python BaseHandler.apply\u response\u修复程序在django中做什么?
我正在使用Python BaseHandler.apply\u response\u修复程序在django中做什么?,python,django,http-headers,http-redirect,Python,Django,Http Headers,Http Redirect,我正在使用pdb逐步完成django请求/响应周期,以调试重定向被破坏的问题 在响应()的最后阶段,我已经通过了中间件的应用程序,现在调用了BaseHandler.apply\u response\u fixes(request,response),它会弄乱我的重定向头: 前面的标题 (Pdb) response._headers {'x-frame-options': ('X-Frame-Options', 'SAMEORIGIN'), 'content-type': ('Content-T
pdb
逐步完成django请求/响应周期,以调试重定向被破坏的问题
在响应()的最后阶段,我已经通过了中间件的应用程序,现在调用了BaseHandler.apply\u response\u fixes(request,response)
,它会弄乱我的重定向头:
前面的标题
(Pdb) response._headers
{'x-frame-options': ('X-Frame-Options', 'SAMEORIGIN'),
'content-type': ('Content-Type', 'application/octet-stream'),
'location':'http://localhost:9000/6/result//blogs/',
'server': ('Server', 'WSGIServer/0.2 CPython/3.4.3')}
现在我做下一步:
-> response = self.apply_response_fixes(request, response)
(Pdb) n
现在在我的位置标题中有一个杂散的t
:
后面的标题
(Pdb) response._headers
{'x-frame-options': ('X-Frame-Options', 'SAMEORIGIN'),
'content-type': ('Content-Type', 'application/octet-stream'),
'location': ('Location', 'http://localhost:9000/6/result//blogs/t'),
'server': ('Server', 'WSGIServer/0.2 CPython/3.4.3')}
BaseHandler.apply\u response\u fixes(请求、响应)
看起来足够简单:
response_fixes = [
http.conditional_content_removal,
]
def apply_response_fixes(self, request, response):
"""
Applies each of the functions in self.response_fixes to the request and
response, modifying the response in the process. Returns the new
response.
"""
for func in self.response_fixes:
response = func(request, response)
return response
这是怎么回事?BaseHandler.apply\u response\u fixes(请求、响应)
做什么
如何避免这个问题?响应对象的类是什么?
django.http.HttpResponse
为什么不使用HttpResponseRedirect?我看到的唯一一件事是apply\u response\u调用的conditional\u content\u remove
函数修复了HttpResponse
对象的内容值。而HttpResponse
有一个属性设置程序,可以对响应进行一些更改。我不知道这是否是你问题的根源。是的,我也是。我不是重定向的作者,我正在代理它,所以我不能对基类做任何事情。