tilia-http 4.1.0.8 → 4.2.1
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/CHANGELOG.sabre.md +15 -0
- data/Gemfile +1 -9
- data/Gemfile.lock +16 -10
- data/examples/asyncclient.rb +1 -5
- data/examples/basicauth.rb +1 -5
- data/examples/client.rb +1 -5
- data/examples/digestauth.rb +37 -0
- data/examples/reverseproxy.rb +1 -1
- data/examples/stringify.rb +1 -5
- data/lib/tilia/http/auth/abstract_auth.rb +0 -19
- data/lib/tilia/http/auth/aws.rb +7 -21
- data/lib/tilia/http/auth/digest.rb +15 -26
- data/lib/tilia/http/client.rb +23 -66
- data/lib/tilia/http/client_exception.rb +1 -1
- data/lib/tilia/http/client_http_exception.rb +2 -11
- data/lib/tilia/http/http_exception.rb +1 -1
- data/lib/tilia/http/message.rb +33 -140
- data/lib/tilia/http/message_decorator_trait.rb +15 -113
- data/lib/tilia/http/message_interface.rb +19 -18
- data/lib/tilia/http/request.rb +21 -121
- data/lib/tilia/http/request_decorator.rb +15 -77
- data/lib/tilia/http/request_interface.rb +11 -11
- data/lib/tilia/http/response.rb +13 -41
- data/lib/tilia/http/response_decorator.rb +4 -19
- data/lib/tilia/http/response_interface.rb +3 -3
- data/lib/tilia/http/sapi.rb +4 -4
- data/lib/tilia/http/url_util.rb +2 -2
- data/lib/tilia/http/util.rb +5 -5
- data/lib/tilia/http/version.rb +1 -1
- data/lib/tilia/http.rb +9 -9
- data/test/http/message_test.rb +24 -4
- data/test/http/url_util_test.rb +1 -1
- data/tilia-http.gemspec +1 -1
- metadata +7 -6
data/lib/tilia/http.rb
CHANGED
@@ -56,9 +56,9 @@ module Tilia
|
|
56
56
|
# http://tools.ietf.org/html/rfc7231#section-7.1.1.1
|
57
57
|
#
|
58
58
|
# @param [String] date_string
|
59
|
-
# @return
|
59
|
+
# @return [Time, nil]
|
60
60
|
def self.parse_date(date_string)
|
61
|
-
return
|
61
|
+
return nil if date_string.blank?
|
62
62
|
|
63
63
|
# Only the format is checked, valid ranges are checked by strtotime below
|
64
64
|
month = '(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)'
|
@@ -83,7 +83,7 @@ module Tilia
|
|
83
83
|
# allow for space around the string and strip it
|
84
84
|
date_string.strip!
|
85
85
|
|
86
|
-
return
|
86
|
+
return nil unless date_string =~ /^#{http_date}$/
|
87
87
|
|
88
88
|
date = Time.zone.parse date_string
|
89
89
|
|
@@ -112,7 +112,7 @@ module Tilia
|
|
112
112
|
|
113
113
|
# Transforms a DateTime object to a valid HTTP/1.1 Date header value
|
114
114
|
#
|
115
|
-
# @param
|
115
|
+
# @param [Time] date_time
|
116
116
|
# @return [String]
|
117
117
|
def self.to_date(date_time)
|
118
118
|
# We need to clone it, as we don't want to affect the existing
|
@@ -136,10 +136,10 @@ module Tilia
|
|
136
136
|
# implying that no accept header was sent.
|
137
137
|
#
|
138
138
|
# @param [String, nil] accept_header_value
|
139
|
-
# @param
|
139
|
+
# @param [Array<String>] available_options
|
140
140
|
# @return [String, nil]
|
141
141
|
def self.negotiate_content_type(accept_header_value, available_options)
|
142
|
-
|
142
|
+
if accept_header_value.blank?
|
143
143
|
# Grabbing the first in the list.
|
144
144
|
return available_options[0]
|
145
145
|
end
|
@@ -223,7 +223,7 @@ module Tilia
|
|
223
223
|
# Parameters are currently discarded. There's no known prefer value that
|
224
224
|
# uses them.
|
225
225
|
#
|
226
|
-
# @param [String, Array<String>]
|
226
|
+
# @param [String, Array<String>] input
|
227
227
|
# @return array
|
228
228
|
def self.parse_prefer(input)
|
229
229
|
token = '[!#$%&\'*+\-.^_`~A-Za-z0-9]+'
|
@@ -287,7 +287,7 @@ $
|
|
287
287
|
#
|
288
288
|
# @param [String, Array<String>] values
|
289
289
|
# @param [String, Array<String>] values2
|
290
|
-
# @return [String]
|
290
|
+
# @return [Array<String>]
|
291
291
|
def self.header_values(values, values2 = nil)
|
292
292
|
values = [values] unless values.is_a?(Array)
|
293
293
|
if values2
|
@@ -313,7 +313,7 @@ $
|
|
313
313
|
# 4. parameters
|
314
314
|
#
|
315
315
|
# @param [String] str
|
316
|
-
# @return
|
316
|
+
# @return [Hash, nil]
|
317
317
|
def self.parse_mime_type(str)
|
318
318
|
parameters = {}
|
319
319
|
# If no q= parameter appears, then quality = 1.
|
data/test/http/message_test.rb
CHANGED
@@ -36,6 +36,30 @@ module Tilia
|
|
36
36
|
assert_equal(body, message.body)
|
37
37
|
end
|
38
38
|
|
39
|
+
# It's possible that streams contains more data than the Content-Length.
|
40
|
+
#
|
41
|
+
# The request object should make sure to never emit more than
|
42
|
+
# Content-Length, if Content-Length is set.
|
43
|
+
#
|
44
|
+
# This is in particular useful when respoding to range requests with
|
45
|
+
# streams that represent files on the filesystem, as it's possible to just
|
46
|
+
# seek the stream to a certain point, set the content-length and let the
|
47
|
+
# request object do the rest.
|
48
|
+
def test_long_stream_to_string_body
|
49
|
+
body = StringIO.new
|
50
|
+
body.write('abcdefg')
|
51
|
+
body.seek(2)
|
52
|
+
|
53
|
+
message = MessageMock.new
|
54
|
+
message.body = body
|
55
|
+
message.update_header('Content-Length', '4')
|
56
|
+
|
57
|
+
assert_equal(
|
58
|
+
'cdef',
|
59
|
+
message.body_as_string
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
39
63
|
def test_get_empty_body_stream
|
40
64
|
message = MessageMock.new
|
41
65
|
body = message.body_as_stream
|
@@ -154,10 +178,6 @@ module Tilia
|
|
154
178
|
|
155
179
|
class MessageMock
|
156
180
|
include Message
|
157
|
-
|
158
|
-
def initialize
|
159
|
-
initialize_message
|
160
|
-
end
|
161
181
|
end
|
162
182
|
end
|
163
183
|
end
|
data/test/http/url_util_test.rb
CHANGED
data/tilia-http.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.email = 'tilia@jakobsack.de'
|
10
10
|
s.files = `git ls-files`.split("\n")
|
11
11
|
s.homepage = 'https://github.com/tilia/tilia-http'
|
12
|
-
s.add_runtime_dependency 'activesupport', '
|
12
|
+
s.add_runtime_dependency 'activesupport', '>= 4.0'
|
13
13
|
s.add_runtime_dependency 'typhoeus', '~> 0.8'
|
14
14
|
s.add_runtime_dependency 'rchardet', '~>1.6'
|
15
15
|
s.add_runtime_dependency 'tilia-event', '~> 2.0'
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: tilia-http
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.1
|
4
|
+
version: 4.2.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakob Sack
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-02-
|
11
|
+
date: 2016-02-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '4.
|
19
|
+
version: '4.0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '4.
|
26
|
+
version: '4.0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: typhoeus
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -119,6 +119,7 @@ files:
|
|
119
119
|
- examples/asyncclient.rb
|
120
120
|
- examples/basicauth.rb
|
121
121
|
- examples/client.rb
|
122
|
+
- examples/digestauth.rb
|
122
123
|
- examples/reverseproxy.rb
|
123
124
|
- examples/stringify.rb
|
124
125
|
- lib/tilia/http.rb
|