nethttputils 0.4.2.0 → 0.4.3.0

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: 6b310f69be9a582878a60741eb385b2cbc61884b
4
- data.tar.gz: fee129582c51e0ec02abc63e318a681534edc391
3
+ metadata.gz: ecb7a8e00f832f9c1fa1f79610772f8f955a177f
4
+ data.tar.gz: ee617bf653fca7736e95e257929ebb7a597872a1
5
5
  SHA512:
6
- metadata.gz: d7f628d6558dbe9aa0d08125c5a294c957235858829013ac4dd655b0b28fc63e38bed1827ce35fbb9de1d66ca6acde828fa3a5d77ea90a3e08238751cab9b0ea
7
- data.tar.gz: ea174acf8e166ef034d6d151b171babdb19fa3736cd23fbdb006c460deb28236f1ce33c1bbc72194d30695498ccc1292108063b6319b54eace9631a5b3e68bc7
6
+ metadata.gz: e3632e1d20d3d853f2b7542364785ce5ba4ca8b4ff25aa2304856061bbe133cdd145ac18843a1bd52af275939e9f8354223c0d37dac6d64df5791dc2f21fc9db
7
+ data.tar.gz: 90e9b8a75802bd2d48cb727cf5c28ac4aa1c481e4af0afdc90d4e5b0f251e36293867819ef788774db550b92c0796482024913d313b7475e82737440c2685197
data/lib/nethttputils.rb CHANGED
@@ -308,10 +308,8 @@ module NetHTTPUtils
308
308
 
309
309
  require "set"
310
310
  @@_405 ||= Set.new
311
- def request_data http, mtd = :GET, type = :form, form: {}, header: {}, auth: nil, proxy: nil, force_post: false,
312
- timeout: nil, no_redirect: false,
313
- max_start_http_retry_delay: 3600,
314
- max_read_retry_delay: 3600,
311
+ def request_data http, mtd = :GET, type = :form, form: {}, header: {}, auth: nil, proxy: nil, force_post: false, no_redirect: false, head: false,
312
+ timeout: nil, max_start_http_retry_delay: 3600, max_read_retry_delay: 3600,
315
313
  patch_request: nil, &block
316
314
  timeout ||= 30
317
315
  http = start_http http, max_start_http_retry_delay, timeout, no_redirect, *proxy unless http.is_a? Net::HTTP
@@ -331,7 +329,7 @@ module NetHTTPUtils
331
329
  )
332
330
  end
333
331
  end
334
- if mtd == :GET && !@@_405.include?(http.address)
332
+ if head && mtd == :GET && !@@_405.include?(http.address)
335
333
  body = begin
336
334
  request_data http, :HEAD, form: form, header: header, auth: auth,
337
335
  max_start_http_retry_delay: max_start_http_retry_delay,
@@ -419,6 +417,7 @@ if $0 == __FILE__
419
417
  server.shutdown
420
418
  t.join
421
419
 
420
+ # HEAD should raise on 404 but not in two other cases
422
421
  [
423
422
  [WEBrick::HTTPStatus::NotFound, 404],
424
423
  [WEBrick::HTTPStatus::BadRequest],
@@ -430,7 +429,7 @@ if $0 == __FILE__
430
429
  end
431
430
  t = Thread.new{ server.start }
432
431
  begin
433
- NetHTTPUtils.request_data "http://localhost:8000/"
432
+ NetHTTPUtils.request_data "http://localhost:8000/", head: true
434
433
  NetHTTPUtils.class_variable_get(:@@_405).clear
435
434
  fail if should_raise
436
435
  rescue NetHTTPUtils::Error => e
@@ -455,7 +454,7 @@ if $0 == __FILE__
455
454
  NetHTTPUtils.request_data("http://localhost:8000/", :head)
456
455
  fail stack.inspect unless stack == %w{ HEAD }
457
456
  stack.clear
458
- NetHTTPUtils.request_data("http://localhost:8000/")
457
+ NetHTTPUtils.request_data("http://localhost:8000/", head: true)
459
458
  fail stack.inspect unless stack == %w{ HEAD GET }
460
459
  server.shutdown
461
460
  t.join
@@ -522,7 +521,7 @@ if $0 == __FILE__
522
521
  http://www.aeronautica.difesa.it/organizzazione/REPARTI/divolo/PublishingImages/6%C2%B0%20Stormo/2013-decollo%20al%20tramonto%20REX%201280.jpg
523
522
  }.each do |url|
524
523
  begin
525
- NetHTTPUtils.request_data url, timeout: 5, max_read_retry_delay: -1
524
+ NetHTTPUtils.request_data url, timeout: 5, max_read_retry_delay: -1, head: true
526
525
  fail
527
526
  rescue Net::ReadTimeout
528
527
  end
data/nethttputils.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |spec|
2
2
  spec.name = "nethttputils"
3
- spec.version = "0.4.2.0"
3
+ spec.version = "0.4.3.0"
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.4.2.0
4
+ version: 0.4.3.0
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: 2021-10-05 00:00:00.000000000 Z
11
+ date: 2021-10-16 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: addressable