~ubuntu-branches/ubuntu/saucy/uwsgi/saucy

« back to all changes in this revision

Viewing changes to plugins/rack/rack_plugin.c

  • Committer: Package Import Robot
  • Author(s): Janos Guljas
  • Date: 2012-04-30 17:35:22 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120430173522-qucwu1au3s9bflhb
Tags: 1.2+dfsg-1
New upstream release.

Show diffs side-by-side

added added

removed removed

Lines of Context:
325
325
        
326
326
}
327
327
 
 
328
static void rack_hack_dollar_zero(VALUE name, ID id) {
 
329
        ur.dollar_zero = rb_obj_as_string(name);
 
330
        rb_obj_taint(ur.dollar_zero);
 
331
}
 
332
 
328
333
int uwsgi_rack_init(){
329
334
 
330
335
        struct http_status_codes *http_sc;
357
362
 
358
363
        ruby_script("uwsgi");
359
364
 
 
365
        ur.dollar_zero = rb_str_new2("uwsgi");
 
366
        rb_define_hooked_variable("$0", &ur.dollar_zero, 0, rack_hack_dollar_zero);
 
367
        rb_define_hooked_variable("$PROGRAM_NAME", &ur.dollar_zero, 0, rack_hack_dollar_zero);
 
368
 
360
369
        ur.signals_protector = rb_ary_new();
361
370
        ur.rpc_protector = rb_ary_new();
362
371
        rb_gc_register_address(&ur.signals_protector);
520
529
static VALUE send_body(VALUE obj) {
521
530
 
522
531
        struct wsgi_request *wsgi_req = current_wsgi_req();
523
 
        ssize_t len = 0;
524
532
 
525
533
        //uwsgi_log("sending body\n");
526
534
        if (TYPE(obj) == T_STRING) {
527
 
                len = wsgi_req->socket->proto_write( wsgi_req, RSTRING_PTR(obj), RSTRING_LEN(obj));
 
535
                wsgi_req->response_size += wsgi_req->socket->proto_write( wsgi_req, RSTRING_PTR(obj), RSTRING_LEN(obj));
528
536
        }
529
537
        else {
530
538
                uwsgi_log("UNMANAGED BODY TYPE %d\n", TYPE(obj));
531
539
        }
532
540
 
533
 
        wsgi_req->response_size += len;
534
 
 
535
541
        return Qnil;
536
542
}
537
543
 
712
718
        VALUE dws_wr = Data_Wrap_Struct(ur.rb_uwsgi_io_class, 0, 0, wsgi_req);
713
719
 
714
720
        if (wsgi_req->async_post) {
715
 
                rb_hash_aset(env, rb_str_new2("rack.input"), rb_funcall( rb_const_get(rb_cObject, rb_intern("IO")), rb_intern("new"), 2, INT2NUM(fileno(wsgi_req->async_post)), rb_str_new("r",1) ));
 
721
                rb_hash_aset(env, rb_str_new2("rack.input"), rb_funcall( rb_const_get(rb_cObject, rb_intern("IO")), rb_intern("new"), 2, INT2NUM(fileno((FILE*)wsgi_req->async_post)), rb_str_new("r",1) ));
716
722
        }
717
723
        else {
718
724
                rb_hash_aset(env, rb_str_new2("rack.input"), rb_funcall(ur.rb_uwsgi_io_class, rb_intern("new"), 1, dws_wr ));
765
771
                wsgi_req->hvec[5].iov_base = (char *) "\r\n";
766
772
                wsgi_req->hvec[5].iov_len = 2 ;
767
773
 
768
 
                if ( !(wsgi_req->headers_size = wsgi_req->socket->proto_writev_header(wsgi_req, wsgi_req->hvec, 6)) ) {
769
 
                        uwsgi_error("writev()");
770
 
                }
 
774
                wsgi_req->headers_size = wsgi_req->socket->proto_writev_header(wsgi_req, wsgi_req->hvec, 6);
771
775
 
772
776
                headers = RARRAY_PTR(ret)[1] ;
773
777
                if (rb_respond_to( headers, rb_intern("each") )) {
778
782
                        }
779
783
                }
780
784
 
781
 
                if (wsgi_req->socket->proto_write(wsgi_req, (char *)"\r\n", 2) != 2) {
782
 
                        uwsgi_error("write()");
783
 
                }
 
785
                wsgi_req->socket->proto_write(wsgi_req, (char *)"\r\n", 2);
784
786
 
785
787
                body = RARRAY_PTR(ret)[2] ;
786
788