nethttputils 0.3.2.10 → 0.3.2.11

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ee1c0a46857d320778ba8a0816cd7e3cb7018fe9
4
- data.tar.gz: 1ade1c1f815b7fd75924cdcbed5ce4b732a51570
3
+ metadata.gz: 4bc1f0212b03ef427e313966fff8e8431f35b0fd
4
+ data.tar.gz: 1751888f47d8d2252a52549ec96126c768ebcbba
5
5
  SHA512:
6
- metadata.gz: 7598d560362cee4112042c59a2710b5d757b29fd3eb4153093f2058ba8c7d7802b9f0ac72c9a9a11c1d2947ae104907c3b0dafb9a2def12d47a5662a59605fa6
7
- data.tar.gz: cc0d7b860a63b7076ee405ded44f0b3c6c0183534b40cc1d6a1ac9030f23f6b06be9d1063a9c4da96325360a9f7fe298b4e336fb2b8295420ace73b4cef5dbf4
6
+ metadata.gz: a047da71bab1fdfa59c4dc1281654ca95914327ebf248080e884d414fdbce39ab0820c84199a359152c29c7f8a749993e9ddcad68238c44bea8a186b29ebf945
7
+ data.tar.gz: 12a74c116dd99b6d0e9c98f5cc4a2cb6f7c33b31cb939478b1e7c4763e8bf52108405d94200da74bdff672bc94870da1bba6d8d81186220e2b9e673a19ecbdec
@@ -18,7 +18,7 @@ module NetHTTPUtils
18
18
  attr_reader :code
19
19
  def initialize body, code = nil
20
20
  @code = code
21
- super "HTTP error ##{code} #{body}"
21
+ super "HTTP error ##{code.inspect} #{body}"
22
22
  end
23
23
  end
24
24
 
@@ -219,11 +219,12 @@ module NetHTTPUtils
219
219
  logger.info "redirect: #{response["location"]}"
220
220
  new_uri = URI.join request.uri, URI.escape(response["location"])
221
221
  new_host = new_uri.host
222
+ raise Error.new "redirected in place" if new_uri == http.instance_variable_get(:@uri)
222
223
  if http.address != new_host ||
223
224
  http.port != new_uri.port ||
224
225
  http.use_ssl? != (new_uri.scheme == "https")
225
226
  logger.debug "changing host from '#{http.address}' to '#{new_host}'"
226
- # http.finish
227
+ # http.finish # why commented out?
227
228
  http = NetHTTPUtils.start_http new_uri, http.instance_variable_get(:@max_start_http_retry_delay), timeout
228
229
  end
229
230
  if request.method == "POST"
@@ -349,6 +350,24 @@ if $0 == __FILE__
349
350
  require "json"
350
351
  Thread.abort_on_exception = true
351
352
 
353
+ server = WEBrick::HTTPServer.new Port: 8000
354
+ tt = false
355
+ server.mount_proc "/" do |req, res|
356
+ next unless "HEAD" == req.request_method
357
+ fail if tt
358
+ tt = true
359
+ res.status = 300
360
+ res["location"] = "/"
361
+ end
362
+ t = Thread.new{ server.start }
363
+ begin
364
+ NetHTTPUtils.request_data "http://localhost:8000/"
365
+ rescue NetHTTPUtils::Error => e
366
+ raise if e.code
367
+ end
368
+ server.shutdown
369
+ t.join
370
+
352
371
  server = WEBrick::HTTPServer.new Port: 8000
353
372
  server.mount_proc "/1" do |req, res|
354
373
  next unless "GET" == req.request_method
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "nethttputils"
3
- spec.version = "0.3.2.10"
3
+ spec.version = "0.3.2.11"
4
4
  spec.summary = "this tool is like a pet that I adopted young and now I depend on, sorry"
5
5
  spec.description = <<-EOF
6
6
  Back in 2015 I was a guy automating things at my job and two scripts had a common need --
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nethttputils
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.2.10
4
+ version: 0.3.2.11
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Maslov aka Nakilon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-18 00:00:00.000000000 Z
11
+ date: 2019-06-08 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: |2
14
14
  Back in 2015 I was a guy automating things at my job and two scripts had a common need --
@@ -51,7 +51,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
51
51
  version: '0'
52
52
  requirements: []
53
53
  rubyforge_project:
54
- rubygems_version: 2.5.2
54
+ rubygems_version: 2.5.2.3
55
55
  signing_key:
56
56
  specification_version: 4
57
57
  summary: this tool is like a pet that I adopted young and now I depend on, sorry