export all the required psgi.* vars and all of the supported psgix.*

This commit is contained in:
roberto@sirius
2011-05-01 15:37:25 +02:00
parent 7f443fdd05
commit 694517bbe7
3 changed files with 61 additions and 1 deletions
+58 -1
View File
@@ -302,8 +302,60 @@ int uwsgi_perl_request(struct wsgi_request *wsgi_req) {
i++;
}
// psgi.version
AV *av = newAV();
av_store( av, 0, newSViv(1));
av_store( av, 1, newSViv(1));
if (!hv_store(env, "psgi.version", 12, newRV((SV *)av ), 0)) goto clear;
if (uwsgi.numproc > 1) {
if (!hv_store(env, "psgi.multiprocess", 17, &PL_sv_yes, 0)) goto clear;
}
else {
if (!hv_store(env, "psgi.multiprocess", 17, &PL_sv_no, 0)) goto clear;
}
if (uwsgi.threads > 1) {
if (!hv_store(env, "psgi.multithread", 16, &PL_sv_yes, 0)) goto clear;
}
else {
if (!hv_store(env, "psgi.multithread", 16, &PL_sv_no, 0)) goto clear;
}
if (!hv_store(env, "psgi.run_once", 13, &PL_sv_no, 0)) goto clear;
#ifdef UWSGI_ASYNC
if (uwsgi.async > 1) {
if (!hv_store(env, "psgi.nonblocking", 16, &PL_sv_yes, 0)) goto clear;
}
else {
#else
if (!hv_store(env, "psgi.nonblocking", 16, &PL_sv_no, 0)) goto clear;
#endif
#ifdef UWSGI_ASYNC
}
#endif
if (!hv_store(env, "psgi.streaming", 14, &PL_sv_yes, 0)) goto clear;
SV *us;
// psgi.url_scheme, honour HTTPS var or UWSGI_SCHEME
if (wsgi_req->scheme_len > 0) {
us = newSVpv(wsgi_req->scheme, wsgi_req->scheme_len);
}
else if (wsgi_req->https_len > 0) {
if (!strncasecmp(wsgi_req->https, "on", 2) || wsgi_req->https[0] == '1') {
us = newSVpv("https", 5);
}
else {
us = newSVpv("http", 4);
}
}
else {
us = newSVpv("http", 4);
}
SV *us = newSVpv("http", 4);
if (!hv_store(env, "psgi.url_scheme", 15, us, 0)) goto clear;
@@ -330,6 +382,9 @@ int uwsgi_perl_request(struct wsgi_request *wsgi_req) {
SV *pi = SvREFCNT_inc(POPs);
if (!hv_store(env, "psgi.input", 10, pi, 0)) goto clear;
if (!hv_store(env, "psgix.io", 8, pi, 0)) goto clear;
if (!hv_store(env, "psgix.input.buffered", 20, &PL_sv_no, 0)) goto clear;
PUSHMARK(SP);
@@ -350,6 +405,8 @@ int uwsgi_perl_request(struct wsgi_request *wsgi_req) {
SV *pe = SvREFCNT_inc(POPs);
if (!hv_store(env, "psgi.errors", 11, pe, 0)) goto clear;
PUSHMARK(SP);
XPUSHs( sv_2mortal(newRV((SV *)env )) );
+2
View File
@@ -531,6 +531,7 @@ void wsgi_req_setup(struct wsgi_request *wsgi_req, int async_id, struct uwsgi_so
}
#ifdef UWSGI_ASYNC
int wsgi_req_async_recv(struct wsgi_request *wsgi_req) {
UWSGI_SET_IN_REQUEST;
@@ -553,6 +554,7 @@ int wsgi_req_async_recv(struct wsgi_request *wsgi_req) {
return 0;
}
#endif
int wsgi_req_recv(struct wsgi_request *wsgi_req) {
+1
View File
@@ -1916,3 +1916,4 @@ void uwsgi_close_all_sockets(void);
struct uwsgi_string_list *uwsgi_string_new_list(struct uwsgi_string_list **, char *);
void uwsgi_string_del_list(struct uwsgi_string_list **, struct uwsgi_string_list *);