falcon 0.18.7 → 0.18.8

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: 6478a325399d505af8b0adc9a6a18cbfc36ab92dd3099f0a36569a6f63794e82
4
- data.tar.gz: b656a4bb1cbdf50aee0f1b3dbbfe4eb8a217a031a3244c954fbbe2a36c45e0fb
3
+ metadata.gz: a96077df272d32fc67187a8cf08cb933fbafb351d86184eaf27d0669839b265a
4
+ data.tar.gz: 285855df5e46df9371a3035c81fb48115ac7b40be4acce8574f63c660383f19b
5
5
  SHA512:
6
- metadata.gz: ef7f8482964b862eb0cc24d88c26599131d09657c8f58b1a1d3ee559e99a64646fc1050eec19f5b635fc3305caf90d8e893aec3cb30cee3a883fe8279cba89b4
7
- data.tar.gz: 021700b3d1e4cd4240de7e23a6b9ff375120e67f270c49562a76c9602c03eefe78d09c49dec098a1630aa2369f430469e8ca2734f6961b10f93d0e74bdff8128
6
+ metadata.gz: a73f57c92c9a662cd86a8d471a6d21f19010678b603c000bfede2b9d3c7c03337b2895cdc451f1fb3e706f24153dfa0eec5a06039099f15bf998ea9cc22a9b79
7
+ data.tar.gz: 9c139bbe127ee57827863513de837c70e93b11359ca49b694c43819449eb0870d0400e2c2942305d66104d921858c43f558e5ff66cebc2cab6ed967716855ba8
@@ -32,6 +32,19 @@ module Falcon
32
32
  @logger = logger
33
33
  end
34
34
 
35
+ # Rack separates multiple headers with the same key, into a single field with multiple "lines".
36
+ def unwrap_headers(headers, env)
37
+ headers.each do |key, value|
38
+ http_key = "HTTP_#{key.upcase.tr('-', '_')}"
39
+
40
+ if current_value = env[http_key]
41
+ env[http_key] = "#{current_value}\n#{value}"
42
+ else
43
+ env[http_key] = value
44
+ end
45
+ end
46
+ end
47
+
35
48
  def call(request)
36
49
  request_path, query_string = request.path.split('?', 2)
37
50
  server_name, server_port = (request.authority || '').split(':', 2)
@@ -75,9 +88,7 @@ module Falcon
75
88
  env['CONTENT_LENGTH'] = content_length
76
89
  end
77
90
 
78
- request.headers.each do |key, value|
79
- env["HTTP_#{key.upcase.tr('-', '_')}"] = value
80
- end
91
+ self.unwrap_headers(request.headers, env)
81
92
 
82
93
  if remote_address = request.remote_address
83
94
  env['REMOTE_ADDR'] = remote_address.ip_address if remote_address.ip?
@@ -115,7 +126,7 @@ module Falcon
115
126
  # end
116
127
 
117
128
  @logger.debug(request) {"Rack response: #{status} #{headers.inspect} #{body.class}"}
118
- return Response.new(status, headers, body)
129
+ return Response.wrap(status, headers, body)
119
130
  rescue => exception
120
131
  @logger.error "#{exception.class}: #{exception.message}\n\t#{$!.backtrace.join("\n\t")}"
121
132
 
@@ -26,14 +26,34 @@ require 'time'
26
26
  module Falcon
27
27
  module Adapters
28
28
  class Response < Async::HTTP::Response
29
- def initialize(status, headers, body)
30
- # We normalize headers to be lower case:
31
- headers = headers.map{|key, value| [key.downcase, value]}.to_h
29
+ # Append a list of newline encoded headers.
30
+ def self.wrap_headers(fields)
31
+ headers = ::HTTP::Protocol::Headers.new
32
+
33
+ fields.each do |key, value|
34
+ next if key.start_with? 'rack.'
35
+
36
+ value.to_s.split("\n").each do |part|
37
+ headers.add(key, part)
38
+ end
39
+ end
40
+
41
+ return headers
42
+ end
43
+
44
+ def self.wrap(status, headers, body)
45
+ headers = wrap_headers(headers)
32
46
 
33
- headers['server'] ||= "falcon/#{Falcon::VERSION}"
34
- headers['date'] ||= Time.now.httpdate
47
+ headers.add('server', "falcon/#{Falcon::VERSION}")
48
+ headers.add('date', Time.now.httpdate)
35
49
 
36
- super(nil, status, nil, headers, Output.wrap(status, headers, body))
50
+ body = Output.wrap(status, headers, body)
51
+
52
+ return self.new(status, headers, body)
53
+ end
54
+
55
+ def initialize(status, headers, body)
56
+ super(nil, status, nil, headers, body)
37
57
  end
38
58
  end
39
59
  end
@@ -19,5 +19,5 @@
19
19
  # THE SOFTWARE.
20
20
 
21
21
  module Falcon
22
- VERSION = "0.18.7"
22
+ VERSION = "0.18.8"
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.18.7
4
+ version: 0.18.8
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-09-30 00:00:00.000000000 Z
11
+ date: 2018-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: http-protocol