rhebok 0.0.2 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Changes +4 -0
- data/ext/rhebok/rhebok.c +17 -11
- data/lib/rack/handler/rhebok.rb +3 -2
- data/lib/rhebok/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e57b88c70418eccd0131a3798c093e5f121783df
|
4
|
+
data.tar.gz: d483fa40f2b94af141e1a7674bb9ee01d3c0b326
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 56a9bedb5bdfa63745fc1bcd46ef349173a144c911cfbb2b08570d81051ebe6bdad4c2f39a1ad98892428b6093ebb27b9d0b7e6e83c22856b6939ff3a77d30ee
|
7
|
+
data.tar.gz: 80dbef163aa4804173847972c5c2dbdb5097775a24e3127cebee33efdd460326e0a6d84d1e574d6170214dbafea110c3cb5280e1945ecb8dc4e6d187ea90ea61
|
data/Changes
CHANGED
data/ext/rhebok/rhebok.c
CHANGED
@@ -120,6 +120,7 @@ static VALUE server_protocol_key;
|
|
120
120
|
static VALUE query_string_key;
|
121
121
|
static VALUE remote_addr_key;
|
122
122
|
static VALUE remote_port_key;
|
123
|
+
static VALUE path_info_key;
|
123
124
|
|
124
125
|
struct common_header {
|
125
126
|
const char * name;
|
@@ -206,7 +207,6 @@ int store_path_info(VALUE env, const char* src, size_t src_len) {
|
|
206
207
|
size_t dlen = 0, i = 0;
|
207
208
|
char *d;
|
208
209
|
char s2, s3;
|
209
|
-
|
210
210
|
d = (char*)malloc(src_len * 3 + 1);
|
211
211
|
for (i = 0; i < src_len; i++ ) {
|
212
212
|
if ( src[i] == '%' ) {
|
@@ -230,7 +230,7 @@ int store_path_info(VALUE env, const char* src, size_t src_len) {
|
|
230
230
|
}
|
231
231
|
}
|
232
232
|
d[dlen]='0';
|
233
|
-
rb_hash_aset(env,
|
233
|
+
rb_hash_aset(env, path_info_key, rb_str_new(d, dlen));
|
234
234
|
free(d);
|
235
235
|
return dlen;
|
236
236
|
}
|
@@ -573,7 +573,7 @@ VALUE rhe_write_timeout(VALUE self, VALUE fileno, VALUE buf, VALUE len, VALUE of
|
|
573
573
|
char* d;
|
574
574
|
ssize_t rv;
|
575
575
|
|
576
|
-
d =
|
576
|
+
d = RSTRING_PTR(buf);
|
577
577
|
rv = _write_timeout(NUM2INT(fileno), NUM2DBL(timeout), &d[NUM2LONG(offset)], NUM2LONG(len));
|
578
578
|
if ( rv < 0 ) {
|
579
579
|
return Qnil;
|
@@ -589,7 +589,7 @@ VALUE rhe_write_all(VALUE self, VALUE fileno, VALUE buf, VALUE offsetv, VALUE ti
|
|
589
589
|
ssize_t rv = 0;
|
590
590
|
ssize_t written = 0;
|
591
591
|
|
592
|
-
d =
|
592
|
+
d = RSTRING_PTR(buf);
|
593
593
|
buf_len = RSTRING_LEN(buf);
|
594
594
|
|
595
595
|
written = 0;
|
@@ -608,6 +608,7 @@ VALUE rhe_write_all(VALUE self, VALUE fileno, VALUE buf, VALUE offsetv, VALUE ti
|
|
608
608
|
|
609
609
|
static
|
610
610
|
int my_hash_keys(VALUE key, VALUE val, VALUE ary) {
|
611
|
+
char * d = RSTRING_PTR(key);
|
611
612
|
rb_ary_push(ary, key);
|
612
613
|
return ST_CONTINUE;
|
613
614
|
}
|
@@ -620,8 +621,8 @@ VALUE rhe_close(VALUE self, VALUE fileno) {
|
|
620
621
|
|
621
622
|
static
|
622
623
|
VALUE rhe_write_response(VALUE self, VALUE filenov, VALUE timeoutv, VALUE status_codev, VALUE headers, VALUE body) {
|
623
|
-
ssize_t hlen;
|
624
|
-
ssize_t blen;
|
624
|
+
ssize_t hlen = 0;
|
625
|
+
ssize_t blen = 0;
|
625
626
|
|
626
627
|
ssize_t len;
|
627
628
|
ssize_t rv = 0;
|
@@ -639,15 +640,17 @@ VALUE rhe_write_response(VALUE self, VALUE filenov, VALUE timeoutv, VALUE status
|
|
639
640
|
char * key;
|
640
641
|
const char * message;
|
641
642
|
|
643
|
+
|
642
644
|
int fileno = NUM2INT(filenov);
|
643
645
|
double timeout = NUM2DBL(timeoutv);
|
644
646
|
int status_code = NUM2INT(status_codev);
|
645
647
|
|
646
648
|
arr = rb_ary_new();
|
649
|
+
RB_GC_GUARD(arr);
|
647
650
|
rb_hash_foreach(headers, my_hash_keys, arr);
|
648
651
|
hlen = RARRAY_LEN(arr);
|
649
652
|
blen = RARRAY_LEN(body);
|
650
|
-
iovcnt = 10 + (hlen *
|
653
|
+
iovcnt = 10 + (hlen * 4) + blen;
|
651
654
|
|
652
655
|
{
|
653
656
|
struct iovec v[iovcnt]; // Needs C99 compiler
|
@@ -680,7 +683,7 @@ VALUE rhe_write_response(VALUE self, VALUE filenov, VALUE timeoutv, VALUE status
|
|
680
683
|
date_pushed = 0;
|
681
684
|
for ( i = 0; i < hlen; i++ ) {
|
682
685
|
key_obj = rb_ary_entry(arr, i);
|
683
|
-
key =
|
686
|
+
key = RSTRING_PTR(key_obj);
|
684
687
|
len = RSTRING_LEN(key_obj);
|
685
688
|
if ( strncasecmp(key,"Connection",len) == 0 ) {
|
686
689
|
continue;
|
@@ -699,7 +702,7 @@ VALUE rhe_write_response(VALUE self, VALUE filenov, VALUE timeoutv, VALUE status
|
|
699
702
|
iovcnt++;
|
700
703
|
/* value */
|
701
704
|
val_obj = rb_hash_aref(headers, key_obj);
|
702
|
-
v[iovcnt].iov_base =
|
705
|
+
v[iovcnt].iov_base = RSTRING_PTR(val_obj);
|
703
706
|
v[iovcnt].iov_len = RSTRING_LEN(val_obj);
|
704
707
|
iovcnt++;
|
705
708
|
v[iovcnt].iov_base = "\r\n";
|
@@ -717,9 +720,9 @@ VALUE rhe_write_response(VALUE self, VALUE filenov, VALUE timeoutv, VALUE status
|
|
717
720
|
v[iovcnt].iov_len = sizeof("\r\n") - 1;
|
718
721
|
iovcnt++;
|
719
722
|
|
720
|
-
for (i=0; i
|
723
|
+
for ( i=0; i<blen; i++) {
|
721
724
|
val_obj = rb_ary_entry(body, i);
|
722
|
-
v[iovcnt].iov_base =
|
725
|
+
v[iovcnt].iov_base = RSTRING_PTR(val_obj);
|
723
726
|
v[iovcnt].iov_len = RSTRING_LEN(val_obj);
|
724
727
|
iovcnt++;
|
725
728
|
}
|
@@ -747,6 +750,7 @@ VALUE rhe_write_response(VALUE self, VALUE filenov, VALUE timeoutv, VALUE status
|
|
747
750
|
}
|
748
751
|
}
|
749
752
|
}
|
753
|
+
|
750
754
|
if ( rv < 0 ) {
|
751
755
|
return Qnil;
|
752
756
|
}
|
@@ -757,6 +761,8 @@ void Init_rhebok()
|
|
757
761
|
{
|
758
762
|
request_method_key = rb_obj_freeze(rb_str_new2("REQUEST_METHOD"));
|
759
763
|
rb_gc_register_address(&request_method_key);
|
764
|
+
path_info_key = rb_obj_freeze(rb_str_new2("PATH_INFO"));
|
765
|
+
rb_gc_register_address(&path_info_key);
|
760
766
|
request_uri_key = rb_obj_freeze(rb_str_new2("REQUEST_URI"));
|
761
767
|
rb_gc_register_address(&request_uri_key);
|
762
768
|
script_name_key = rb_obj_freeze(rb_str_new2("SCRIPT_NAME"));
|
data/lib/rack/handler/rhebok.rb
CHANGED
@@ -179,9 +179,9 @@ module Rack
|
|
179
179
|
|
180
180
|
status_code, headers, body = app.call(env)
|
181
181
|
if body.instance_of?(Array) then
|
182
|
-
::Rhebok.write_response(connection, @options[:Timeout], status_code, headers, body)
|
182
|
+
::Rhebok.write_response(connection, @options[:Timeout], status_code, headers, body)
|
183
183
|
else
|
184
|
-
::Rhebok.write_response(connection, @options[:Timeout], status_code, headers, [])
|
184
|
+
::Rhebok.write_response(connection, @options[:Timeout], status_code, headers, [])
|
185
185
|
body.each do |part|
|
186
186
|
ret = ::Rhebok.write_all(connection, part, 0, @options[:Timeout])
|
187
187
|
if ret == nil then
|
@@ -189,6 +189,7 @@ module Rack
|
|
189
189
|
end
|
190
190
|
end #body.each
|
191
191
|
end
|
192
|
+
#p [env,status_code,headers,body]
|
192
193
|
ensure
|
193
194
|
if buffer.instance_of?(Tempfile)
|
194
195
|
buffer.close!
|
data/lib/rhebok/version.rb
CHANGED