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 +4 -4
- data/lib/falcon/adapters/rack.rb +15 -4
- data/lib/falcon/adapters/response.rb +26 -6
- data/lib/falcon/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a96077df272d32fc67187a8cf08cb933fbafb351d86184eaf27d0669839b265a
|
4
|
+
data.tar.gz: 285855df5e46df9371a3035c81fb48115ac7b40be4acce8574f63c660383f19b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a73f57c92c9a662cd86a8d471a6d21f19010678b603c000bfede2b9d3c7c03337b2895cdc451f1fb3e706f24153dfa0eec5a06039099f15bf998ea9cc22a9b79
|
7
|
+
data.tar.gz: 9c139bbe127ee57827863513de837c70e93b11359ca49b694c43819449eb0870d0400e2c2942305d66104d921858c43f558e5ff66cebc2cab6ed967716855ba8
|
data/lib/falcon/adapters/rack.rb
CHANGED
@@ -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
|
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.
|
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
|
-
|
30
|
-
|
31
|
-
headers =
|
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
|
34
|
-
headers
|
47
|
+
headers.add('server', "falcon/#{Falcon::VERSION}")
|
48
|
+
headers.add('date', Time.now.httpdate)
|
35
49
|
|
36
|
-
|
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
|
data/lib/falcon/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2018-10-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: http-protocol
|