aitch 0.5.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +3 -5
  3. data/CHANGELOG.md +38 -0
  4. data/README.md +50 -14
  5. data/Rakefile +10 -0
  6. data/aitch.gemspec +4 -2
  7. data/lib/aitch.rb +7 -2
  8. data/lib/aitch/configuration.rb +1 -12
  9. data/lib/aitch/dsl.rb +1 -0
  10. data/lib/aitch/errors.rb +1 -0
  11. data/lib/aitch/ext/to_query.rb +1 -0
  12. data/lib/aitch/location.rb +3 -2
  13. data/lib/aitch/namespace.rb +1 -0
  14. data/lib/aitch/redirect.rb +8 -2
  15. data/lib/aitch/request.rb +22 -9
  16. data/lib/aitch/response.rb +4 -13
  17. data/lib/aitch/response/body.rb +1 -0
  18. data/lib/aitch/response/description.rb +52 -51
  19. data/lib/aitch/response/errors.rb +1 -0
  20. data/lib/aitch/response_parser.rb +29 -0
  21. data/lib/aitch/response_parser/default_parser.rb +18 -0
  22. data/lib/aitch/response_parser/html_parser.rb +18 -0
  23. data/lib/aitch/response_parser/json_parser.rb +18 -0
  24. data/lib/aitch/response_parser/xml_parser.rb +18 -0
  25. data/lib/aitch/uri.rb +1 -0
  26. data/lib/aitch/utils.rb +1 -0
  27. data/lib/aitch/version.rb +2 -1
  28. data/test/aitch/aitch_test.rb +27 -0
  29. data/test/aitch/configuration_test.rb +29 -0
  30. data/test/aitch/dsl_test.rb +48 -0
  31. data/test/aitch/execute_test.rb +45 -0
  32. data/test/aitch/namespace_test.rb +12 -0
  33. data/test/aitch/request/client_https_test.rb +20 -0
  34. data/test/aitch/request/follow_redirect_test.rb +64 -0
  35. data/test/aitch/request/request_class_test.rb +28 -0
  36. data/test/aitch/request/status_code_validation_test.rb +19 -0
  37. data/test/aitch/request_test.rb +138 -0
  38. data/test/aitch/response/custom_response_parser_test.rb +31 -0
  39. data/test/aitch/response/errors_test.rb +16 -0
  40. data/test/aitch/response/html_response_test.rb +18 -0
  41. data/test/aitch/response/json_response_test.rb +18 -0
  42. data/test/aitch/response/raw_response_test.rb +11 -0
  43. data/test/aitch/response/status_3xx_test.rb +56 -0
  44. data/test/aitch/response/status_4xx_test.rb +18 -0
  45. data/test/aitch/response/status_5xx_test.rb +18 -0
  46. data/test/aitch/response/xml_response_test.rb +18 -0
  47. data/test/aitch/response_parser/html_parser_test.rb +9 -0
  48. data/test/aitch/response_parser/json_parser_test.rb +9 -0
  49. data/test/aitch/response_parser/xml_parser_test.rb +17 -0
  50. data/test/aitch/response_test.rb +114 -0
  51. data/test/aitch/uri_test.rb +37 -0
  52. data/test/aitch/utils/symbolize_keys_test.rb +9 -0
  53. data/test/aitch/utils/underscore_test.rb +12 -0
  54. data/{spec → test}/fixtures/iso8859-1.xml +0 -0
  55. data/{spec/support/request_uri.rb → test/support/helpers.rb} +12 -3
  56. data/test/test_helper.rb +15 -0
  57. metadata +70 -37
  58. data/.rspec +0 -1
  59. data/lib/aitch/html_parser.rb +0 -7
  60. data/lib/aitch/xml_parser.rb +0 -7
  61. data/spec/aitch/aitch_spec.rb +0 -71
  62. data/spec/aitch/configuration_spec.rb +0 -33
  63. data/spec/aitch/dsl_spec.rb +0 -47
  64. data/spec/aitch/html_parser_spec.rb +0 -8
  65. data/spec/aitch/namespace_spec.rb +0 -11
  66. data/spec/aitch/request_spec.rb +0 -261
  67. data/spec/aitch/response_spec.rb +0 -259
  68. data/spec/aitch/uri_spec.rb +0 -36
  69. data/spec/aitch/utils_spec.rb +0 -19
  70. data/spec/aitch/xml_parser_spec.rb +0 -16
  71. data/spec/spec_helper.rb +0 -24
  72. data/spec/support/webmock.rb +0 -15
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 23b168b3e1919c4678e936b498d68f03d76d633e
4
- data.tar.gz: a389c8c536ca656791eb7eae62f2f74b15a62983
3
+ metadata.gz: daca7104634e48ff40f0d33174c701884d0cbab4
4
+ data.tar.gz: 7d96817bec549c8764561efc84553859b6b6e29b
5
5
  SHA512:
6
- metadata.gz: 355b7f2f6bb8cabf5defde1bfe2bf8dbeb0ca7d545d3f70c6e92ccfa1b08193d295bb859774306e76641a9b6f2854b08b75bd483f78453f1bd6eefb9748b3b65
7
- data.tar.gz: d3dfa452ba5bb4c8483315372b966d45765e7d480f7a52cced117c58e131c15fa4f8a6c9e133f56090b2fbfcc48f8b62cf93e61fee890b1a3a2498c1998d0b17
6
+ metadata.gz: a2c8b42241ec8b9af83c2452c0b2f7fe5c92be1254d91b1324afa39eb7643283ecb3c0f8125834baedbf13e04ad4ffd8a4adadccd235a59318a35c273ee511d0
7
+ data.tar.gz: 7e7d759d48479efe4fb335a8a7ff1fd05434b34cb247f3b725bd6067391d8f05969fc8efd1b2fad976f1f1aeb385a74b37c943f4af167f3fa0987b76624d92ad
@@ -1,23 +1,21 @@
1
1
  language: ruby
2
- script: "bundle exec rspec"
2
+ script: "bundle exec rake"
3
3
  before_install: gem install bundler
4
4
  cache: bundler
5
5
  sudo: false
6
6
 
7
7
  rvm:
8
+ - "2.3.0"
8
9
  - "2.2"
9
10
  - "2.1"
10
11
  - "2.0"
11
- - "1.9"
12
- - jruby-19mode
13
12
  - jruby-head
14
13
 
15
14
  gemfile:
16
15
  - Gemfile
17
16
 
18
17
  notifications:
19
- email:
20
- - fnando.vieira@gmail.com
18
+ email: false
21
19
 
22
20
  addons:
23
21
  code_climate:
@@ -0,0 +1,38 @@
1
+ # Changelog
2
+
3
+ * **1.0.0**
4
+ * Use frozen string magic comments
5
+ * 307 redirections will honor the HTTP request method
6
+ * Fix issue with redirection; it was including the target url for one level redirection.
7
+ * Methods `Aitch::Response#html`, `Aitch::Response#json`, `Aitch::Response#xml` were removed; use `Aitch::Response#data` instead.
8
+ * Add support to response parsers
9
+ * **0.5.0** - May 24, 2015
10
+ * Remove hard dependency on ActiveSupport
11
+ * Add response validation
12
+ * **0.4.1** - December 20, 2014
13
+ * Consider default headers when returning content type (fixes issue with body's JSON encoding)
14
+ * **0.4.0** - December 18, 2014
15
+ * Add accessor method for setting request's content type
16
+ * Automatically encodes body as JSON when content type matches `json`
17
+ * JSON encoding now uses a parser
18
+ * **0.3.0** - April 28, 2014
19
+ * Make list of redirections available
20
+ * Make the request URL available on responses
21
+ * **0.2.1** - July 30, 2013
22
+ * Add alias for `response.success?` (`response.ok?`)
23
+ * **0.2.0** - July 28, 2013
24
+ * Add DSL support
25
+ * Create aliases for `response.data` (`response.xml` and `response.json`)
26
+ * **0.1.5** - June 26, 2013
27
+ * Fix issue with jRuby and `to_h` protocol
28
+ * **0.1.4** - June 13, 2013
29
+ * Accept headers as callable objects
30
+ * Fix XML encoding, always converting values to UTF-8
31
+ * **0.1.3** - May 12, 2013
32
+ * Add response HTML parsing into Nokogiri object
33
+ * **0.1.2** - May 10, 2013
34
+ * Add response error code helpers, like `response.bad_request?` and `response.not_found?`
35
+ * **0.1.1** - April 30, 2013
36
+ * Add support for namespaces
37
+ * **0.1.0** - April 29, 2013
38
+ * Initial release
data/README.md CHANGED
@@ -54,15 +54,6 @@ Aitch.configure do |config|
54
54
 
55
55
  # Set the logger.
56
56
  config.logger = nil
57
-
58
- # Set the JSON parser.
59
- config.json_parser = JSON
60
-
61
- # Set the XML parser.
62
- config.xml_parser = Aitch::XMLParser
63
-
64
- # Set the HTML parser.
65
- config.html_parser = Aitch::HTMLParser
66
57
  end
67
58
  ```
68
59
 
@@ -108,10 +99,7 @@ response.redirect? # status 3xx
108
99
  response.error? # status 4xx or 5xx
109
100
  response.error # response error
110
101
  response.body # returned body
111
- response.data # HTML, JSON or XML payload
112
- response.xml # An alias to the Aitch::Response#data method
113
- response.html # An alias to the Aitch::Response#data method
114
- response.json # An alias to the Aitch::Response#data method
102
+ response.data # Parsed response body
115
103
  ```
116
104
 
117
105
  #### Parsing JSON, XML and HTML with Nokogiri
@@ -208,7 +196,7 @@ Request.get("http://example.org")
208
196
 
209
197
  ### Validating responses
210
198
 
211
- When you know of kind of response you're expecting, you can validate the response with a list of accepted response statuses.
199
+ When you know the kind of response you're expecting, you can validate it by specifying the `expect` option.
212
200
 
213
201
  ```ruby
214
202
  Aitch.get do
@@ -225,6 +213,54 @@ Expect(200 OK) <=> Actual(404 Not Found)
225
213
 
226
214
  You can also provide a list of accepted statuses, like `expect: [200, 201]`.
227
215
 
216
+ ### Response Parsers
217
+
218
+ You can register new response parsers by using `Aitch::ResponseParser.register(name, parser)`, where parser must implement the methods `match?(content_type)` and `load(response_body)`. This is how you could load CSV values.
219
+
220
+ ```ruby
221
+ require "csv"
222
+
223
+ module CSVParser
224
+ def self.type
225
+ :csv
226
+ end
227
+
228
+ def self.match?(content_type)
229
+ content_type.to_s =~ /csv/
230
+ end
231
+
232
+ def self.load(source)
233
+ CSV.parse(source.to_s)
234
+ end
235
+ end
236
+
237
+ Aitch::ResponseParser.prepend(:csv, CSVParser)
238
+ ```
239
+
240
+ The default behavior is returning the response body. You can replace it as the following:
241
+
242
+ ```ruby
243
+ module DefaultParser
244
+ def self.type
245
+ :default
246
+ end
247
+
248
+ def self.match?(content_type)
249
+ true
250
+ end
251
+
252
+ def self.load(source)
253
+ source.to_s
254
+ end
255
+ end
256
+
257
+ # You should use append here, to ensure
258
+ # that is that last parser on the list.
259
+ Aitch::ResponseParser.append(:default, DefaultParser)
260
+ ```
261
+
262
+ Aitch comes with response parsers for HTML, XML and JSON.
263
+
228
264
  ## Contributing
229
265
 
230
266
  1. Fork it
data/Rakefile CHANGED
@@ -1 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  require "bundler/gem_tasks"
3
+ require "rake/testtask"
4
+
5
+ Rake::TestTask.new(:test) do |t|
6
+ t.libs << "test"
7
+ t.test_files = FileList["test/**/*_test.rb"]
8
+ t.warning = false
9
+ end
10
+
11
+ task default: :test
@@ -15,12 +15,14 @@ Gem::Specification.new do |spec|
15
15
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
16
16
  spec.require_paths = ["lib"]
17
17
 
18
+ spec.required_ruby_version = ">= 2.0"
19
+
18
20
  spec.add_dependency "nokogiri", ">= 1.6.0"
19
21
 
20
22
  spec.add_development_dependency "codeclimate-test-reporter"
21
23
  spec.add_development_dependency "bundler"
22
24
  spec.add_development_dependency "rake"
23
- spec.add_development_dependency "rspec"
24
- spec.add_development_dependency "test_notifier"
25
+ spec.add_development_dependency "minitest-utils"
26
+ spec.add_development_dependency "mocha"
25
27
  spec.add_development_dependency "webmock"
26
28
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "net/https"
2
3
  require "forwardable"
3
4
  require "json"
@@ -24,8 +25,11 @@ require "aitch/response/errors"
24
25
  require "aitch/response"
25
26
  require "aitch/response/body"
26
27
  require "aitch/response/description"
27
- require "aitch/xml_parser"
28
- require "aitch/html_parser"
28
+ require "aitch/response_parser/default_parser"
29
+ require "aitch/response_parser/html_parser"
30
+ require "aitch/response_parser/json_parser"
31
+ require "aitch/response_parser/xml_parser"
32
+ require "aitch/response_parser"
29
33
  require "aitch/version"
30
34
 
31
35
  module Aitch
@@ -47,6 +51,7 @@ module Aitch
47
51
  end
48
52
 
49
53
  private
54
+
50
55
  def self.namespace
51
56
  @namespace ||= Namespace.new
52
57
  end
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Aitch
2
3
  class Configuration
3
4
  # Set proxy.
@@ -21,24 +22,12 @@ module Aitch
21
22
  # Set the logger.
22
23
  attr_accessor :logger
23
24
 
24
- # Set the JSON parser.
25
- attr_accessor :json_parser
26
-
27
- # Set the XML parser.
28
- attr_accessor :xml_parser
29
-
30
- # Set the HTML parser.
31
- attr_accessor :html_parser
32
-
33
25
  def initialize
34
26
  @timeout = 10
35
27
  @redirect_limit = 5
36
28
  @follow_redirect = true
37
29
  @user_agent = "Aitch/#{Aitch::VERSION} (http://rubygems.org/gems/aitch)"
38
30
  @default_headers = {}
39
- @json_parser = JSON
40
- @xml_parser = XMLParser
41
- @html_parser = HTMLParser
42
31
  end
43
32
 
44
33
  def to_h
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Aitch
2
3
  class DSL
3
4
  %w[url options headers data].each do |name|
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Aitch
2
3
  InvalidURIError = Class.new(StandardError)
3
4
  InvalidHTTPMethodError = Class.new(StandardError)
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  require "cgi"
2
3
 
3
4
  class Object
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Aitch
2
3
  class Location
3
4
  attr_reader :redirect_stack, :current_url
@@ -11,10 +12,10 @@ module Aitch
11
12
  return current_url unless current_url.match(%r[\A/])
12
13
 
13
14
  uri = find_uri_with_host
14
- url = "#{uri.scheme}://#{uri.hostname}"
15
+ url = ["#{uri.scheme}://#{uri.hostname}"]
15
16
  url << ":#{uri.port}" unless [80, 443].include?(uri.port)
16
17
  url << current_url
17
- url
18
+ url.join
18
19
  end
19
20
 
20
21
  def find_uri_with_host
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Aitch
2
3
  class Namespace
3
4
  def configure(&block)
@@ -1,9 +1,11 @@
1
+ # frozen_string_literal: true
1
2
  module Aitch
2
3
  class Redirect
4
+ attr_reader :tries
5
+
3
6
  def initialize(options)
4
7
  @tries = 1
5
8
  @options = options
6
- @max_tries = @options[:redirect_limit]
7
9
  end
8
10
 
9
11
  def followed!
@@ -11,7 +13,11 @@ module Aitch
11
13
  end
12
14
 
13
15
  def follow?(response)
14
- enabled? && response.redirect? && @tries < @max_tries
16
+ enabled? && response.redirect? && tries < max_tries
17
+ end
18
+
19
+ def max_tries
20
+ @options[:redirect_limit]
15
21
  end
16
22
 
17
23
  def enabled?
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Aitch
2
3
  class Request
3
4
  attr_accessor :request_method
@@ -5,10 +6,14 @@ module Aitch
5
6
  attr_accessor :data
6
7
  attr_accessor :headers
7
8
  attr_accessor :options
9
+ attr_accessor :redirects
8
10
 
9
11
  def initialize(options)
10
- self.headers ||= {}
11
- self.options ||= {}
12
+ self.headers = {}
13
+ self.options = {}
14
+ self.redirects = []
15
+
16
+ @_original_options = options.dup.freeze
12
17
 
13
18
  options.each do |name, value|
14
19
  public_send("#{name}=", value)
@@ -26,11 +31,11 @@ module Aitch
26
31
  end
27
32
 
28
33
  def content_type=(content_type)
29
- headers['Content-Type'] = content_type
34
+ headers["Content-Type"] = content_type
30
35
  end
31
36
 
32
37
  def content_type
33
- headers['Content-Type'] || options.fetch(:default_headers, {})['Content-Type']
38
+ headers["Content-Type"] || options.fetch(:default_headers, {})["Content-Type"]
34
39
  end
35
40
 
36
41
  def request
@@ -114,14 +119,22 @@ module Aitch
114
119
  defined?(Net::ReadTimeout) ? Net::ReadTimeout : Timeout::Error
115
120
  end
116
121
 
117
- def follow_redirect(response)
122
+ def follow_redirect(response, redirected_from = [])
123
+ return response unless response.redirect?
124
+
118
125
  redirect = Redirect.new(options)
126
+ redirected_from = [url]
119
127
 
120
128
  while redirect.follow?(response)
121
- redirected_from ||= [url]
122
- redirected_from << Location.new(redirected_from, response.location).location
129
+ location = Location.new(redirected_from, response.location).location
123
130
  redirect.followed!
124
- response = Aitch.get(redirected_from.last)
131
+ follow_request_method = response.code == 307 ? request_method : :get
132
+ follow_request_options = @_original_options.merge(
133
+ request_method: follow_request_method,
134
+ url: location
135
+ )
136
+ response = self.class.new(follow_request_options).perform
137
+ redirected_from += response.redirected_from
125
138
  end
126
139
 
127
140
  raise TooManyRedirectsError if redirect.enabled? && response.redirect?
@@ -138,7 +151,7 @@ module Aitch
138
151
 
139
152
  descriptions = expected
140
153
  .map {|code| Response.description_for_code(code) }
141
- .join(', ')
154
+ .join(", ")
142
155
 
143
156
  raise StatusCodeError,
144
157
  "Expected(#{descriptions}) <=> Actual(#{response.description})"
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Aitch
2
3
  class Response
3
4
  extend Forwardable
@@ -6,12 +7,13 @@ module Aitch
6
7
  attr_accessor :redirected_from, :url
7
8
 
8
9
  def self.description_for_code(code)
9
- [code, DESCRIPTION[code]].compact.join(' ')
10
+ [code, DESCRIPTION[code]].compact.join(" ")
10
11
  end
11
12
 
12
13
  def initialize(options, http_response)
13
14
  @options = options
14
15
  @http_response = http_response
16
+ @redirected_from = options.fetch(:redirected_from, [])
15
17
  end
16
18
 
17
19
  ERRORS.each do |status_code, exception|
@@ -60,19 +62,8 @@ module Aitch
60
62
  end
61
63
 
62
64
  def data
63
- if json?
64
- @options[:json_parser].load(body)
65
- elsif xml?
66
- @options[:xml_parser].load(body)
67
- elsif html?
68
- @options[:html_parser].load(body)
69
- else
70
- body
71
- end
65
+ Aitch::ResponseParser.find(content_type).load(body)
72
66
  end
73
- alias_method :xml, :data
74
- alias_method :html, :data
75
- alias_method :json, :data
76
67
 
77
68
  def headers
78
69
  @headers ||= {}.tap do |headers|
@@ -1,3 +1,4 @@
1
+ # frozen_string_literal: true
1
2
  module Aitch
2
3
  class Response
3
4
  class Body
@@ -1,61 +1,62 @@
1
+ # frozen_string_literal: true
1
2
  module Aitch
2
3
  class Response
3
4
  DESCRIPTION = {
4
- 100 => 'Continue',
5
- 101 => 'Switch Protocol',
5
+ 100 => "Continue",
6
+ 101 => "Switch Protocol",
6
7
 
7
- 200 => 'OK',
8
- 201 => 'Created',
9
- 202 => 'Accepted',
10
- 203 => 'Non Authoritative Information',
11
- 204 => 'No Content',
12
- 205 => 'Reset Content',
13
- 206 => 'Partial Content',
14
- 207 => 'Multi Status',
15
- 226 => 'IM Used',
8
+ 200 => "OK",
9
+ 201 => "Created",
10
+ 202 => "Accepted",
11
+ 203 => "Non Authoritative Information",
12
+ 204 => "No Content",
13
+ 205 => "Reset Content",
14
+ 206 => "Partial Content",
15
+ 207 => "Multi Status",
16
+ 226 => "IM Used",
16
17
 
17
- 300 => 'Multiple Choices',
18
- 301 => 'Moved Permanently',
19
- 302 => 'Found',
20
- 303 => 'See Other',
21
- 304 => 'Not Modified',
22
- 305 => 'Use Proxy',
23
- 307 => 'Temporary Redirect',
18
+ 300 => "Multiple Choices",
19
+ 301 => "Moved Permanently",
20
+ 302 => "Found",
21
+ 303 => "See Other",
22
+ 304 => "Not Modified",
23
+ 305 => "Use Proxy",
24
+ 307 => "Temporary Redirect",
24
25
 
25
- 400 => 'Bad Request',
26
- 401 => 'Unauthorized',
27
- 402 => 'Payment Required',
28
- 403 => 'Forbidden',
29
- 404 => 'Not Found',
30
- 405 => 'Method Not Allowed',
31
- 406 => 'Not Acceptable',
32
- 407 => 'Proxy Authentication Required',
33
- 408 => 'Request Time Out',
34
- 409 => 'Conflict',
35
- 410 => 'Gone',
36
- 411 => 'Length Required',
37
- 412 => 'Precondition Failed',
38
- 413 => 'Request Entity Too Large',
39
- 414 => 'Request URIToo Long',
40
- 415 => 'Unsupported Media Type',
41
- 416 => 'Requested Range Not Satisfiable',
42
- 417 => 'Expectation Failed',
43
- 422 => 'Unprocessable Entity',
44
- 423 => 'Locked',
45
- 424 => 'Failed Dependency',
46
- 426 => 'Upgrade Required',
47
- 428 => 'Precondition Required',
48
- 429 => 'Too Many Requests',
49
- 431 => 'Request Header Fields Too Large',
26
+ 400 => "Bad Request",
27
+ 401 => "Unauthorized",
28
+ 402 => "Payment Required",
29
+ 403 => "Forbidden",
30
+ 404 => "Not Found",
31
+ 405 => "Method Not Allowed",
32
+ 406 => "Not Acceptable",
33
+ 407 => "Proxy Authentication Required",
34
+ 408 => "Request Time Out",
35
+ 409 => "Conflict",
36
+ 410 => "Gone",
37
+ 411 => "Length Required",
38
+ 412 => "Precondition Failed",
39
+ 413 => "Request Entity Too Large",
40
+ 414 => "Request URIToo Long",
41
+ 415 => "Unsupported Media Type",
42
+ 416 => "Requested Range Not Satisfiable",
43
+ 417 => "Expectation Failed",
44
+ 422 => "Unprocessable Entity",
45
+ 423 => "Locked",
46
+ 424 => "Failed Dependency",
47
+ 426 => "Upgrade Required",
48
+ 428 => "Precondition Required",
49
+ 429 => "Too Many Requests",
50
+ 431 => "Request Header Fields Too Large",
50
51
 
51
- 500 => 'Internal Server Error',
52
- 501 => 'Not Implemented',
53
- 502 => 'Bad Gateway',
54
- 503 => 'Service Unavailable',
55
- 504 => 'Gateway Time Out',
56
- 505 => 'Version Not Supported',
57
- 507 => 'Insufficient Storage',
58
- 511 => 'Network Authentication Required',
52
+ 500 => "Internal Server Error",
53
+ 501 => "Not Implemented",
54
+ 502 => "Bad Gateway",
55
+ 503 => "Service Unavailable",
56
+ 504 => "Gateway Time Out",
57
+ 505 => "Version Not Supported",
58
+ 507 => "Insufficient Storage",
59
+ 511 => "Network Authentication Required",
59
60
  }
60
61
  end
61
62
  end