protocol-rack 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/lib/protocol/rack/adapter/generic.rb +3 -1
- data/lib/protocol/rack/adapter/rack2.rb +28 -1
- data/lib/protocol/rack/adapter/rack3.rb +23 -0
- data/lib/protocol/rack/response.rb +2 -26
- data/lib/protocol/rack/version.rb +1 -1
- data.tar.gz.sig +0 -0
- metadata +1 -1
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2826bd60593f65a9f2f5350e714c2436b266b9d393d8afb594e59d18ab9168f9
|
4
|
+
data.tar.gz: 4c5051edaf485a0413d5090641c6347ead593a3b5210fcb9b2538808218d7a63
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: df9fa485dd38739b5ff6a400cf047f7dd24237211b9e092252f927ea6bda819f383b08b8dc44be434cf4d44a1828661542aaa60058cac56d8d49c376355bb0ef
|
7
|
+
data.tar.gz: f2a4c166cf5466f230a4cbdf0b1e221d328d06462dee18a7c2d6951ced7530e58528519f5627ee3905449bb4e53cd7dfd563f5f6606a7e93511df1daac5867ba
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
@@ -103,7 +103,9 @@ module Protocol
|
|
103
103
|
|
104
104
|
status, headers, body = @app.call(env)
|
105
105
|
|
106
|
-
|
106
|
+
headers, meta = self.wrap_headers(headers)
|
107
|
+
|
108
|
+
return Response.wrap(status, headers, meta, body, request)
|
107
109
|
rescue => exception
|
108
110
|
Console.logger.error(self) {exception}
|
109
111
|
|
@@ -90,11 +90,34 @@ module Protocol
|
|
90
90
|
return env
|
91
91
|
end
|
92
92
|
|
93
|
+
# Process the rack response headers into into a {Protocol::HTTP::Headers} instance, along with any extra `rack.` metadata.
|
94
|
+
# @returns [Tuple(Protocol::HTTP::Headers, Hash)]
|
95
|
+
def wrap_headers(fields)
|
96
|
+
headers = ::Protocol::HTTP::Headers.new
|
97
|
+
meta = {}
|
98
|
+
|
99
|
+
fields.each do |key, value|
|
100
|
+
key = key.downcase
|
101
|
+
|
102
|
+
if key.start_with?('rack.')
|
103
|
+
meta[key] = value
|
104
|
+
else
|
105
|
+
value.split("\n").each do |value|
|
106
|
+
headers[key] = value
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
return headers, meta
|
112
|
+
end
|
113
|
+
|
93
114
|
def self.make_response(env, response)
|
94
115
|
# These interfaces should be largely compatible:
|
95
116
|
headers = response.headers.to_h
|
117
|
+
|
96
118
|
if protocol = response.protocol
|
97
119
|
headers['rack.protocol'] = protocol
|
120
|
+
# headers['upgrade'] = protocol
|
98
121
|
end
|
99
122
|
|
100
123
|
if body = response.body and body.stream?
|
@@ -103,7 +126,11 @@ module Protocol
|
|
103
126
|
body = []
|
104
127
|
end
|
105
128
|
end
|
106
|
-
|
129
|
+
|
130
|
+
headers.transform_values! do |value|
|
131
|
+
value.is_a?(Array) ? value.join("\n") : value
|
132
|
+
end
|
133
|
+
|
107
134
|
[response.status, headers, body]
|
108
135
|
end
|
109
136
|
end
|
@@ -76,6 +76,29 @@ module Protocol
|
|
76
76
|
return env
|
77
77
|
end
|
78
78
|
|
79
|
+
# Process the rack response headers into into a {Protocol::HTTP::Headers} instance, along with any extra `rack.` metadata.
|
80
|
+
# @returns [Tuple(Protocol::HTTP::Headers, Hash)]
|
81
|
+
def wrap_headers(fields)
|
82
|
+
headers = ::Protocol::HTTP::Headers.new
|
83
|
+
meta = {}
|
84
|
+
|
85
|
+
fields.each do |key, value|
|
86
|
+
key = key.downcase
|
87
|
+
|
88
|
+
if key.start_with?('rack.')
|
89
|
+
meta[key] = value
|
90
|
+
elsif value.is_a?(Array)
|
91
|
+
value.each do |value|
|
92
|
+
headers[key] = value
|
93
|
+
end
|
94
|
+
else
|
95
|
+
headers[key] = value
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
return headers, meta
|
100
|
+
end
|
101
|
+
|
79
102
|
def self.make_response(env, response)
|
80
103
|
# These interfaces should be largely compatible:
|
81
104
|
headers = response.headers.to_h
|
@@ -51,38 +51,14 @@ module Protocol
|
|
51
51
|
'upgrade',
|
52
52
|
]
|
53
53
|
|
54
|
-
# Process the rack response headers into into a {Protocol::HTTP::Headers} instance, along with any extra `rack.` metadata.
|
55
|
-
# @returns [Tuple(Protocol::HTTP::Headers, Hash)]
|
56
|
-
def self.wrap_headers(fields)
|
57
|
-
headers = ::Protocol::HTTP::Headers.new
|
58
|
-
meta = {}
|
59
|
-
|
60
|
-
fields.each do |key, value|
|
61
|
-
key = key.downcase
|
62
|
-
|
63
|
-
if key.start_with?('rack.')
|
64
|
-
meta[key] = value
|
65
|
-
elsif value.is_a?(Array)
|
66
|
-
value.each do |value|
|
67
|
-
headers[key] = value
|
68
|
-
end
|
69
|
-
else
|
70
|
-
headers[key] = value
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
return headers, meta
|
75
|
-
end
|
76
|
-
|
77
54
|
# Wrap a rack response.
|
78
55
|
# @parameter status [Integer] The rack response status.
|
79
56
|
# @parameter headers [Duck(:each)] The rack response headers.
|
80
57
|
# @parameter body [Duck(:each, :close) | Nil] The rack response body.
|
81
58
|
# @parameter request [Protocol::HTTP::Request] The original request.
|
82
|
-
def self.wrap(status, headers, body, request = nil)
|
83
|
-
headers, meta = wrap_headers(headers)
|
84
|
-
|
59
|
+
def self.wrap(status, headers, meta, body, request = nil)
|
85
60
|
ignored = headers.extract(HOP_HEADERS)
|
61
|
+
|
86
62
|
unless ignored.empty?
|
87
63
|
Console.logger.warn(self, "Ignoring protocol-level headers: #{ignored.inspect}")
|
88
64
|
end
|
data.tar.gz.sig
CHANGED
Binary file
|
metadata
CHANGED
metadata.gz.sig
CHANGED
Binary file
|