kcar 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  #!/bin/sh
2
2
 
3
3
  GVF=GIT-VERSION-FILE
4
- DEF_VER=v0.3.0.GIT
4
+ DEF_VER=v0.3.1.GIT
5
5
 
6
6
  LF='
7
7
  '
@@ -63,21 +63,14 @@ class Kcar::Response
63
63
  # body. It may only be called once (usually by a Rack server) as it streams
64
64
  # the response body off the our socket object.
65
65
  def each
66
- if @parser.body_eof?
67
- return
68
- end
66
+ return if @parser.body_eof?
69
67
  if @unchunk
70
68
  @parser.chunked? ? each_unchunk { |x| yield x } :
71
69
  each_identity { |x| yield x }
72
70
  else
73
- if @parser.keepalive?
74
- @parser.chunked? ? each_rechunk { |x| yield x } :
75
- each_identity { |x| yield x }
76
- else
77
- each_until_eof { |x| yield x } # fastest path
78
- end
71
+ @parser.chunked? ? each_rechunk { |x| yield x } :
72
+ each_identity { |x| yield x }
79
73
  end
80
- rescue EOFError
81
74
  end
82
75
 
83
76
  # :stopdoc:
@@ -123,6 +116,7 @@ class Kcar::Response
123
116
  begin
124
117
  yield dst
125
118
  end while @sock.readpartial(READ_SIZE, dst)
119
+ rescue EOFError
126
120
  end
127
121
 
128
122
  def each_identity
@@ -485,7 +485,7 @@ class TestSession < Test::Unit::TestCase
485
485
  assert ! @c.closed?
486
486
  end
487
487
 
488
- def test_rack_preserve_chunk_ary_no_keepalive
488
+ def test_rack_preserve_chunk_no_keepalive
489
489
  pid = fork do
490
490
  @s << "HTTP/1.1 200 OK\r\n"
491
491
  @s << "Connection: close\r\n"
@@ -501,11 +501,36 @@ class TestSession < Test::Unit::TestCase
501
501
  tmp = []
502
502
  assert ! body.parser.keepalive?
503
503
  assert_nothing_raised { body.each { |chunk| tmp << chunk.dup } }
504
- assert_equal ["5\r\nhello\r\n0\r\nFoo: bar\r\n\r\n"], tmp
504
+ assert_equal "5\r\nhello\r\n0\r\nFoo: bar\r\n\r\n", tmp.join
505
505
  _, status = Process.waitpid2(pid)
506
506
  assert status.success?
507
507
  body.close
508
508
  assert @c.closed?
509
509
  end
510
510
 
511
+ def test_rack_preserve_chunk_no_keepalive
512
+ s = "HTTP/1.1 200 OK\r\n"
513
+ s << "Connection: close\r\n"
514
+ s << "Content-Length: 666\r\n"
515
+ s << "\r\n"
516
+ s << "hello"
517
+ @s.write(s)
518
+ @response = Kcar::Response.new(@c, [])
519
+ status, headers, body = @response.rack
520
+ assert_kind_of Array, headers
521
+ assert_equal status, "200 OK"
522
+ tmp = []
523
+ assert ! body.parser.keepalive?
524
+
525
+ closer = Thread.new do
526
+ Thread.pass until tmp[0]
527
+ @s.close
528
+ end
529
+ assert_raises(EOFError) {
530
+ body.each { |chunk| tmp << chunk.dup }
531
+ }
532
+ assert_nil @c.close
533
+ assert_equal "hello", tmp[0]
534
+ assert_nil closer.value
535
+ end
511
536
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kcar
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 0
10
- version: 0.3.0
9
+ - 1
10
+ version: 0.3.1
11
11
  platform: ruby
12
12
  authors:
13
13
  - kcar hackers
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-07 00:00:00 Z
18
+ date: 2012-09-26 00:00:00 Z
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
21
21
  name: wrongdoc
@@ -114,7 +114,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
114
114
  requirements: []
115
115
 
116
116
  rubyforge_project: rainbows
117
- rubygems_version: 1.8.2
117
+ rubygems_version: 1.8.24
118
118
  signing_key:
119
119
  specification_version: 3
120
120
  summary: bytestream to Rack response converter