nethttputils 0.3.2.10 → 0.3.2.11
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/lib/nethttputils.rb +21 -2
- data/nethttputils.gemspec +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4bc1f0212b03ef427e313966fff8e8431f35b0fd
|
4
|
+
data.tar.gz: 1751888f47d8d2252a52549ec96126c768ebcbba
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a047da71bab1fdfa59c4dc1281654ca95914327ebf248080e884d414fdbce39ab0820c84199a359152c29c7f8a749993e9ddcad68238c44bea8a186b29ebf945
|
7
|
+
data.tar.gz: 12a74c116dd99b6d0e9c98f5cc4a2cb6f7c33b31cb939478b1e7c4763e8bf52108405d94200da74bdff672bc94870da1bba6d8d81186220e2b9e673a19ecbdec
|
data/lib/nethttputils.rb
CHANGED
@@ -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
|
data/nethttputils.gemspec
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
Gem::Specification.new do |spec|
|
2
2
|
spec.name = "nethttputils"
|
3
|
-
spec.version = "0.3.2.
|
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.
|
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-
|
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
|