通过iis7,部署了python cgi服务器
想通过该服务返回201 并且 带location的header,期望浏览器能正常不跳转
通过iis,部署了python cgi服务器
def http201():
try:
print ('Status: 201 Created')
print ('Content-Type: text/html')
print ('Location: http://10.1.146.174/index.html')
print ('')
print ('\n')
except:
logger.error(sys.exc_info())
httplib.error()
return
但是抓包实际浏览器得到的数据是:
HTTP/1.1 302 Redirect
Content-Type: text/html; charset=UTF-8
Location: http://10.1.146.174/index.html
Server: Microsoft-IIS/7.0
X-Powered-By: ASP.NET
Date: Sun, 27 Nov 2011 07:09:56 GMT
Content-Length: 153
但是不设置location的时候,status code是对的
HTTP/1.1 201 Created
Content-Type: text/html
Server: Microsoft-IIS/7.0
X-Powered-By: ASP.NET
Date: Sun, 27 Nov 2011 07:11:33 GMT
Connection: close
Content-Len
网上没有查到什么有效的信息,只是看到isapi好像有设置这些filter的,但是将所有的filter都去掉,然后重启
依然如故,所以,可以基本确定是iis恶心的bug
按照http1.1协议,是允许返回20x status 再加上location的,如果这样返回的话,是告诉client agent,服务器有新的resource,但是客户端可以选择自己处理
而iis这样做就会浏览器每次都自动跳转。