slimmer 13.3.0 → 13.4.0

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: 29c95c6ec5fcb3d786e88628da00aa44018de1a338e49359d19088db092ea025
4
- data.tar.gz: 5c2f32ef832e751dc5812af7cb9d388fd4a36c8bde03d9525f58b7a46b5f0e87
3
+ metadata.gz: b585bacc031b338e7fc26d91031217d8f9fd5d941f1ef7f0c7ed22570d8ca3d8
4
+ data.tar.gz: 0d887cb3278b139200586f525c0ad225c76aa0680f667a1d53ccd08555380c83
5
5
  SHA512:
6
- metadata.gz: 111d7b5964863534428a2a6b9f46252f49624cb226c524e6c048cbff155c2a37d96cf14f85ade73d71b9b8bbeef1065596f9e795682f7f4fe913529fb0225116
7
- data.tar.gz: 182cab20358b7ae4b69b17c11b19ddb6697e54bd94cd66575478bdc0fa11d6a03597d9788ec4c03b6da22f6ccbb5a4156042aaecb433b1c7ddc907c2e3b7934f
6
+ metadata.gz: 82f4f5819b2c58bf7609409342705cb326298b85532dc6a7e2731af5c8629b4b5bd1195797a2358fa6a959840a3d80bc9089e20659781c23ba91eff8419ffae7
7
+ data.tar.gz: 3de1edffa193308ff1e370e617dc7d503cec26398bdfe383edec856875ac0b6b4dba33ff975cc90adc3885688393d738452e5faf143578202d54b75fe8981693
@@ -1,3 +1,7 @@
1
+ # 13.4.0
2
+
3
+ * Revert X-Slimmer-Ignore-Error header (#246)
4
+
1
5
  # 13.3.0
2
6
 
3
7
  * Add X-Slimmer-Ignore-Error header flag to prevent overriding non-200 status responses
@@ -64,10 +64,6 @@ module Slimmer
64
64
  !!response.headers[Headers::SKIP_HEADER]
65
65
  end
66
66
 
67
- def ignore_error_header?(response)
68
- !!response.headers[Headers::IGNORE_ERROR_HEADER]
69
- end
70
-
71
67
  def s(body)
72
68
  return body.to_s unless body.respond_to?(:each)
73
69
 
@@ -88,32 +84,26 @@ module Slimmer
88
84
  # Store the request id so it can be passed on with any template requests
89
85
  GovukRequestId.value = env["HTTP_GOVUK_REQUEST_ID"]
90
86
 
91
- body = rewritten_body(request, response)
92
-
93
- body = [body] unless body.respond_to?(:each)
94
- response.body = body
87
+ rewritten_body = case response.status
88
+ when 200
89
+ @skin.success request, response, s(response.body)
90
+ when 403
91
+ @skin.error "403", s(response.body), request.env
92
+ when 404
93
+ @skin.error "404", s(response.body), request.env
94
+ when 410
95
+ @skin.error "410", s(response.body), request.env
96
+ else
97
+ @skin.error "500", s(response.body), request.env
98
+ end
99
+
100
+ rewritten_body = [rewritten_body] unless rewritten_body.respond_to?(:each)
101
+ response.body = rewritten_body
95
102
  response.headers["Content-Length"] = content_length(response.body)
96
103
 
97
104
  response.finish
98
105
  end
99
106
 
100
- def rewritten_body(request, response)
101
- return @skin.success request, response, s(response.body) if ignore_error_header?(response)
102
-
103
- case response.status
104
- when 200
105
- @skin.success request, response, s(response.body)
106
- when 403
107
- @skin.error "403", s(response.body), request.env
108
- when 404
109
- @skin.error "404", s(response.body), request.env
110
- when 410
111
- @skin.error "410", s(response.body), request.env
112
- else
113
- @skin.error "500", s(response.body), request.env
114
- end
115
- end
116
-
117
107
  def strip_slimmer_headers(headers)
118
108
  headers.reject { |k, _v| k =~ /\A#{Headers::HEADER_PREFIX}/ }
119
109
  end
@@ -20,7 +20,6 @@ module Slimmer
20
20
  skip: "Skip",
21
21
  template: "Template",
22
22
  remove_search: "Remove-Search",
23
- ignore_error: "Ignore-Error",
24
23
  }.freeze
25
24
 
26
25
  # @private
@@ -56,15 +55,10 @@ module Slimmer
56
55
  # @private
57
56
  REMOVE_SEARCH_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:remove_search]}".freeze
58
57
 
59
- # @private
60
- IGNORE_ERROR_HEADER = "#{HEADER_PREFIX}-#{SLIMMER_HEADER_MAPPING[:ignore_error]}".freeze
61
-
62
-
63
58
  # Set the "slimmer headers" to configure the page
64
59
  #
65
60
  # @param hash [Hash] the options
66
61
  # @option hash [String] application_name
67
- # @option hash [String] ignore_error
68
62
  # @option hash [String] format
69
63
  # @option hash [String] organisations
70
64
  # @option hash [String] page_owner
@@ -1,3 +1,3 @@
1
1
  module Slimmer
2
- VERSION = "13.3.0".freeze
2
+ VERSION = "13.4.0".freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: slimmer
3
3
  version: !ruby/object:Gem::Version
4
- version: 13.3.0
4
+ version: 13.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GOV.UK Dev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-04-08 00:00:00.000000000 Z
11
+ date: 2020-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport