http 3.2.0 → 3.3.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: f5e1c6e74ac078db494c4b2196a43018b75db1dc
4
- data.tar.gz: 8bf04adb251ff46dc31190ce865736c13c7317a2
2
+ SHA256:
3
+ metadata.gz: 853087de359024f397422b0563f0232edfa247c2f201a060c10b7b8ea9aff00b
4
+ data.tar.gz: b07ad1d88da70f9d76c5e272923dab3ce763077a8f8f7cb9ee6c37602acb6bb5
5
5
  SHA512:
6
- metadata.gz: 702c1c5e63d582319859b9f6da99d4192141f6162237e593bb50e70e87cb0a54e0b6bcc43bfedce1e02cb1b7cc2c7cfbf18fcab903cf99a5b4f6362419a98d44
7
- data.tar.gz: 44e4070afc9aeae5b0ba5c5f6c74d87df2c5a5656175e26d3cc485418316e84ec23c36dccd7e9b4d2a9595b09d117a1bdff0714cca432f337cc770b3840da222
6
+ metadata.gz: 654f47604b4e77c1138f9b82b5b902bf5d47f3bdc73979594633fc1d15c991eab5d933f001f1e6671bd432c498127f9b3ddb89cc2dc93fd3b792461961f1f1a0
7
+ data.tar.gz: 4f8e97ea9830b1f36d5a0d636807e3f1296176640c2876d0f66c59d0643954e663d5c35ab14a538220b5f669195109a367b70d6ad281898ecb3830ce573cd485
data/CHANGES.md CHANGED
@@ -1,6 +1,23 @@
1
+ ## 3.3.0 (2018-04-25)
2
+
3
+ This version backports some of the fixes and improvements made to development
4
+ version of the HTTP gem:
5
+
6
+ * [#458](https://github.com/httprb/http/pull/458)
7
+ Extract HTTP::Client#build_request method.
8
+ ([@tycoon])
9
+
10
+
11
+ ## 3.2.1 (2018-04-24)
12
+
13
+ * [#468](https://github.com/httprb/http/pull/468)
14
+ Rewind `HTTP::Request::Body#source` once `#each` is complete.
15
+ ([@ixti])
16
+
17
+
1
18
  ## 3.2.0 (2018-04-22)
2
19
 
3
- This vresion backports one change we missed to backport in previous release:
20
+ This version backports one change we missed to backport in previous release:
4
21
 
5
22
  * Reduce memory usage when reading response body
6
23
  ([@janko-m])
@@ -650,3 +667,4 @@ end
650
667
  [@marshall-lee]: https://github.com/marshall-lee
651
668
  [@scarfacedeb]: https://github.com/scarfacedeb
652
669
  [@mikegee]: https://github.com/mikegee
670
+ [@tycoon]: https://github.com/tycooon
@@ -70,12 +70,21 @@ module HTTP
70
70
  end
71
71
 
72
72
  # Make an HTTP request with the given verb
73
+ # @param verb
73
74
  # @param uri
74
75
  # @option options [Hash]
75
76
  def request(verb, uri, options = {}) # rubocop:disable Style/OptionHash
76
77
  branch(options).request verb, uri
77
78
  end
78
79
 
80
+ # Prepare an HTTP request with the given verb
81
+ # @param verb
82
+ # @param uri
83
+ # @option options [Hash]
84
+ def build_request(verb, uri, options = {}) # rubocop:disable Style/OptionHash
85
+ branch(options).build_request verb, uri
86
+ end
87
+
79
88
  # @overload timeout(options = {})
80
89
  # Syntax sugar for `timeout(:per_operation, options)`
81
90
  # @overload timeout(klass, options = {})
data/lib/http/client.rb CHANGED
@@ -25,13 +25,25 @@ module HTTP
25
25
 
26
26
  # Make an HTTP request
27
27
  def request(verb, uri, opts = {}) # rubocop:disable Style/OptionHash
28
+ opts = @default_options.merge(opts)
29
+ req = build_request(verb, uri, opts)
30
+ res = perform(req, opts)
31
+ return res unless opts.follow
32
+
33
+ Redirector.new(opts.follow).perform(req, res) do |request|
34
+ perform(request, opts)
35
+ end
36
+ end
37
+
38
+ # Prepare an HTTP request
39
+ def build_request(verb, uri, opts = {}) # rubocop:disable Style/OptionHash
28
40
  opts = @default_options.merge(opts)
29
41
  uri = make_request_uri(uri, opts)
30
42
  headers = make_request_headers(opts)
31
43
  body = make_request_body(opts, headers)
32
44
  proxy = opts.proxy
33
45
 
34
- req = HTTP::Request.new(
46
+ HTTP::Request.new(
35
47
  :verb => verb,
36
48
  :uri => uri,
37
49
  :headers => headers,
@@ -39,13 +51,6 @@ module HTTP
39
51
  :body => body,
40
52
  :auto_deflate => opts.feature(:auto_deflate)
41
53
  )
42
-
43
- res = perform(req, opts)
44
- return res unless opts.follow
45
-
46
- Redirector.new(opts.follow).perform(req, res) do |request|
47
- perform(request, opts)
48
- end
49
54
  end
50
55
 
51
56
  # @!method persistent?
@@ -35,6 +35,7 @@ module HTTP
35
35
  yield @source
36
36
  elsif @source.respond_to?(:read)
37
37
  IO.copy_stream(@source, ProcIO.new(block))
38
+ @source.rewind if @source.respond_to?(:rewind)
38
39
  elsif @source.is_a?(Enumerable)
39
40
  @source.each(&block)
40
41
  end
data/lib/http/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module HTTP
4
- VERSION = "3.2.0"
4
+ VERSION = "3.3.0"
5
5
  end
@@ -126,10 +126,26 @@ RSpec.describe HTTP::Request::Body do
126
126
  end
127
127
 
128
128
  context "when body is an Enumerable IO" do
129
- let(:body) { StringIO.new("a" * 16 * 1024 + "b" * 10 * 1024) }
129
+ let(:data) { "a" * 16 * 1024 + "b" * 10 * 1024 }
130
+ let(:body) { StringIO.new data }
130
131
 
131
132
  it "yields chunks of content" do
132
- expect(chunks.inject("", :+)).to eq "a" * 16 * 1024 + "b" * 10 * 1024
133
+ expect(chunks.inject("", :+)).to eq data
134
+ end
135
+
136
+ it "allows to enumerate multiple times" do
137
+ results = []
138
+
139
+ 2.times do
140
+ result = ""
141
+ subject.each { |chunk| result += chunk }
142
+ results << result
143
+ end
144
+
145
+ aggregate_failures do
146
+ expect(results.count).to eq 2
147
+ expect(results).to all eq data
148
+ end
133
149
  end
134
150
  end
135
151
 
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: 3.2.0
4
+ version: 3.3.0
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: 2018-04-22 00:00:00.000000000 Z
14
+ date: 2018-04-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: http_parser.rb
@@ -195,7 +195,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
195
195
  version: '0'
196
196
  requirements: []
197
197
  rubyforge_project:
198
- rubygems_version: 2.5.2.3
198
+ rubygems_version: 2.7.6
199
199
  signing_key:
200
200
  specification_version: 4
201
201
  summary: HTTP should be easy