http 0.8.11 → 0.8.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGES.md +5 -0
- data/lib/http.rb +1 -1
- data/lib/http/cache.rb +2 -2
- data/lib/http/cache/headers.rb +5 -5
- data/lib/http/chainable.rb +8 -3
- data/lib/http/client.rb +17 -14
- data/lib/http/connection.rb +5 -3
- data/lib/http/headers.rb +1 -6
- data/lib/http/headers/known.rb +78 -0
- data/lib/http/redirector.rb +6 -4
- data/lib/http/request.rb +9 -7
- data/lib/http/request/caching.rb +6 -6
- data/lib/http/request/writer.rb +13 -5
- data/lib/http/response.rb +1 -1
- data/lib/http/response/caching.rb +6 -5
- data/lib/http/response/status.rb +10 -2
- data/lib/http/version.rb +1 -1
- data/spec/lib/http/response/status_spec.rb +1 -1
- metadata +5 -40
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2bb012bd8ce0fdf45a88171c20552f819279e316
|
4
|
+
data.tar.gz: 094be455227c7e42aba8157819b9336b9744b9d1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60ce4064cdafe70513e1749ace44afed30c9c08251d3d9ec0d0c1f205d243704403ca8643e96d7792fb23085e4ae755ab04db073c084142f7652f0ef5a594bdf
|
7
|
+
data.tar.gz: a7c7acda4cb5c67cb84ee300d42f5871a413066a78c44188fb8d51de96047124ba4b25ece259b0785c7a806f16e0d7bdc911572d7d6ab292cfd52b1afb4d612c
|
data/CHANGES.md
CHANGED
data/lib/http.rb
CHANGED
data/lib/http/cache.rb
CHANGED
@@ -51,8 +51,8 @@ module HTTP
|
|
51
51
|
handle_response(cached_resp, actual_resp, req)
|
52
52
|
end
|
53
53
|
|
54
|
-
# @
|
55
|
-
#
|
54
|
+
# @return [Response] the most useful of the responses after
|
55
|
+
# updating the cache as appropriate
|
56
56
|
def handle_response(cached_resp, actual_resp, req)
|
57
57
|
if actual_resp.status.not_modified? && cached_resp
|
58
58
|
logger.debug { "<#{req.uri}> not modified, using cached version." }
|
data/lib/http/cache/headers.rb
CHANGED
@@ -53,23 +53,23 @@ module HTTP
|
|
53
53
|
|
54
54
|
# @return [Boolean] is the vary header set to '*'
|
55
55
|
def vary_star?
|
56
|
-
get(
|
56
|
+
get(HTTP::Headers::VARY).any? { |v| "*" == v.strip }
|
57
57
|
end
|
58
58
|
|
59
59
|
private
|
60
60
|
|
61
61
|
# @return [Boolean] true when cache-control header matches the pattern
|
62
62
|
def matches?(pattern)
|
63
|
-
get(
|
63
|
+
get(HTTP::Headers::CACHE_CONTROL).any? { |v| v =~ pattern }
|
64
64
|
end
|
65
65
|
|
66
66
|
# @return [Numeric] number of seconds until the time in the
|
67
67
|
# expires header is reached.
|
68
68
|
#
|
69
69
|
# ---
|
70
|
-
# Some servers send a "
|
70
|
+
# Some servers send a "Expires: -1" header which must be treated as expired
|
71
71
|
def seconds_til_expires
|
72
|
-
get(
|
72
|
+
get(HTTP::Headers::EXPIRES).
|
73
73
|
map { |e| http_date_to_ttl(e) }.
|
74
74
|
max
|
75
75
|
end
|
@@ -89,7 +89,7 @@ module HTTP
|
|
89
89
|
|
90
90
|
# @return [Numeric] the value of the max-age component of cache control
|
91
91
|
def explicit_max_age
|
92
|
-
get(
|
92
|
+
get(HTTP::Headers::CACHE_CONTROL).
|
93
93
|
map { |v| (/max-age=(\d+)/i).match(v) }.
|
94
94
|
compact.
|
95
95
|
map { |m| m[1].to_i }.
|
data/lib/http/chainable.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "base64"
|
2
2
|
|
3
|
+
require "http/headers"
|
4
|
+
|
3
5
|
module HTTP
|
4
6
|
module Chainable
|
5
7
|
# Request a get sans response body
|
@@ -95,7 +97,10 @@ module HTTP
|
|
95
97
|
options["#{k}_timeout".to_sym] = options.delete k
|
96
98
|
end
|
97
99
|
|
98
|
-
branch
|
100
|
+
branch default_options.merge(
|
101
|
+
:timeout_class => klass,
|
102
|
+
:timeout_options => options
|
103
|
+
)
|
99
104
|
end
|
100
105
|
|
101
106
|
# @overload persistent(host)
|
@@ -195,7 +200,7 @@ module HTTP
|
|
195
200
|
# Accept the given MIME type(s)
|
196
201
|
# @param type
|
197
202
|
def accept(type)
|
198
|
-
|
203
|
+
headers Headers::ACCEPT => MimeType.normalize(type)
|
199
204
|
end
|
200
205
|
|
201
206
|
# Make a request with the given Authorization header
|
@@ -204,7 +209,7 @@ module HTTP
|
|
204
209
|
# shim for deprecated auth(:basic, opts).
|
205
210
|
# will be removed in 0.8.0
|
206
211
|
return basic_auth(opts) if :basic == value
|
207
|
-
|
212
|
+
headers Headers::AUTHORIZATION => value.to_s
|
208
213
|
end
|
209
214
|
|
210
215
|
# Make a request with the given Basic authorization header
|
data/lib/http/client.rb
CHANGED
@@ -16,7 +16,6 @@ module HTTP
|
|
16
16
|
extend Forwardable
|
17
17
|
include Chainable
|
18
18
|
|
19
|
-
CONNECTION = "Connection".freeze
|
20
19
|
KEEP_ALIVE = "Keep-Alive".freeze
|
21
20
|
CLOSE = "close".freeze
|
22
21
|
|
@@ -36,13 +35,6 @@ module HTTP
|
|
36
35
|
body = make_request_body(opts, headers)
|
37
36
|
proxy = opts.proxy
|
38
37
|
|
39
|
-
# Tell the server to keep the conn open
|
40
|
-
if default_options.persistent?
|
41
|
-
headers[CONNECTION] = KEEP_ALIVE
|
42
|
-
else
|
43
|
-
headers[CONNECTION] = CLOSE
|
44
|
-
end
|
45
|
-
|
46
38
|
req = HTTP::Request.new(verb, uri, headers, proxy, body)
|
47
39
|
res = perform req, opts
|
48
40
|
|
@@ -147,11 +139,22 @@ module HTTP
|
|
147
139
|
|
148
140
|
# Creates request headers with cookies (if any) merged in
|
149
141
|
def make_request_headers(opts)
|
142
|
+
headers = opts.headers
|
143
|
+
|
144
|
+
# Tell the server to keep the conn open
|
145
|
+
if default_options.persistent?
|
146
|
+
headers[Headers::CONNECTION] = KEEP_ALIVE
|
147
|
+
else
|
148
|
+
headers[Headers::CONNECTION] = CLOSE
|
149
|
+
end
|
150
|
+
|
150
151
|
cookies = opts.cookies.values
|
151
|
-
|
152
|
+
unless cookies.empty?
|
153
|
+
cookies = opts.headers.get(Headers::COOKIE).concat(cookies).join("; ")
|
154
|
+
headers[Headers::COOKIE] = cookies
|
155
|
+
end
|
152
156
|
|
153
|
-
|
154
|
-
opts.headers.merge(Headers::COOKIE => cookies)
|
157
|
+
headers
|
155
158
|
end
|
156
159
|
|
157
160
|
# Create the request body object to send
|
@@ -161,11 +164,11 @@ module HTTP
|
|
161
164
|
opts.body
|
162
165
|
when opts.form
|
163
166
|
form = HTTP::FormData.create opts.form
|
164
|
-
headers[
|
165
|
-
headers[
|
167
|
+
headers[Headers::CONTENT_TYPE] ||= form.content_type
|
168
|
+
headers[Headers::CONTENT_LENGTH] ||= form.content_length
|
166
169
|
form.to_s
|
167
170
|
when opts.json
|
168
|
-
headers[
|
171
|
+
headers[Headers::CONTENT_TYPE] ||= "application/json"
|
169
172
|
MimeType[:json].encode opts.json
|
170
173
|
end
|
171
174
|
end
|
data/lib/http/connection.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "forwardable"
|
2
2
|
|
3
|
+
require "http/client"
|
4
|
+
require "http/headers"
|
3
5
|
require "http/response/parser"
|
4
6
|
|
5
7
|
module HTTP
|
@@ -51,7 +53,7 @@ module HTTP
|
|
51
53
|
|
52
54
|
# Send a request to the server
|
53
55
|
#
|
54
|
-
# @param [Request] Request to send to the server
|
56
|
+
# @param [Request] req Request to send to the server
|
55
57
|
# @return [nil]
|
56
58
|
def send_request(req)
|
57
59
|
if @pending_response
|
@@ -186,9 +188,9 @@ module HTTP
|
|
186
188
|
|
187
189
|
case @parser.http_version
|
188
190
|
when HTTP_1_0 # HTTP/1.0 requires opt in for Keep Alive
|
189
|
-
@keep_alive = @parser.headers[
|
191
|
+
@keep_alive = @parser.headers[Headers::CONNECTION] == Client::KEEP_ALIVE
|
190
192
|
when HTTP_1_1 # HTTP/1.1 is opt-out
|
191
|
-
@keep_alive = @parser.headers[
|
193
|
+
@keep_alive = @parser.headers[Headers::CONNECTION] != Client::CLOSE
|
192
194
|
else # Anything else we assume doesn't supportit
|
193
195
|
@keep_alive = false
|
194
196
|
end
|
data/lib/http/headers.rb
CHANGED
@@ -2,6 +2,7 @@ require "forwardable"
|
|
2
2
|
|
3
3
|
require "http/errors"
|
4
4
|
require "http/headers/mixin"
|
5
|
+
require "http/headers/known"
|
5
6
|
|
6
7
|
module HTTP
|
7
8
|
# HTTP Headers container.
|
@@ -16,12 +17,6 @@ module HTTP
|
|
16
17
|
# @see http://tools.ietf.org/html/rfc7230#section-3.2
|
17
18
|
HEADER_NAME_RE = /^[A-Za-z0-9!#\$%&'*+\-.^_`|~]+$/
|
18
19
|
|
19
|
-
# Set-Cookie (response) header name
|
20
|
-
SET_COOKIE = "Set-Cookie".freeze
|
21
|
-
|
22
|
-
# Cookie (request) header name
|
23
|
-
COOKIE = "Cookie".freeze
|
24
|
-
|
25
20
|
# Class constructor.
|
26
21
|
def initialize
|
27
22
|
@pile = []
|
@@ -0,0 +1,78 @@
|
|
1
|
+
module HTTP
|
2
|
+
class Headers
|
3
|
+
# Content-Types that are acceptable for the response.
|
4
|
+
ACCEPT = "Accept".freeze
|
5
|
+
|
6
|
+
# The age the object has been in a proxy cache in seconds.
|
7
|
+
AGE = "Age".freeze
|
8
|
+
|
9
|
+
# Authentication credentials for HTTP authentication.
|
10
|
+
AUTHORIZATION = "Authorization".freeze
|
11
|
+
|
12
|
+
# Used to specify directives that must be obeyed by all caching mechanisms
|
13
|
+
# along the request-response chain.
|
14
|
+
CACHE_CONTROL = "Cache-Control".freeze
|
15
|
+
|
16
|
+
# An HTTP cookie previously sent by the server with Set-Cookie.
|
17
|
+
COOKIE = "Cookie".freeze
|
18
|
+
|
19
|
+
# Control options for the current connection and list
|
20
|
+
# of hop-by-hop request fields.
|
21
|
+
CONNECTION = "Connection".freeze
|
22
|
+
|
23
|
+
# The length of the request body in octets (8-bit bytes).
|
24
|
+
CONTENT_LENGTH = "Content-Length".freeze
|
25
|
+
|
26
|
+
# The MIME type of the body of the request
|
27
|
+
# (used with POST and PUT requests).
|
28
|
+
CONTENT_TYPE = "Content-Type".freeze
|
29
|
+
|
30
|
+
# The date and time that the message was sent (in "HTTP-date" format as
|
31
|
+
# defined by RFC 7231 Date/Time Formats).
|
32
|
+
DATE = "Date".freeze
|
33
|
+
|
34
|
+
# An identifier for a specific version of a resource,
|
35
|
+
# often a message digest.
|
36
|
+
ETAG = "ETag".freeze
|
37
|
+
|
38
|
+
# Gives the date/time after which the response is considered stale (in
|
39
|
+
# "HTTP-date" format as defined by RFC 7231).
|
40
|
+
EXPIRES = "Expires".freeze
|
41
|
+
|
42
|
+
# The domain name of the server (for virtual hosting), and the TCP port
|
43
|
+
# number on which the server is listening. The port number may be omitted
|
44
|
+
# if the port is the standard port for the service requested.
|
45
|
+
HOST = "Host".freeze
|
46
|
+
|
47
|
+
# Allows a 304 Not Modified to be returned if content is unchanged.
|
48
|
+
IF_MODIFIED_SINCE = "If-Modified-Since".freeze
|
49
|
+
|
50
|
+
# Allows a 304 Not Modified to be returned if content is unchanged.
|
51
|
+
IF_NONE_MATCH = "If-None-Match".freeze
|
52
|
+
|
53
|
+
# The last modified date for the requested object (in "HTTP-date" format as
|
54
|
+
# defined by RFC 7231).
|
55
|
+
LAST_MODIFIED = "Last-Modified".freeze
|
56
|
+
|
57
|
+
# Used in redirection, or when a new resource has been created.
|
58
|
+
LOCATION = "Location".freeze
|
59
|
+
|
60
|
+
# Authorization credentials for connecting to a proxy.
|
61
|
+
PROXY_AUTHORIZATION = "Proxy-Authorization".freeze
|
62
|
+
|
63
|
+
# An HTTP cookie.
|
64
|
+
SET_COOKIE = "Set-Cookie".freeze
|
65
|
+
|
66
|
+
# The form of encoding used to safely transfer the entity to the user.
|
67
|
+
# Currently defined methods are: chunked, compress, deflate, gzip, identity.
|
68
|
+
TRANSFER_ENCODING = "Transfer-Encoding".freeze
|
69
|
+
|
70
|
+
# The user agent string of the user agent.
|
71
|
+
USER_AGENT = "User-Agent".freeze
|
72
|
+
|
73
|
+
# Tells downstream proxies how to match future request headers to decide
|
74
|
+
# whether the cached response can be used rather than requesting a fresh
|
75
|
+
# one from the origin server.
|
76
|
+
VARY = "Vary".freeze
|
77
|
+
end
|
78
|
+
end
|
data/lib/http/redirector.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
require "set"
|
2
2
|
|
3
|
+
require "http/headers"
|
4
|
+
|
3
5
|
module HTTP
|
4
6
|
class Redirector
|
5
7
|
# Notifies that we reached max allowed redirect hops
|
@@ -35,9 +37,9 @@ module HTTP
|
|
35
37
|
# @param [Hash] opts
|
36
38
|
# @option opts [Boolean] :strict (true) redirector hops policy
|
37
39
|
# @option opts [#to_i] :max_hops (5) maximum allowed amount of hops
|
38
|
-
def initialize(
|
39
|
-
@strict =
|
40
|
-
@max_hops =
|
40
|
+
def initialize(opts = {})
|
41
|
+
@strict = opts.fetch(:strict, true)
|
42
|
+
@max_hops = opts.fetch(:max_hops, 5).to_i
|
41
43
|
end
|
42
44
|
|
43
45
|
# Follows redirects until non-redirect response found
|
@@ -52,7 +54,7 @@ module HTTP
|
|
52
54
|
fail TooManyRedirectsError if too_many_hops?
|
53
55
|
fail EndlessRedirectError if endless_loop?
|
54
56
|
|
55
|
-
@request = redirect_to @response.headers[
|
57
|
+
@request = redirect_to @response.headers[Headers::LOCATION]
|
56
58
|
@response = yield @request
|
57
59
|
end
|
58
60
|
|
data/lib/http/request.rb
CHANGED
@@ -79,14 +79,14 @@ module HTTP
|
|
79
79
|
|
80
80
|
@headers = HTTP::Headers.coerce(headers || {})
|
81
81
|
|
82
|
-
@headers[
|
83
|
-
@headers[
|
82
|
+
@headers[Headers::HOST] ||= default_host_header_value
|
83
|
+
@headers[Headers::USER_AGENT] ||= USER_AGENT
|
84
84
|
end
|
85
85
|
|
86
86
|
# Returns new Request with updated uri
|
87
87
|
def redirect(uri, verb = @verb)
|
88
88
|
req = self.class.new(verb, @uri.join(uri), headers, proxy, body, version)
|
89
|
-
req[
|
89
|
+
req[Headers::HOST] = req.uri.host
|
90
90
|
req
|
91
91
|
end
|
92
92
|
|
@@ -108,7 +108,7 @@ module HTTP
|
|
108
108
|
|
109
109
|
# Compute and add the Proxy-Authorization header
|
110
110
|
def include_proxy_authorization_header
|
111
|
-
headers[
|
111
|
+
headers[Headers::PROXY_AUTHORIZATION] = proxy_authorization_header
|
112
112
|
end
|
113
113
|
|
114
114
|
def proxy_authorization_header
|
@@ -138,10 +138,12 @@ module HTTP
|
|
138
138
|
# Headers to send with proxy connect request
|
139
139
|
def proxy_connect_headers
|
140
140
|
connect_headers = HTTP::Headers.coerce(
|
141
|
-
|
142
|
-
|
141
|
+
Headers::HOST => headers[Headers::HOST],
|
142
|
+
Headers::USER_AGENT => headers[Headers::USER_AGENT]
|
143
143
|
)
|
144
|
-
|
144
|
+
|
145
|
+
connect_headers[Headers::PROXY_AUTHORIZATION] = proxy_authorization_header if using_authenticated_proxy?
|
146
|
+
|
145
147
|
connect_headers
|
146
148
|
end
|
147
149
|
|
data/lib/http/request/caching.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "http/headers"
|
1
2
|
require "http/cache/headers"
|
2
3
|
|
3
4
|
module HTTP
|
@@ -76,17 +77,16 @@ module HTTP
|
|
76
77
|
private
|
77
78
|
|
78
79
|
# @return [Headers] conditional request headers
|
79
|
-
# @api private
|
80
80
|
def conditional_headers_for(cached_response)
|
81
81
|
headers = HTTP::Headers.new
|
82
82
|
|
83
|
-
cached_response.headers.get(
|
84
|
-
each { |etag| headers.add(
|
83
|
+
cached_response.headers.get(HTTP::Headers::ETAG).
|
84
|
+
each { |etag| headers.add(HTTP::Headers::IF_NONE_MATCH, etag) }
|
85
85
|
|
86
|
-
cached_response.headers.get(
|
87
|
-
each { |last_mod| headers.add(
|
86
|
+
cached_response.headers.get(HTTP::Headers::LAST_MODIFIED).
|
87
|
+
each { |last_mod| headers.add(HTTP::Headers::IF_MODIFIED_SINCE, last_mod) }
|
88
88
|
|
89
|
-
headers.add(
|
89
|
+
headers.add(HTTP::Headers::CACHE_CONTROL, "max-age=0") if cache_headers.forces_revalidation?
|
90
90
|
|
91
91
|
headers
|
92
92
|
end
|
data/lib/http/request/writer.rb
CHANGED
@@ -1,8 +1,16 @@
|
|
1
|
+
require "http/headers"
|
2
|
+
|
1
3
|
module HTTP
|
2
4
|
class Request
|
3
5
|
class Writer
|
4
6
|
# CRLF is the universal HTTP delimiter
|
5
|
-
CRLF = "\r\n"
|
7
|
+
CRLF = "\r\n".freeze
|
8
|
+
|
9
|
+
# Chunked data termintaor.
|
10
|
+
ZERO = "0".freeze
|
11
|
+
|
12
|
+
# Chunked transfer encoding
|
13
|
+
CHUNKED = "chunked".freeze
|
6
14
|
|
7
15
|
# Types valid to be used as body source
|
8
16
|
VALID_BODY_TYPES = [String, NilClass, Enumerable]
|
@@ -38,9 +46,9 @@ module HTTP
|
|
38
46
|
# Adds the headers to the header array for the given request body we are working
|
39
47
|
# with
|
40
48
|
def add_body_type_headers
|
41
|
-
if @body.is_a?(String) && !@headers[
|
42
|
-
@request_header << "
|
43
|
-
elsif @body.is_a?(Enumerable) &&
|
49
|
+
if @body.is_a?(String) && !@headers[Headers::CONTENT_LENGTH]
|
50
|
+
@request_header << "#{Headers::CONTENT_LENGTH}: #{@body.bytesize}"
|
51
|
+
elsif @body.is_a?(Enumerable) && CHUNKED != @headers[Headers::TRANSFER_ENCODING]
|
44
52
|
fail(RequestError, "invalid transfer encoding")
|
45
53
|
end
|
46
54
|
end
|
@@ -69,7 +77,7 @@ module HTTP
|
|
69
77
|
@socket << chunk << CRLF
|
70
78
|
end
|
71
79
|
|
72
|
-
@socket <<
|
80
|
+
@socket << ZERO << CRLF << CRLF
|
73
81
|
end
|
74
82
|
end
|
75
83
|
|
data/lib/http/response.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
require "http/headers"
|
1
2
|
require "http/cache/headers"
|
2
3
|
require "http/response/string_body"
|
3
4
|
require "http/response/io_body"
|
@@ -25,7 +26,7 @@ module HTTP
|
|
25
26
|
expired? || cache_headers.must_revalidate?
|
26
27
|
end
|
27
28
|
|
28
|
-
# @
|
29
|
+
# @return [Boolean] true iff this response has expired
|
29
30
|
def expired?
|
30
31
|
current_age >= cache_headers.max_age
|
31
32
|
end
|
@@ -52,7 +53,7 @@ module HTTP
|
|
52
53
|
# Algo from https://tools.ietf.org/html/rfc2616#section-13.2.3
|
53
54
|
def current_age
|
54
55
|
now = Time.now
|
55
|
-
age_value = headers.get(
|
56
|
+
age_value = headers.get(HTTP::Headers::AGE).map(&:to_i).max || 0
|
56
57
|
|
57
58
|
apparent_age = [0, received_at - server_response_time].max
|
58
59
|
corrected_received_age = [apparent_age, age_value].max
|
@@ -116,18 +117,18 @@ module HTTP
|
|
116
117
|
end
|
117
118
|
|
118
119
|
def vary
|
119
|
-
headers.get(
|
120
|
+
headers.get(HTTP::Headers::VARY).first
|
120
121
|
end
|
121
122
|
|
122
123
|
protected
|
123
124
|
|
124
125
|
# @return [Time] the time at which the server generated this response.
|
125
126
|
def server_response_time
|
126
|
-
headers.get(
|
127
|
+
headers.get(HTTP::Headers::DATE).
|
127
128
|
map(&method(:to_time_or_epoch)).
|
128
129
|
max || begin
|
129
130
|
# set it if it is not already set
|
130
|
-
headers[
|
131
|
+
headers[HTTP::Headers::DATE] = received_at.httpdate
|
131
132
|
received_at
|
132
133
|
end
|
133
134
|
end
|
data/lib/http/response/status.rb
CHANGED
@@ -78,20 +78,28 @@ module HTTP
|
|
78
78
|
REASONS[code]
|
79
79
|
end
|
80
80
|
|
81
|
+
# @return [String] string representation of HTTP status
|
82
|
+
def to_s
|
83
|
+
"#{code} #{reason}".strip
|
84
|
+
end
|
85
|
+
|
81
86
|
# Symbolized {#reason}
|
82
87
|
#
|
83
88
|
# @return [nil] unless code is well-known (see REASONS)
|
84
89
|
# @return [Symbol]
|
85
|
-
def
|
90
|
+
def to_sym
|
86
91
|
SYMBOLS[code]
|
87
92
|
end
|
88
93
|
|
94
|
+
# @deprecated Will be removed in 1.0.0
|
95
|
+
alias_method :symbolize, :to_sym
|
96
|
+
|
89
97
|
# Printable version of HTTP Status, surrounded by quote marks,
|
90
98
|
# with special characters escaped.
|
91
99
|
#
|
92
100
|
# (see String#inspect)
|
93
101
|
def inspect
|
94
|
-
"
|
102
|
+
"#<#{self.class} #{self}>"
|
95
103
|
end
|
96
104
|
|
97
105
|
SYMBOLS.each do |code, symbol|
|
data/lib/http/version.rb
CHANGED
@@ -55,7 +55,7 @@ RSpec.describe HTTP::Response::Status do
|
|
55
55
|
describe "#inspect" do
|
56
56
|
it "returns quoted code and reason phrase" do
|
57
57
|
status = described_class.new 200
|
58
|
-
expect(status.inspect).to eq
|
58
|
+
expect(status.inspect).to eq "#<HTTP::Response::Status 200 OK>"
|
59
59
|
end
|
60
60
|
end
|
61
61
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.12
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tony Arcieri
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-05-
|
14
|
+
date: 2015-05-26 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: http_parser.rb
|
@@ -116,6 +116,7 @@ files:
|
|
116
116
|
- lib/http/content_type.rb
|
117
117
|
- lib/http/errors.rb
|
118
118
|
- lib/http/headers.rb
|
119
|
+
- lib/http/headers/known.rb
|
119
120
|
- lib/http/headers/mixin.rb
|
120
121
|
- lib/http/mime_type.rb
|
121
122
|
- lib/http/mime_type/adapter.rb
|
@@ -195,45 +196,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
195
196
|
version: '0'
|
196
197
|
requirements: []
|
197
198
|
rubyforge_project:
|
198
|
-
rubygems_version: 2.
|
199
|
+
rubygems_version: 2.2.3
|
199
200
|
signing_key:
|
200
201
|
specification_version: 4
|
201
202
|
summary: HTTP should be easy
|
202
|
-
test_files:
|
203
|
-
- spec/lib/http/cache/headers_spec.rb
|
204
|
-
- spec/lib/http/cache_spec.rb
|
205
|
-
- spec/lib/http/client_spec.rb
|
206
|
-
- spec/lib/http/content_type_spec.rb
|
207
|
-
- spec/lib/http/headers/mixin_spec.rb
|
208
|
-
- spec/lib/http/headers_spec.rb
|
209
|
-
- spec/lib/http/options/body_spec.rb
|
210
|
-
- spec/lib/http/options/form_spec.rb
|
211
|
-
- spec/lib/http/options/headers_spec.rb
|
212
|
-
- spec/lib/http/options/json_spec.rb
|
213
|
-
- spec/lib/http/options/merge_spec.rb
|
214
|
-
- spec/lib/http/options/new_spec.rb
|
215
|
-
- spec/lib/http/options/proxy_spec.rb
|
216
|
-
- spec/lib/http/options_spec.rb
|
217
|
-
- spec/lib/http/redirector_spec.rb
|
218
|
-
- spec/lib/http/request/caching_spec.rb
|
219
|
-
- spec/lib/http/request/writer_spec.rb
|
220
|
-
- spec/lib/http/request_spec.rb
|
221
|
-
- spec/lib/http/response/body_spec.rb
|
222
|
-
- spec/lib/http/response/caching_spec.rb
|
223
|
-
- spec/lib/http/response/io_body_spec.rb
|
224
|
-
- spec/lib/http/response/status_spec.rb
|
225
|
-
- spec/lib/http/response/string_body_spec.rb
|
226
|
-
- spec/lib/http/response_spec.rb
|
227
|
-
- spec/lib/http_spec.rb
|
228
|
-
- spec/spec_helper.rb
|
229
|
-
- spec/support/black_hole.rb
|
230
|
-
- spec/support/capture_warning.rb
|
231
|
-
- spec/support/connection_reuse_shared.rb
|
232
|
-
- spec/support/dummy_server.rb
|
233
|
-
- spec/support/dummy_server/servlet.rb
|
234
|
-
- spec/support/http_handling_shared.rb
|
235
|
-
- spec/support/proxy_server.rb
|
236
|
-
- spec/support/servers/config.rb
|
237
|
-
- spec/support/servers/runner.rb
|
238
|
-
- spec/support/ssl_helper.rb
|
203
|
+
test_files: []
|
239
204
|
has_rdoc:
|