File tree Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Expand file tree Collapse file tree 1 file changed +26
-0
lines changed Original file line number Diff line number Diff line change @@ -4,6 +4,19 @@ class Prerender
4
4
require 'active_support'
5
5
6
6
def initialize ( app , options = { } )
7
+ @connection_header_values = [
8
+ 'close' ,
9
+ 'keep-alive'
10
+ ] . freeze
11
+ @hop_by_hop_headers = [
12
+ 'Connection' ,
13
+ 'Keep-Alive' ,
14
+ 'Public' ,
15
+ 'Proxy-Authenticate' ,
16
+ 'Transfer-Encoding' ,
17
+ 'Upgrade'
18
+ ] . freeze
19
+
7
20
@crawler_user_agents = [
8
21
'googlebot' ,
9
22
'yahoo' ,
@@ -175,6 +188,19 @@ def get_prerendered_page_response(env)
175
188
response [ 'Content-Length' ] = response . body . length
176
189
response . delete ( 'Content-Encoding' )
177
190
end
191
+
192
+ hop_by_hop_headers = @hop_by_hop_headers
193
+ connection = response [ 'Connection' ]
194
+ if connection
195
+ connection_hop_by_hop_headers = connection . split ( ',' ) .
196
+ map ( &:strip ) .
197
+ map ( &:downcase ) .
198
+ difference ( @connection_header_values )
199
+ hop_by_hop_headers = connection_hop_by_hop_headers .
200
+ concat ( hop_by_hop_headers )
201
+ end
202
+ hop_by_hop_headers . each { |h | response . delete ( h ) }
203
+
178
204
response
179
205
rescue
180
206
nil
You can’t perform that action at this time.
0 commit comments