http2 0.0.35 → 0.0.36

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
2
  SHA256:
3
- metadata.gz: ff94aecdfbfa493bb62b38edeef5a2bf49f9b5fb16ce5f023e6928ed77cb21c7
4
- data.tar.gz: d8858f9e7daf39ed428311db9af0d561c971780d249cf0d0932a36962c921884
3
+ metadata.gz: aaaa3b5476a0d9233f4ef5977f64d0368f009021f92bd821280058f518463bca
4
+ data.tar.gz: 24942b90af076019fc755a6abdc61ae049ec2a7178dcad6f6df5c0aba9c5a945
5
5
  SHA512:
6
- metadata.gz: 04205c61f20290a3dec42a1c7a78b380ac749e0245ea53ba13f1a65cc983140e486a73fd26bf1e8a6ad808cde9a97d98ab9ba982f984726386d0b6db201da8d3
7
- data.tar.gz: 413150d064f99e448cfcb0cca6380a6677b8e525ffcbbdaebfd957b5b7a6c263aeb105562ffcb6e8584603fd097a7fcfbda13327a662d7ba9927ad2e0d077afa
6
+ metadata.gz: eb01eb1aab89764bcaa356f5c89341e926ef0ebe5818aa5b22be70e64dd0e926f6ab9807723ae15b0f33d125397be759c89d5e896ab3b25d486b312bd44e252c
7
+ data.tar.gz: 7ff240f8d775175b3b5f9fdbfe1f8a4d380c83c26729c3c31730672d5e3dbea1e8d3ccc8899f39c06f27199799243c87b8de9c6483d00ff8335fb1c279a024e5
@@ -132,7 +132,7 @@ class Http2::Connection
132
132
  @sock_plain.write(@nl)
133
133
 
134
134
  res = @sock_plain.gets.to_s
135
- raise "Couldn't connect through proxy: #{res}" unless res.match(/^http\/1\.(0|1)\s+200/i)
135
+ raise "Couldn't connect through proxy: #{res}" unless res.match?(/^http\/1\.(0|1)\s+200/i)
136
136
 
137
137
  @sock_plain.gets
138
138
 
@@ -103,15 +103,17 @@ private
103
103
  @url ||= response.header("location")
104
104
  end
105
105
 
106
+ SSL_AND_PORT_KEYS = [:ssl, :port].freeze
107
+
106
108
  def url_and_args_from_location
107
109
  uri = URI.parse(url)
108
110
 
109
111
  url = uri.path
110
112
  url << "?#{uri.query}" unless uri.query.to_s.empty?
111
- url = url.gsub(/\A\//, "")
113
+ url = url.delete_prefix("/")
112
114
 
113
115
  args = @http2.args
114
- .reject { |k, _v| [:ssl, :port].include? k }
116
+ .reject { |k, _v| SSL_AND_PORT_KEYS.include?(k) }
115
117
  .merge(host: uri.host)
116
118
 
117
119
  args[:ssl] = true if uri.scheme == "https"
@@ -1,9 +1,9 @@
1
1
  require "spec_helper"
2
2
 
3
- describe Http2 do
3
+ describe Http2::Cookie do
4
4
  include Helpers
5
5
 
6
- it "should parse cookies and let them be read" do
6
+ it "parses cookies and let them be read" do
7
7
  with_http do |http|
8
8
  http.get("cookie_test.rhtml")
9
9
  expect(http.cookies.length).to eq 2
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Http2::PostDataGenerator do
4
- it "should be able to recursively parse post-data-hashes." do
4
+ it "recursively parses post-data-hashes." do
5
5
  res = Http2::PostDataGenerator.new(
6
6
  "test1" => "test2"
7
7
  ).generate
@@ -25,14 +25,14 @@ describe Http2::Response do
25
25
  end
26
26
  end
27
27
 
28
- it "returns true for 'application/json'" do
28
+ it "returns true for 'application/json' and getting" do
29
29
  with_http do |http|
30
30
  res = http.get("json_test.rhtml")
31
31
  expect(res.json?).to eq true
32
32
  end
33
33
  end
34
34
 
35
- it "returns true for 'application/json'" do
35
+ it "returns true for 'application/json' and posting" do
36
36
  with_http do |http|
37
37
  res = http.post(url: "json_test.rhtml", post: {test: "test2"})
38
38
 
@@ -1,7 +1,7 @@
1
1
  require "spec_helper"
2
2
 
3
3
  describe Http2::UrlBuilder do
4
- context "#build" do
4
+ describe "#build" do
5
5
  it "builds correctly" do
6
6
  ub = Http2::UrlBuilder.new
7
7
  ub.protocol = "https"
data/spec/http2_spec.rb CHANGED
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
  require "json"
3
3
 
4
4
  describe "Http2" do
5
- it "should be able to do normal post-requests." do
5
+ it "does normal post-requests" do
6
6
  # Test posting keep-alive and advanced post-data.
7
7
  with_http do |http|
8
8
  0.upto(5) do
@@ -44,17 +44,19 @@ describe "Http2" do
44
44
  end
45
45
  end
46
46
 
47
- it "#reconnect" do
48
- with_http(follow_redirects: false, encoding_gzip: false) do |http|
49
- resp1 = http.get("multipart_test.rhtml")
50
- http.reconnect
51
- resp2 = http.get("multipart_test.rhtml")
47
+ describe "#reconnect" do
48
+ it "reconnects" do
49
+ with_http(follow_redirects: false, encoding_gzip: false) do |http|
50
+ resp1 = http.get("multipart_test.rhtml")
51
+ http.reconnect
52
+ resp2 = http.get("multipart_test.rhtml")
52
53
 
53
- expect(resp1.body).to eq resp2.body
54
+ expect(resp1.body).to eq resp2.body
55
+ end
54
56
  end
55
57
  end
56
58
 
57
- it "should be able to do multipart-requests and keep-alive when using multipart." do
59
+ it "handles multipart-requests and keep-alive when using multipart." do
58
60
  with_http(follow_redirects: false) do |http|
59
61
  0.upto(5) do
60
62
  fpath = File.realpath(__FILE__)
@@ -84,7 +86,7 @@ describe "Http2" do
84
86
  end
85
87
  end
86
88
 
87
- it "it should be able to handle keep-alive correctly" do
89
+ it "handles keep-alive correctly" do
88
90
  urls = [
89
91
  "content_type_test.rhtml",
90
92
  "json_test.rhtml"
@@ -100,13 +102,13 @@ describe "Http2" do
100
102
  end
101
103
  end
102
104
 
103
- it "should raise exception when something is not found" do
105
+ it "raises an error when something is not found" do
104
106
  with_http do |http|
105
107
  expect { http.get("something_that_does_not_exist.rhtml") }.to raise_error(::Http2::Errors::Notfound)
106
108
  end
107
109
  end
108
110
 
109
- it "should be able to post json" do
111
+ it "posts json" do
110
112
  with_http do |http|
111
113
  res = http.post(
112
114
  url: "json_test.rhtml",
@@ -126,7 +128,7 @@ describe "Http2" do
126
128
  end
127
129
  end
128
130
 
129
- it "should be able to post custom content types" do
131
+ it "posts custom content types" do
130
132
  with_http do |http|
131
133
  res = http.post(
132
134
  url: "content_type_test.rhtml",
@@ -142,7 +144,7 @@ describe "Http2" do
142
144
  end
143
145
  end
144
146
 
145
- it "should set various timeouts" do
147
+ it "sets various timeouts" do
146
148
  with_http do |http|
147
149
  http.get("content_type_test.rhtml")
148
150
  expect(http.keepalive_timeout).to eq 15
@@ -150,7 +152,7 @@ describe "Http2" do
150
152
  end
151
153
  end
152
154
 
153
- it "should follow redirects" do
155
+ it "follows redirects" do
154
156
  with_http(follow_redirects: true) do |http|
155
157
  resp = http.get("redirect_test.rhtml")
156
158
  expect(resp.code).to eq "200"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: http2
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.35
4
+ version: 0.0.36
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kasper Johansen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-10-04 00:00:00.000000000 Z
11
+ date: 2021-11-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: string-cases
@@ -136,6 +136,34 @@ dependencies:
136
136
  - - ">="
137
137
  - !ruby/object:Gem::Version
138
138
  version: '0'
139
+ - !ruby/object:Gem::Dependency
140
+ name: rubocop-performance
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: rubocop-rspec
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
139
167
  - !ruby/object:Gem::Dependency
140
168
  name: sqlite3
141
169
  requirement: !ruby/object:Gem::Requirement
@@ -218,21 +246,21 @@ specification_version: 4
218
246
  summary: A lightweight framework for doing http-connections in Ruby. Supports cookies,
219
247
  keep-alive, compressing and much more.
220
248
  test_files:
249
+ - spec/http2/post_multipart_request_spec.rb
250
+ - spec/http2/response_reader_spec.rb
251
+ - spec/http2/get_request_spec.rb
252
+ - spec/http2/url_builder_spec.rb
253
+ - spec/http2/cookies_spec.rb
254
+ - spec/http2/post_data_generator_spec.rb
255
+ - spec/http2/post_request_spec.rb
256
+ - spec/http2/response_spec.rb
221
257
  - spec/helpers.rb
222
258
  - spec/http2_spec.rb
223
- - spec/spec_root/unauthorized.rhtml
259
+ - spec/spec_helper.rb
224
260
  - spec/spec_root/json_test.rhtml
225
- - spec/spec_root/content_type_test.rhtml
261
+ - spec/spec_root/unauthorized.rhtml
226
262
  - spec/spec_root/redirect_test.rhtml
227
- - spec/spec_root/multipart_test.rhtml
228
263
  - spec/spec_root/cookie_test.rhtml
264
+ - spec/spec_root/content_type_test.rhtml
265
+ - spec/spec_root/multipart_test.rhtml
229
266
  - spec/spec_root/unsupported_media_type.rhtml
230
- - spec/spec_helper.rb
231
- - spec/http2/cookies_spec.rb
232
- - spec/http2/get_request_spec.rb
233
- - spec/http2/url_builder_spec.rb
234
- - spec/http2/post_multipart_request_spec.rb
235
- - spec/http2/post_data_generator_spec.rb
236
- - spec/http2/post_request_spec.rb
237
- - spec/http2/response_reader_spec.rb
238
- - spec/http2/response_spec.rb