kcar 0.3.1 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/GIT-VERSION-GEN +1 -1
- data/ext/kcar/kcar.rl +19 -0
- data/lib/kcar/response.rb +1 -0
- data/test/test_response.rb +6 -1
- metadata +40 -52
data/GIT-VERSION-GEN
CHANGED
data/ext/kcar/kcar.rl
CHANGED
@@ -493,6 +493,24 @@ static VALUE body_bytes_left(VALUE self)
|
|
493
493
|
return Qnil;
|
494
494
|
}
|
495
495
|
|
496
|
+
/**
|
497
|
+
* call-seq:
|
498
|
+
* parser.body_bytes_left = Integer
|
499
|
+
*
|
500
|
+
* Sets the number of bytes left to download for HTTP responses
|
501
|
+
* with "Content-Length". This raises RuntimeError for chunked
|
502
|
+
* responses.
|
503
|
+
*/
|
504
|
+
static VALUE body_bytes_left_set(VALUE self, VALUE bytes)
|
505
|
+
{
|
506
|
+
struct http_parser *hp = data_get(self);
|
507
|
+
|
508
|
+
if (HP_FL_TEST(hp, CHUNKED))
|
509
|
+
rb_raise(rb_eRuntimeError, "body_bytes_left= is not for chunked bodies");
|
510
|
+
hp->len.content = NUM2OFFT(bytes);
|
511
|
+
return bytes;
|
512
|
+
}
|
513
|
+
|
496
514
|
/**
|
497
515
|
* Document-method: chunked
|
498
516
|
* call-seq:
|
@@ -667,6 +685,7 @@ void Init_kcar_ext(void)
|
|
667
685
|
rb_define_method(cParser, "trailers", headers, 2);
|
668
686
|
rb_define_method(cParser, "filter_body", filter_body, 2);
|
669
687
|
rb_define_method(cParser, "body_bytes_left", body_bytes_left, 0);
|
688
|
+
rb_define_method(cParser, "body_bytes_left=", body_bytes_left_set, 1);
|
670
689
|
rb_define_method(cParser, "body_eof?", body_eof, 0);
|
671
690
|
rb_define_method(cParser, "keepalive?", keepalive, 0);
|
672
691
|
rb_define_method(cParser, "chunked?", chunked, 0);
|
data/lib/kcar/response.rb
CHANGED
data/test/test_response.rb
CHANGED
@@ -28,6 +28,7 @@ class TestSession < Test::Unit::TestCase
|
|
28
28
|
assert_nothing_raised { body.each { |chunk| tmp << chunk.dup } }
|
29
29
|
assert_equal [], tmp
|
30
30
|
assert @response.parser.keepalive?
|
31
|
+
assert @response.parser.body_eof?
|
31
32
|
body.close
|
32
33
|
|
33
34
|
status, headers, body = @response.rack
|
@@ -135,6 +136,8 @@ class TestSession < Test::Unit::TestCase
|
|
135
136
|
tmp = []
|
136
137
|
assert body.parser.keepalive?
|
137
138
|
assert_nothing_raised { body.each { |chunk| tmp << chunk.dup } }
|
139
|
+
assert body.parser.body_eof?
|
140
|
+
assert body.parser.keepalive?
|
138
141
|
assert_equal [ "HI" ], tmp
|
139
142
|
_, status = Process.waitpid2(pid)
|
140
143
|
assert status.success?
|
@@ -171,6 +174,8 @@ class TestSession < Test::Unit::TestCase
|
|
171
174
|
tmp = []
|
172
175
|
assert body.parser.keepalive?
|
173
176
|
assert_nothing_raised { body.each { |chunk| tmp << chunk.dup } }
|
177
|
+
assert body.parser.keepalive?
|
178
|
+
assert body.parser.body_eof?
|
174
179
|
assert_equal [ "abcde" ], tmp
|
175
180
|
_, status = Process.waitpid2(pid)
|
176
181
|
assert status.success?
|
@@ -508,7 +513,7 @@ class TestSession < Test::Unit::TestCase
|
|
508
513
|
assert @c.closed?
|
509
514
|
end
|
510
515
|
|
511
|
-
def
|
516
|
+
def test_rack_preserve_chunk_no_keepalive_2
|
512
517
|
s = "HTTP/1.1 200 OK\r\n"
|
513
518
|
s << "Connection: close\r\n"
|
514
519
|
s << "Content-Length: 666\r\n"
|
metadata
CHANGED
@@ -1,48 +1,44 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: kcar
|
3
|
-
version: !ruby/object:Gem::Version
|
4
|
-
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.0
|
5
5
|
prerelease:
|
6
|
-
segments:
|
7
|
-
- 0
|
8
|
-
- 3
|
9
|
-
- 1
|
10
|
-
version: 0.3.1
|
11
6
|
platform: ruby
|
12
|
-
authors:
|
7
|
+
authors:
|
13
8
|
- kcar hackers
|
14
9
|
autorequire:
|
15
10
|
bindir: bin
|
16
11
|
cert_chain: []
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2012-10-26 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
21
15
|
name: wrongdoc
|
22
|
-
|
23
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
24
17
|
none: false
|
25
|
-
requirements:
|
18
|
+
requirements:
|
26
19
|
- - ~>
|
27
|
-
- !ruby/object:Gem::Version
|
28
|
-
|
29
|
-
segments:
|
30
|
-
- 1
|
31
|
-
- 5
|
32
|
-
version: "1.5"
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '1.5'
|
33
22
|
type: :development
|
34
|
-
|
35
|
-
|
36
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.5'
|
30
|
+
description: ! 'kcar features an HTTP parser that will convert a bytestream into a
|
31
|
+
|
37
32
|
3-element array suitable for use as a Rack response. It is IO interface
|
33
|
+
|
38
34
|
agnostic, so it may be used with HTTP streams over Unix domain sockets,
|
39
|
-
|
35
|
+
|
36
|
+
regular files, FIFOs, StringIOs as well as traditional TCP sockets.'
|
40
37
|
email: kcar@librelist.org
|
41
38
|
executables: []
|
42
|
-
|
43
|
-
extensions:
|
39
|
+
extensions:
|
44
40
|
- ext/kcar/extconf.rb
|
45
|
-
extra_rdoc_files:
|
41
|
+
extra_rdoc_files:
|
46
42
|
- LICENSE
|
47
43
|
- README
|
48
44
|
- TODO
|
@@ -52,7 +48,7 @@ extra_rdoc_files:
|
|
52
48
|
- lib/kcar/parser.rb
|
53
49
|
- lib/kcar/response.rb
|
54
50
|
- ext/kcar/kcar.c
|
55
|
-
files:
|
51
|
+
files:
|
56
52
|
- .document
|
57
53
|
- .gitignore
|
58
54
|
- .manifest
|
@@ -84,40 +80,32 @@ files:
|
|
84
80
|
- test/test_response.rb
|
85
81
|
homepage: http://bogomips.org/kcar/
|
86
82
|
licenses: []
|
87
|
-
|
88
83
|
post_install_message:
|
89
|
-
rdoc_options:
|
84
|
+
rdoc_options:
|
90
85
|
- -t
|
91
86
|
- kcar - bytestream to Rack response converter
|
92
87
|
- -W
|
93
88
|
- http://bogomips.org/kcar.git/tree/%s
|
94
|
-
require_paths:
|
89
|
+
require_paths:
|
95
90
|
- lib
|
96
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
91
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
97
92
|
none: false
|
98
|
-
requirements:
|
99
|
-
- -
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
|
102
|
-
|
103
|
-
- 0
|
104
|
-
version: "0"
|
105
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ! '>='
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
106
98
|
none: false
|
107
|
-
requirements:
|
108
|
-
- -
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
|
111
|
-
segments:
|
112
|
-
- 0
|
113
|
-
version: "0"
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
114
103
|
requirements: []
|
115
|
-
|
116
104
|
rubyforge_project: rainbows
|
117
|
-
rubygems_version: 1.8.
|
105
|
+
rubygems_version: 1.8.23
|
118
106
|
signing_key:
|
119
107
|
specification_version: 3
|
120
108
|
summary: bytestream to Rack response converter
|
121
|
-
test_files:
|
109
|
+
test_files:
|
122
110
|
- test/test_parser.rb
|
123
111
|
- test/test_response.rb
|