Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove HTTP_CONTENT_LENGTH and HTTP_CONTENT_TYPE from rack/psgi autom…

…atically
  • Loading branch information...
commit 3bb43745b874f22fe2f5259849ff7c450f597685 1 parent beb12b6
roberto@precise64 authored
View
3  buildconf/cgi.ini
@@ -0,0 +1,3 @@
+[uwsgi]
+main_plugin = cgi
+inherit = base
View
41 plugins/corerouter/corerouter.c
@@ -641,6 +641,31 @@ void uwsgi_corerouter_loop(int id, void *data) {
}
+int uwsgi_courerouter_has_has_backends(struct uwsgi_corerouter *ucr) {
+
+ if (ucr->has_backends) return 1;
+
+ // check if the router has configured backends
+ if (ucr->use_cache ||
+ ucr->pattern ||
+ ucr->has_subscription_sockets ||
+ ucr->base ||
+ (ucr->code_string_code && ucr->code_string_function) ||
+ ucr->to_socket ||
+ ucr->static_nodes ||
+ ucr->use_cluster
+#ifdef UWSGI_SCTP
+ || ucr->has_sctp_sockets
+#endif
+ ) {
+ return 1;
+ }
+
+
+ return 0;
+
+}
+
int uwsgi_corerouter_init(struct uwsgi_corerouter *ucr) {
int i;
@@ -656,21 +681,7 @@ int uwsgi_corerouter_init(struct uwsgi_corerouter *ucr) {
ucr->nevents = 64;
- // check if the router has configured backends
- if (ucr->use_cache ||
- ucr->pattern ||
- ucr->has_subscription_sockets ||
- ucr->base ||
- (ucr->code_string_code && ucr->code_string_function) ||
- ucr->to_socket ||
- ucr->static_nodes ||
- ucr->use_cluster
-#ifdef UWSGI_SCTP
- || ucr->has_sctp_sockets
-#endif
- ) {
- ucr->has_backends = 1;
- }
+ ucr->has_backends = uwsgi_courerouter_has_has_backends(ucr);
uwsgi_corerouter_setup_sockets(ucr);
View
2  plugins/corerouter/cr.h
@@ -181,6 +181,8 @@ int uwsgi_cr_map_use_base(struct uwsgi_corerouter *, struct corerouter_session *
int uwsgi_cr_map_use_cs(struct uwsgi_corerouter *, struct corerouter_session *);
int uwsgi_cr_map_use_to(struct uwsgi_corerouter *, struct corerouter_session *);
int uwsgi_cr_map_use_static_nodes(struct uwsgi_corerouter *, struct corerouter_session *);
+
+int uwsgi_courerouter_has_has_backends(struct uwsgi_corerouter *);
#ifdef UWSGI_SCTP
int uwsgi_cr_map_use_sctp(struct fastrouter_session *, char **);
#endif
View
7 plugins/http/http.c
@@ -436,7 +436,7 @@ void uwsgi_http_switch_events(struct uwsgi_corerouter *ucr, struct corerouter_se
event_queue_add_fd_read(ucs->queue, cs->fd);
#endif
if (len <= 0) {
- // check for blocking operation non non-blocking socket
+ // check for blocking operation non on-blocking socket
if (len < 0 && cs->ugs->nb && errno == EINPROGRESS) break;
corerouter_close_session(ucr, cs);
break;
@@ -470,6 +470,7 @@ void uwsgi_http_switch_events(struct uwsgi_corerouter *ucr, struct corerouter_se
if (ucr->mapper(ucr, cs))
break;
+
// no address found
if (!cs->instance_address_len) {
// if fallback nodes are configured, trigger them
@@ -888,12 +889,12 @@ int http_init() {
uhttp.cr.session_size = sizeof(struct http_session);
uhttp.cr.switch_events = uwsgi_http_switch_events;
uhttp.cr.alloc_session = http_alloc_session;
- uwsgi_corerouter_init((struct uwsgi_corerouter *) &uhttp);
- if (uhttp.cr.has_sockets && !uwsgi.sockets && !uhttp.cr.has_backends) {
+ if (uhttp.cr.has_sockets && !uwsgi.sockets && !uwsgi_courerouter_has_has_backends(&uhttp.cr)) {
uwsgi_new_socket(uwsgi_concat2("127.0.0.1:0", ""));
uhttp.cr.use_socket = 1;
uhttp.cr.socket_num = 0;
}
+ uwsgi_corerouter_init((struct uwsgi_corerouter *) &uhttp);
return 0;
}
View
3  plugins/psgi/psgi_plugin.c
@@ -298,6 +298,9 @@ SV *build_psgi_env(struct wsgi_request *wsgi_req) {
SV *pe = uwsgi_perl_obj_new("uwsgi::error", 12);
if (!hv_store(env, "psgi.errors", 11, pe, 0)) goto clear;
+ (void) hv_delete(env, "HTTP_CONTENT_LENGTH", 19, G_DISCARD);
+ (void) hv_delete(env, "HTTP_CONTENT_TYPE", 17, G_DISCARD);
+
return newRV_noinc((SV *)env);
clear:
View
4 plugins/rack/rack_plugin.c
@@ -726,6 +726,10 @@ int uwsgi_rack_request(struct wsgi_request *wsgi_req) {
rb_hash_aset(env, rb_str_new2("rack.errors"), rb_funcall( rb_const_get(rb_cObject, rb_intern("IO")), rb_intern("new"), 2, INT2NUM(2), rb_str_new("w",1) ));
+ // remove HTTP_CONTENT_LENGTH and HTTP_CONTENT_TYPE
+ rb_hash_delete(env, rb_str_new2("HTTP_CONTENT_LENGTH"));
+ rb_hash_delete(env, rb_str_new2("HTTP_CONTENT_TYPE"));
+
ret = rb_protect( call_dispatch, env, &error);
if (error) {
uwsgi_ruby_exception();
Please sign in to comment.
Something went wrong with that request. Please try again.