uWSGI 0.9.9-rc1

This commit is contained in:
roberto@debian32
2011-08-19 09:57:58 +02:00
parent eebe757c16
commit d5e6412b20
3 changed files with 70 additions and 3 deletions
+13 -1
View File
@@ -838,17 +838,29 @@ PyObject *py_uwsgi_advanced_sendfile(PyObject * self, PyObject * args) {
return NULL;
}
if (PyString_Check(what)) {
filename = PyString_AsString(what);
fd = open(filename, O_RDONLY);
if (fd < 0) {
uwsgi_error("open");
uwsgi_error_open(filename);
goto clear;
}
}
#ifdef PYTHREE
else if (PyUnicode_Check(what)) {
filename = PyBytes_AsString(PyUnicode_AsASCIIString(what));
fd = open(filename, O_RDONLY);
if (fd < 0) {
uwsgi_error_open(filename);
goto clear;
}
}
#endif
else {
fd = PyObject_AsFileDescriptor(what);
if (fd < 0)
-2
View File
@@ -1423,8 +1423,6 @@ int uwsgi_read_whole_body_in_mem(struct wsgi_request *wsgi_req, char *buf) {
post_remains -= len;
}
uwsgi_log("%.*s\n", wsgi_req->post_cl, buf);
return 1;
}
+57
View File
@@ -0,0 +1,57 @@
import uwsgi
import os
def xsendfile(e, sr):
sr('200 OK', [('Content-Type', 'image/png'), ('X-Sendfile', os.path.abspath('logo_uWSGI.png'))])
return b''
def serve_logo(e, sr):
sr('200 OK', [('Content-Type', 'image/png')])
return uwsgi.sendfile('logo_uWSGI.png')
def serve_options(e, sr):
sr('200 OK', [('Content-Type', 'text/html')])
for opt in range(0,256):
body = "{opt} = {optvalue}<br/>".format(opt=opt, optvalue=uwsgi.get_option(opt))
yield bytes(body.encode('ascii'))
def serve_config(e, sr):
sr('200 OK', [('Content-Type', 'text/html')])
for opt in uwsgi.opt.keys():
body = "{opt} = {optvalue}<br/>".format(opt=opt, optvalue=uwsgi.opt[opt].decode('ascii'))
yield bytes(body.encode('ascii'))
routes = {}
routes['/xsendfile'] = xsendfile
routes['/logo'] = serve_logo
routes['/config'] = serve_config
routes['/options'] = serve_options
def application(env, start_response):
if env['PATH_INFO'] in routes:
return routes[env['PATH_INFO']](env, start_response)
start_response('200 OK', [('Content-Type', 'text/html')])
body = """
<img src="/logo"/> version {version}<br/>
<hr size="1"/>
Configuration<br/>
<iframe src="/config"></iframe><br/>
<br/>
Dynamic options<br/>
<iframe src="/options"></iframe><br/>
""".format(version=uwsgi.version.decode('ascii'))
return bytes(body.encode('ascii'))