kcar 0.1.0 → 0.1.1
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.
- data/ChangeLog +43 -80
- data/GIT-VERSION-FILE +1 -1
- data/GIT-VERSION-GEN +1 -1
- data/GNUmakefile +1 -1
- data/NEWS +10 -0
- data/README +11 -0
- data/ext/kcar/kcar.c +7 -0
- data/ext/kcar/kcar.rl +7 -0
- data/kcar.gemspec +2 -2
- data/lib/kcar/response.rb +9 -6
- data/lib/kcar.rb +2 -2
- data/test/test_response.rb +63 -0
- metadata +19 -7
data/ChangeLog
CHANGED
@@ -1,110 +1,73 @@
|
|
1
|
-
ChangeLog from git://git.bogomips.org/kcar.git ()
|
1
|
+
ChangeLog from git://git.bogomips.org/kcar.git (v0.1.0..v0.1.1)
|
2
2
|
|
3
|
-
commit
|
3
|
+
commit 2b264a464707e448275883ac198d7ead7eaeadb9
|
4
4
|
Author: Eric Wong <normalperson@yhbt.net>
|
5
|
-
Date:
|
5
|
+
Date: Sat Jul 24 23:51:48 2010 +0000
|
6
6
|
|
7
|
-
|
8
|
-
|
9
|
-
commit ee89a72720c8c035eebf2389e09dd28c788551d8
|
10
|
-
Author: Eric Wong <normalperson@yhbt.net>
|
11
|
-
Date: Wed Apr 28 15:12:19 2010 -0700
|
12
|
-
|
13
|
-
autoload Kcar::Response, document VERSION constant
|
7
|
+
kcar 0.1.1
|
14
8
|
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
Date: Wed Apr 28 15:10:38 2010 -0700
|
21
|
-
|
22
|
-
kcar/parser: magic comments for binary encoding
|
9
|
+
Our handling of pipelined identity (not chunked) responses
|
10
|
+
did not properly reset our internal buffer, causing HTTP
|
11
|
+
header parsing to fail for the second response as the buffer
|
12
|
+
still contained the last part of the body from the previous
|
13
|
+
response.
|
23
14
|
|
24
|
-
|
25
|
-
encoding as that's how HTTP processing is done.
|
15
|
+
There are also minor documentation updates and cleanups.
|
26
16
|
|
27
|
-
commit
|
17
|
+
commit 558513bdeaac2bd1feb9df46c3ba09616b1be2bf
|
28
18
|
Author: Eric Wong <normalperson@yhbt.net>
|
29
|
-
Date:
|
19
|
+
Date: Sat Jul 24 23:43:08 2010 +0000
|
30
20
|
|
31
|
-
|
32
|
-
|
33
|
-
commit 9d880bb373793f42c29cd77890663d62a1b9c578
|
34
|
-
Author: Eric Wong <normalperson@yhbt.net>
|
35
|
-
Date: Wed Apr 28 14:33:27 2010 -0700
|
36
|
-
|
37
|
-
add Kcar::Response#rack to give proper Rack responses
|
21
|
+
response: simplify trailers handling
|
38
22
|
|
39
|
-
|
40
|
-
|
41
|
-
without chunked encoding. So we'll unconditionally disable
|
42
|
-
unchunking and pass the response through as-is
|
43
|
-
|
44
|
-
commit 2a3a8ac8e64f5f02f87de268c9b2615437d16a96
|
45
|
-
Author: Eric Wong <normalperson@yhbt.net>
|
46
|
-
Date: Wed Apr 28 13:09:51 2010 -0700
|
23
|
+
Kcar::Parser#extract_trailers never returns a false/nil
|
24
|
+
value, so there's no reason to check for it.
|
47
25
|
|
48
|
-
|
49
|
-
|
50
|
-
commit b75e162e0b9b605a9b3033c3dbc616afcb08b4ad
|
51
|
-
Author: Eric Wong <normalperson@yhbt.net>
|
52
|
-
Date: Wed Apr 28 12:58:29 2010 -0700
|
53
|
-
|
54
|
-
Documentation prep for release
|
55
|
-
|
56
|
-
commit b85f1528667b3aaa699b37dcc362901e1e573b04
|
26
|
+
commit 62621af7c8724f5cc5cc3a6dfcd47eb6654286a5
|
57
27
|
Author: Eric Wong <normalperson@yhbt.net>
|
58
|
-
Date:
|
28
|
+
Date: Sat Jul 24 23:18:14 2010 +0000
|
59
29
|
|
60
|
-
|
30
|
+
response: fix handling of pipelined identity responses
|
61
31
|
|
62
|
-
|
63
|
-
|
32
|
+
When parsing a stream of multiple responses (when HTTP
|
33
|
+
pipelining is enabled), we did not properly reset our
|
34
|
+
internal buffer, causing failures when parsing the
|
35
|
+
second response.
|
64
36
|
|
65
|
-
commit
|
37
|
+
commit 35e3ad8134c39902b502e20d88246be2751767e1
|
66
38
|
Author: Eric Wong <normalperson@yhbt.net>
|
67
|
-
Date:
|
68
|
-
|
69
|
-
build + release infrastructure
|
39
|
+
Date: Sat Jul 24 21:38:40 2010 +0000
|
70
40
|
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
parser: avoid shadowing "key" variable
|
41
|
+
response: fix unreferenced constant
|
42
|
+
|
43
|
+
Oops :x
|
76
44
|
|
77
|
-
commit
|
45
|
+
commit 6224ff57ce2b95cd62ab01316dedcc106e6e4e6b
|
78
46
|
Author: Eric Wong <normalperson@yhbt.net>
|
79
|
-
Date:
|
47
|
+
Date: Sat Jul 24 20:44:03 2010 +0000
|
80
48
|
|
81
|
-
|
49
|
+
update README with Rubinius support
|
82
50
|
|
83
|
-
|
51
|
+
It has likely always worked.
|
84
52
|
|
85
|
-
commit
|
53
|
+
commit 856a8a7e061845d5db617cc407c92aabdb4679a0
|
86
54
|
Author: Eric Wong <normalperson@yhbt.net>
|
87
|
-
Date:
|
55
|
+
Date: Sun May 2 16:38:27 2010 -0700
|
88
56
|
|
89
|
-
|
57
|
+
document Kcar::Parser#chunked? method
|
90
58
|
|
91
|
-
commit
|
59
|
+
commit 7f1597ea01cac380393fb4d50e458204059beb24
|
92
60
|
Author: Eric Wong <normalperson@yhbt.net>
|
93
|
-
Date:
|
61
|
+
Date: Sun May 2 16:30:13 2010 -0700
|
94
62
|
|
95
|
-
|
63
|
+
update README with Gmane and mbox archive info
|
96
64
|
|
97
|
-
commit
|
65
|
+
commit 6b4bf45c0cab182462ed0c5c0d98fe11e1201b61
|
98
66
|
Author: Eric Wong <normalperson@yhbt.net>
|
99
|
-
Date:
|
67
|
+
Date: Wed Apr 28 22:26:45 2010 +0000
|
100
68
|
|
101
|
-
|
69
|
+
gemspec: fix authors and homepage info
|
102
70
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
commit f071a6f936ba0b22610b1f7ce68e414403f29996
|
107
|
-
Author: Eric Wong <normalperson@yhbt.net>
|
108
|
-
Date: Mon Apr 26 18:29:21 2010 -0700
|
109
|
-
|
110
|
-
initial
|
71
|
+
Oops, URLs should end with a trailing slash since I'm expecting
|
72
|
+
my webserver to load index.html. Also, it's "kcar hackers",
|
73
|
+
kcar did not write itself!
|
data/GIT-VERSION-FILE
CHANGED
@@ -1 +1 @@
|
|
1
|
-
GIT_VERSION = 0.1.
|
1
|
+
GIT_VERSION = 0.1.1
|
data/GIT-VERSION-GEN
CHANGED
data/GNUmakefile
CHANGED
@@ -54,7 +54,7 @@ NEWS: GIT-VERSION-FILE
|
|
54
54
|
latest: NEWS
|
55
55
|
@awk 'BEGIN{RS="=== ";ORS=""}NR==2{sub(/\n$$/,"");print RS""$$0 }' $<
|
56
56
|
|
57
|
-
SINCE =
|
57
|
+
SINCE = 0.1.0
|
58
58
|
ChangeLog: LOG_VERSION = \
|
59
59
|
$(shell git rev-parse -q "$(GIT_VERSION)" >/dev/null 2>&1 && \
|
60
60
|
echo $(GIT_VERSION) || git describe)
|
data/NEWS
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
+
=== 0.1.1 / 2010-07-25 00:03 UTC
|
2
|
+
|
3
|
+
Our handling of pipelined identity (not chunked) responses
|
4
|
+
did not properly reset our internal buffer, causing HTTP
|
5
|
+
header parsing to fail for the second response as the buffer
|
6
|
+
still contained the last part of the body from the previous
|
7
|
+
response.
|
8
|
+
|
9
|
+
There are also minor documentation updates and cleanups.
|
10
|
+
|
1
11
|
=== 0.1.0 / 2010-04-28 22:18 UTC
|
2
12
|
|
3
13
|
initial
|
data/README
CHANGED
@@ -19,6 +19,8 @@ A drop-in, Net::HTTP-compatible interface is planned.
|
|
19
19
|
* streaming interface for response bodies allows for incremental
|
20
20
|
processing of arbitrarily large responses.
|
21
21
|
|
22
|
+
* suppported under Ruby 1.8, 1.9 and Rubinuus
|
23
|
+
|
22
24
|
== Problems
|
23
25
|
|
24
26
|
* kcar is only lightly tested and is not yet aware of all quirks found in
|
@@ -84,3 +86,12 @@ don't email the git mailing list or maintainer with kcar patches.
|
|
84
86
|
|
85
87
|
All feedback (bug reports, user/development discussion, patches, pull
|
86
88
|
requests) go to the mailing list: mailto:kcar@librelist.com
|
89
|
+
|
90
|
+
The mailing list is mirrored to Gmane, all information about the
|
91
|
+
group is here:
|
92
|
+
|
93
|
+
http://gmane.org/info.php?group=gmane.comp.lang.ruby.kcar.general
|
94
|
+
|
95
|
+
Mailing list archives in mbox format may be downloaded here:
|
96
|
+
|
97
|
+
http://bogomips.org/kcar/archives/
|
data/ext/kcar/kcar.c
CHANGED
@@ -1339,6 +1339,13 @@ static VALUE body_bytes_left(VALUE self)
|
|
1339
1339
|
return Qnil;
|
1340
1340
|
}
|
1341
1341
|
|
1342
|
+
/**
|
1343
|
+
* Document-method: chunked
|
1344
|
+
* call-seq:
|
1345
|
+
* parser.chunked? => true or false
|
1346
|
+
*
|
1347
|
+
* This is used to detect if a response uses chunked Transfer-Encoding or not.
|
1348
|
+
*/
|
1342
1349
|
static VALUE chunked(VALUE self)
|
1343
1350
|
{
|
1344
1351
|
struct http_parser *hp = data_get(self);
|
data/ext/kcar/kcar.rl
CHANGED
@@ -467,6 +467,13 @@ static VALUE body_bytes_left(VALUE self)
|
|
467
467
|
return Qnil;
|
468
468
|
}
|
469
469
|
|
470
|
+
/**
|
471
|
+
* Document-method: chunked
|
472
|
+
* call-seq:
|
473
|
+
* parser.chunked? => true or false
|
474
|
+
*
|
475
|
+
* This is used to detect if a response uses chunked Transfer-Encoding or not.
|
476
|
+
*/
|
470
477
|
static VALUE chunked(VALUE self)
|
471
478
|
{
|
472
479
|
struct http_parser *hp = data_get(self);
|
data/kcar.gemspec
CHANGED
@@ -7,8 +7,8 @@ Gem::Specification.new do |s|
|
|
7
7
|
s.name = %q{kcar}
|
8
8
|
s.version = ENV["VERSION"]
|
9
9
|
|
10
|
-
s.homepage = 'http://bogomips.org/kcar'
|
11
|
-
s.authors = ["kcar"]
|
10
|
+
s.homepage = 'http://bogomips.org/kcar/'
|
11
|
+
s.authors = ["kcar hackers"]
|
12
12
|
s.date = Time.now.utc.strftime('%Y-%m-%d')
|
13
13
|
s.description = description
|
14
14
|
s.email = %q{kcar@librelist.com}
|
data/lib/kcar/response.rb
CHANGED
@@ -107,9 +107,8 @@ class Response < Struct.new(:sock, :hdr, :unchunk, :buf, :parser)
|
|
107
107
|
# since Rack does not provide a way to explicitly send trailers
|
108
108
|
# in the response, we'll just yield a stringified version to our
|
109
109
|
# server and pretend it's part of the body.
|
110
|
-
|
111
|
-
|
112
|
-
end
|
110
|
+
trailers = parser.extract_trailers(hdr)
|
111
|
+
yield(trailers.map! { |k,v| "#{k}: #{v}\r\n" }.join("") << CRLF)
|
113
112
|
end
|
114
113
|
|
115
114
|
def each_until_eof(&block)
|
@@ -140,9 +139,13 @@ class Response < Struct.new(:sock, :hdr, :unchunk, :buf, :parser)
|
|
140
139
|
len -= dst.size
|
141
140
|
yield dst
|
142
141
|
end
|
143
|
-
|
144
|
-
|
145
|
-
|
142
|
+
|
143
|
+
if len > 0
|
144
|
+
begin
|
145
|
+
len -= sock.readpartial(len > READ_SIZE ? READ_SIZE : len, dst).size
|
146
|
+
yield dst
|
147
|
+
end while len > 0
|
148
|
+
dst.respond_to?(:clear) ? dst.clear : self.buf = ''
|
146
149
|
end
|
147
150
|
end
|
148
151
|
end
|
data/lib/kcar.rb
CHANGED
data/test/test_response.rb
CHANGED
@@ -3,12 +3,75 @@ require 'test/unit'
|
|
3
3
|
require 'pp'
|
4
4
|
require 'socket'
|
5
5
|
require 'kcar'
|
6
|
+
require 'digest/sha1'
|
6
7
|
|
7
8
|
class TestSession < Test::Unit::TestCase
|
8
9
|
def setup
|
9
10
|
@s, @c = UNIXSocket.pair
|
10
11
|
end
|
11
12
|
|
13
|
+
def test_http_small_pipelined_identity
|
14
|
+
resp = "HTTP/1.1 200 OK\r\nContent-Length: 12\r\n\r\nhello world\n" \
|
15
|
+
"HTTP/1.1 200 OK\r\nContent-Length: 14\r\n\r\ngoodbye world\n"
|
16
|
+
pid = fork do
|
17
|
+
@s << resp
|
18
|
+
@s.close
|
19
|
+
end
|
20
|
+
@s.close
|
21
|
+
@response = Kcar::Response.new(@c)
|
22
|
+
status, headers, body = @response.rack
|
23
|
+
assert_equal status, "200 OK"
|
24
|
+
assert_equal({'Content-Length'=>'12'},headers)
|
25
|
+
tmp = []
|
26
|
+
assert_nothing_raised { body.each { |chunk| tmp << chunk.dup } }
|
27
|
+
assert_equal [ "hello world\n" ], tmp
|
28
|
+
body.close
|
29
|
+
assert ! @c.closed?
|
30
|
+
|
31
|
+
status, headers, body = @response.rack
|
32
|
+
assert_equal status, "200 OK"
|
33
|
+
assert_equal({'Content-Length'=>'14'},headers)
|
34
|
+
tmp = []
|
35
|
+
assert_nothing_raised { body.each { |chunk| tmp << chunk.dup } }
|
36
|
+
assert_equal [ "goodbye world\n" ], tmp
|
37
|
+
|
38
|
+
_, status = Process.waitpid2(pid)
|
39
|
+
assert status.success?
|
40
|
+
body.close
|
41
|
+
end
|
42
|
+
|
43
|
+
def test_http_big_pipelined_identity
|
44
|
+
nr = 1024 * 512
|
45
|
+
width = 80
|
46
|
+
length = nr * width
|
47
|
+
template = "%0#{width - 1}x\n"
|
48
|
+
expect = Digest::SHA1.new
|
49
|
+
nr.times { |i| expect << sprintf(template, i) }
|
50
|
+
pid = fork do
|
51
|
+
@s.sync = false
|
52
|
+
@s << "HTTP/1.1 200 OK\r\nContent-Length: #{length}\r\n\r\n"
|
53
|
+
nr.times { |i| @s.printf(template, i) }
|
54
|
+
@s << "HTTP/1.1 200 OK\r\nContent-Length: #{length}\r\n\r\n"
|
55
|
+
nr.times { |i| @s.printf(template, i) }
|
56
|
+
@s.close
|
57
|
+
end
|
58
|
+
@s.close
|
59
|
+
@response = Kcar::Response.new(@c)
|
60
|
+
|
61
|
+
2.times do |i|
|
62
|
+
status, headers, body = @response.rack
|
63
|
+
assert_equal status, "200 OK"
|
64
|
+
assert_equal({'Content-Length'=>length.to_s}, headers)
|
65
|
+
sha1 = Digest::SHA1.new
|
66
|
+
assert_nothing_raised { body.each { |chunk| sha1 << chunk } }
|
67
|
+
assert_equal expect, sha1, "#{expect.hexdigest} != #{sha1.hexdigest}"
|
68
|
+
body.close
|
69
|
+
assert ! @c.closed?
|
70
|
+
end
|
71
|
+
_, status = Process.waitpid2(pid)
|
72
|
+
assert status.success?
|
73
|
+
end
|
74
|
+
|
12
75
|
def test_http_one_zero
|
13
76
|
pid = fork do
|
14
77
|
@s << "HTTP/1.0 200 OK\r\n\r\nHI"
|
metadata
CHANGED
@@ -1,15 +1,21 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kcar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
|
4
|
+
hash: 25
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 1
|
9
|
+
- 1
|
10
|
+
version: 0.1.1
|
5
11
|
platform: ruby
|
6
12
|
authors:
|
7
|
-
- kcar
|
13
|
+
- kcar hackers
|
8
14
|
autorequire:
|
9
15
|
bindir: bin
|
10
16
|
cert_chain: []
|
11
17
|
|
12
|
-
date: 2010-
|
18
|
+
date: 2010-07-25 00:00:00 +00:00
|
13
19
|
default_executable:
|
14
20
|
dependencies: []
|
15
21
|
|
@@ -61,7 +67,7 @@ files:
|
|
61
67
|
- test/test_parser.rb
|
62
68
|
- test/test_response.rb
|
63
69
|
has_rdoc: true
|
64
|
-
homepage: http://bogomips.org/kcar
|
70
|
+
homepage: http://bogomips.org/kcar/
|
65
71
|
licenses: []
|
66
72
|
|
67
73
|
post_install_message:
|
@@ -73,21 +79,27 @@ require_paths:
|
|
73
79
|
- lib
|
74
80
|
- ext
|
75
81
|
required_ruby_version: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
76
83
|
requirements:
|
77
84
|
- - ">="
|
78
85
|
- !ruby/object:Gem::Version
|
86
|
+
hash: 3
|
87
|
+
segments:
|
88
|
+
- 0
|
79
89
|
version: "0"
|
80
|
-
version:
|
81
90
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
91
|
+
none: false
|
82
92
|
requirements:
|
83
93
|
- - ">="
|
84
94
|
- !ruby/object:Gem::Version
|
95
|
+
hash: 3
|
96
|
+
segments:
|
97
|
+
- 0
|
85
98
|
version: "0"
|
86
|
-
version:
|
87
99
|
requirements: []
|
88
100
|
|
89
101
|
rubyforge_project: rainbows
|
90
|
-
rubygems_version: 1.3.
|
102
|
+
rubygems_version: 1.3.7
|
91
103
|
signing_key:
|
92
104
|
specification_version: 3
|
93
105
|
summary: bytestream to Rack response converter
|