falcon 0.17.1 → 0.17.4

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: ff2e7b8b6b71da71a61d98c6a832b98baa2d3e4748089f33f0eab99eca235052
4
- data.tar.gz: 3e3da30dd2860e50be089be4e439e77fcb8d9e0e6c124e03ecee4876d3f72043
3
+ metadata.gz: bffdd8ea496ec7bdcac74b8c2c540f4d6da008d35d3d8f598764a2d17974b842
4
+ data.tar.gz: 4f993d6d77cebb76ca53141f2e92febba54d3db3eeddaeda130d5bce04d9f48c
5
5
  SHA512:
6
- metadata.gz: 1ba139f77f0885560d055e364e35e443c3677f253fa49baf21450e9dedced20d237efdabf4da67e96311bfdac14097804e1d72ae67fe9c86a5cbb8f28aafce5a
7
- data.tar.gz: 126664e2cbf082fac77f4eaf465710eb31c6c88a0a9b62abfea73aa13f469d24b7e1e839ab219ec97036720d657c7fd8b6521cd4647e8a0b02eb1ec3f74ecd65
6
+ metadata.gz: 8c44c95675ce2e672a97048ca99070b83d773b7a840699f474b72744fe80f17fd8ba8a8d2061a0ab2659dc7622188b5238395b34871db2f17b424580ce0aa7e1
7
+ data.tar.gz: 752f925c54ff738d48cbc2cd81104bd2291d931a5cfe5f1b3893c18e98a599d4bf32f5b0f8e9a5b6db5f9a456357cd1ad88053d5169acc470fff7a1313381607
@@ -24,8 +24,8 @@ Gem::Specification.new do |spec|
24
24
 
25
25
  spec.add_dependency('samovar', "~> 1.3")
26
26
 
27
- spec.add_development_dependency "async-rspec", "~> 1.2"
28
- spec.add_development_dependency "async-websocket"
27
+ spec.add_development_dependency "async-rspec", "~> 1.7"
28
+ spec.add_development_dependency "async-websocket", "~> 0.6.0"
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 1.3"
31
31
  spec.add_development_dependency "rspec", "~> 3.6"
@@ -28,8 +28,8 @@ module Falcon
28
28
  def initialize(body)
29
29
  @body = body
30
30
 
31
- # The current buffer, which is extended by calling `#fill_buffer`.
32
- @buffer = Async::IO::BinaryString.new
31
+ # Will hold remaining data in `#read`.
32
+ @buffer = nil
33
33
  @finished = @body.nil?
34
34
  end
35
35
 
@@ -49,7 +49,7 @@ module Falcon
49
49
  if @body
50
50
  # If the body is not rewindable, this will fail.
51
51
  @body.rewind
52
- @buffer.clear
52
+ @buffer = nil
53
53
  @finished = false
54
54
  end
55
55
  end
@@ -67,49 +67,41 @@ module Falcon
67
67
  # @param buffer [String] the buffer which will receive the data
68
68
  # @return a buffer containing the data
69
69
  def read(length = nil, buffer = nil)
70
- if length
71
- fill_buffer(length) if @buffer.bytesize <= length
72
-
73
- chunk = @buffer.slice!(0, length)
70
+ buffer ||= Async::IO::BinaryString.new
71
+ buffer.clear
72
+
73
+ until buffer.bytesize == length
74
+ @buffer = read_next if @buffer.nil?
75
+ break if @buffer.nil?
74
76
 
75
- if buffer
76
- # TODO https://bugs.ruby-lang.org/issues/14745
77
- buffer.replace(chunk)
78
- else
79
- buffer = chunk
80
- end
77
+ remaining_length = length - buffer.bytesize if length
81
78
 
82
- if buffer.empty? and length > 0
83
- return nil
79
+ if remaining_length && remaining_length < @buffer.bytesize
80
+ buffer << @buffer.byteslice(0, remaining_length)
81
+ @buffer = @buffer.byteslice(remaining_length..-1)
84
82
  else
85
- return buffer
86
- end
87
- else
88
- buffer ||= Async::IO::BinaryString.new
89
-
90
- buffer.replace(@buffer)
91
- @buffer.clear
92
-
93
- while chunk = read_next
94
- buffer << chunk
83
+ buffer << @buffer
84
+ @buffer = nil
95
85
  end
96
-
97
- return buffer
98
86
  end
87
+
88
+ return nil if buffer.empty? && length && length > 0
89
+
90
+ return buffer
99
91
  end
100
92
 
101
93
  def eof?
102
- @finished and @buffer.empty?
94
+ @finished and @buffer.nil?
103
95
  end
104
96
 
105
97
  # gets must be called without arguments and return a string, or nil on EOF.
106
98
  # @return [String, nil] The next chunk from the body.
107
99
  def gets
108
- if @buffer.empty?
100
+ if @buffer.nil?
109
101
  return read_next
110
102
  else
111
- buffer = @buffer.dup
112
- @buffer.clear
103
+ buffer = @buffer
104
+ @buffer = nil
113
105
  return buffer
114
106
  end
115
107
  end
@@ -131,12 +123,6 @@ module Falcon
131
123
  return nil
132
124
  end
133
125
  end
134
-
135
- def fill_buffer(length)
136
- while @buffer.bytesize < length and chunk = read_next
137
- @buffer << chunk
138
- end
139
- end
140
126
  end
141
127
  end
142
128
  end
@@ -87,8 +87,13 @@ module Falcon
87
87
  env['rack.hijack?'] = true
88
88
 
89
89
  env['rack.hijack'] = lambda do
90
- @logger.debug(request) {"Hijacking request..."}
91
- env['rack.hijack_io'] = request.hijack
90
+ wrapper = request.hijack
91
+
92
+ # We dup this as it might be taken out of the normal control flow, and the io will be closed shortly after returning from this method.
93
+ io = wrapper.io.dup
94
+ wrapper.close
95
+
96
+ env['rack.hijack_io'] = io
92
97
  end
93
98
  else
94
99
  env['rack.hijack?'] = false
@@ -105,9 +110,9 @@ module Falcon
105
110
  # return nil
106
111
  # end
107
112
 
108
- if env['rack.hijack_io']
109
- return nil
110
- end
113
+ # if env['rack.hijack_io']
114
+ # return nil
115
+ # end
111
116
 
112
117
  @logger.debug(request) {"Rack response: #{status} #{headers.inspect} #{body.class}"}
113
118
  return Response.new(status, headers, body)
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Falcon
22
- VERSION = "0.17.1"
22
+ VERSION = "0.17.4"
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.17.1
4
+ version: 0.17.4
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-06-29 00:00:00.000000000 Z
11
+ date: 2018-07-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: async-io
@@ -86,28 +86,28 @@ dependencies:
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: '1.2'
89
+ version: '1.7'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: '1.2'
96
+ version: '1.7'
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: async-websocket
99
99
  requirement: !ruby/object:Gem::Requirement
100
100
  requirements:
101
- - - ">="
101
+ - - "~>"
102
102
  - !ruby/object:Gem::Version
103
- version: '0'
103
+ version: 0.6.0
104
104
  type: :development
105
105
  prerelease: false
106
106
  version_requirements: !ruby/object:Gem::Requirement
107
107
  requirements:
108
- - - ">="
108
+ - - "~>"
109
109
  - !ruby/object:Gem::Version
110
- version: '0'
110
+ version: 0.6.0
111
111
  - !ruby/object:Gem::Dependency
112
112
  name: bundler
113
113
  requirement: !ruby/object:Gem::Requirement