falcon 0.10.0 → 0.11.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: f3429e33911513a17a66a9dad747942f377f57dd4f2351ec59cb3e17047407ca
4
- data.tar.gz: 7b6339640be53ec16971524684e12e1e1a77a9bd2f1ebacfbc1abeb5eb3754be
3
+ metadata.gz: bfbbbd80fcbe0e419ff2d26f22004bba0fb8bb6674b508b253ebdc44729abebe
4
+ data.tar.gz: 0dc2c1e25e1e1a5bf19d843ef3b803ebacc855417cdd460bd3e971d8e3ed6e0a
5
5
  SHA512:
6
- metadata.gz: 1c1780fd09c7840daafb3b4f4472c622a87f077182bc334ca09406a38bd3d7616bcd1bc78be85debb5fdc48d368460d8d79fd893b99e3e45659f5cce975277f2
7
- data.tar.gz: 80fa7d8d306a2c4cb4e967051e1e8353d5ac4e41ab41a1cf3ba43fb842713f74a32e8d64e2b201d30350c7f5b5bd30c77a5c60fad4c04e83321b12687806807b
6
+ metadata.gz: 4bc9ea031a37477c780688caa3ed0ad19625fd91c74f7bc148b7fd83511e4ee646edf4dc85a64521a347e93742b3dbb317781fa4abd26f4074148093d662d335
7
+ data.tar.gz: 9da626f01d30cfaa3a30174b8fc73eeba209d632cafe708c2d56b6cec7840ea818a6cb1883c3435508ba7a6f5256a1d977c0b255a855081dc9d67c618ef1b12d
data/falcon.gemspec CHANGED
@@ -17,7 +17,7 @@ Gem::Specification.new do |spec|
17
17
  spec.require_paths = ["lib"]
18
18
 
19
19
  spec.add_dependency("async-io", "~> 1.6")
20
- spec.add_dependency("async-http", "~> 0.11")
20
+ spec.add_dependency("async-http", "~> 0.15")
21
21
  spec.add_dependency("async-container", "~> 0.3")
22
22
 
23
23
  spec.add_dependency("rack", ">= 1.0")
data/lib/falcon/input.rb CHANGED
@@ -26,19 +26,15 @@ module Falcon
26
26
  @body = body
27
27
  @chunks = []
28
28
 
29
- @buffer = nil
30
- @closed = false
29
+ @index = 0
30
+ @buffer = Async::IO::BinaryString.new
31
+ @finished = false
31
32
  end
32
33
 
33
34
  def each(&block)
34
- while @index < @chunks.count
35
- chunk = @chunks[@index]
36
- @index += 1
37
- yield chunk
38
- end
35
+ return to_enum unless block_given?
39
36
 
40
- @body.each do |chunk|
41
- @chunks << chunk
37
+ while chunk = read_next
42
38
  yield chunk
43
39
  end
44
40
 
@@ -47,30 +43,31 @@ module Falcon
47
43
 
48
44
  def rewind
49
45
  @index = 0
50
- @closed = false
46
+ @finished = false
47
+ @buffer.clear
51
48
  end
52
49
 
53
50
  def read(length = nil, buffer = nil)
54
- unless @buffer
55
- self.each do |chunk|
56
- @buffer = chunk
57
- break
58
- end
59
- end
60
-
61
- if @buffer
62
- if length and @buffer.bytesize < length
63
- return @buffer.slice!(0, length)
64
- else
65
- buffer = @buffer
66
- @buffer = nil
67
- return buffer
51
+ if length
52
+ fill_buffer(length) if @buffer.bytesize <= length
53
+
54
+ return @buffer.slice!(0, length)
55
+ else
56
+ buffer ||= Async::IO::BinaryString.new
57
+
58
+ buffer << @buffer
59
+ @buffer.clear
60
+
61
+ while chunk = read_next
62
+ buffer << chunk
68
63
  end
64
+
65
+ return buffer
69
66
  end
70
67
  end
71
68
 
72
69
  def eof?
73
- @closed and @buffer.nil?
70
+ @finished and @buffer.empty?
74
71
  end
75
72
 
76
73
  def gets
@@ -78,7 +75,35 @@ module Falcon
78
75
  end
79
76
 
80
77
  def close
81
- @body.close
78
+ @body.finish
79
+ end
80
+
81
+ private
82
+
83
+ def read_next
84
+ return nil if @finished
85
+
86
+ chunk = nil
87
+
88
+ if @index < @chunks.count
89
+ chunk = @chunks[@index]
90
+ @index += 1
91
+ else
92
+ if chunk = @body.read
93
+ @chunks << chunk
94
+ @index += 1
95
+ end
96
+ end
97
+
98
+ @finished = true if chunk.nil?
99
+
100
+ return chunk
101
+ end
102
+
103
+ def fill_buffer(length)
104
+ while @buffer.bytesize < length and chunk = read_next
105
+ @buffer << chunk
106
+ end
82
107
  end
83
108
  end
84
109
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Falcon
22
- VERSION = "0.10.0"
22
+ VERSION = "0.11.0"
23
23
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: falcon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Samuel Williams
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-04-09 00:00:00.000000000 Z
11
+ date: 2018-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-io
@@ -30,14 +30,14 @@ dependencies:
30
30
  requirements:
31
31
  - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: '0.11'
33
+ version: '0.15'
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: '0.11'
40
+ version: '0.15'
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: async-container
43
43
  requirement: !ruby/object:Gem::Requirement