在运行gevent的WSGIServer时,我遇到了一些非常奇怪的行为。似乎每个通过的请求都被错误地解释了方法。
如果我发送以下请求:
requests.get('http://localhost:5000')
requests.head('http://localhost:5000')
requests.delete('http://localhost:5000')
requests.put('http://localhost:5000')
requests.post('http://localhost:5000')这就是控制台中显示的内容:
127.0.0.1 - - [2012-01-22 14:55:36] "POST / HTTP/1.1" 405 183 "-" "python-requests/0.9.1"
127.0.0.1 - - [2012-01-22 14:55:41] "DELETE / HTTP/1.1" 405 185 "-" "python-requests/0.9.1"
127.0.0.1 - - [2012-01-22 14:55:46] "16 / HTTP/1.1" 405 181 "-" "python-requests/0.9.1"
127.0.0.1 - - [2012-01-22 14:55:50] "8 / HTTP/1.1" 405 180 "-" "python-requests/0.9.1"
127.0.0.1 - - [2012-01-22 14:56:13] "HEAD / HTTP/1.1" 200 0 "-" "python-requests/0.9.1"为了完整起见,这是我正在运行的脚本:
from gevent.wsgi import WSGIServer
from flask import Flask
app = Flask(__name__)
app.debug = True
@app.route("/")
def hello():
return 'hello'
port = 5000
http_server = WSGIServer(('', port), app)
http_server.serve_forever()会发生什么事?
编辑:
我使用的是gevent版本: 0.13.0
发布于 2012-01-22 18:07:22
Libevent对HTTP方法的支持有限,支持哪些HTTP方法取决于libevent版本。为什么您有一个数字而不是一个方法,这显然是一个错误。是因为您正在构建并链接gevent的不同版本吗?
你能试着切换到gevent.pywsgi吗?这将以牺牲一些性能来解决这个问题。
此外,gevent的1.0版本也有许多很大的改进。你可以在那里找到它:http://code.google.com/p/gevent/downloads/list
https://stackoverflow.com/questions/8962141
复制相似问题