miteru 0.10.0 → 0.10.1

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
  SHA256:
3
- metadata.gz: f3388ff4a8c19447535952bc611725e1faa31b04241b0432cb7516ed03222f1f
4
- data.tar.gz: 28440e7ff65d33a303e5446b4c9eb454ee0831b6b2acc4bef938b855a9b08d23
3
+ metadata.gz: a09a660f481a7f6c7000ad7943e0116a32629c137682bd5d944aef6a045aebd3
4
+ data.tar.gz: 402676cd08f35bdb0e5e2771f83a39fcde8c3ed4e5d8fc953176b85244828ebf
5
5
  SHA512:
6
- metadata.gz: dc88d56a0b8d3d22ea703e8a4d60671804cda0d2ca8323733580260815aad0a0046757c31a35872140c1bee624b2ff17894eecd37c25390f3b85634bd1c2d0c3
7
- data.tar.gz: ee0de0987aea58886a61d2c95e4df80a81d4cf8941342b1c0e48ef8528f21db411c59e047a423f6dbecfdeee79d98b4ed5a6587c6a741e8147d6b440c2b44752
6
+ metadata.gz: 1b8d9cc4c82fdbc0c5d785a082f395e97d8e1a0550540170b900f894cc760ee31ae8755d5c3baed9b1c6a3681a88788e51ab8998bfcae80ca039ec7d3bdfd87a
7
+ data.tar.gz: 76b4aabd5fab653ef7d2133671ae6a770be2e9b8f52a0af36289bcf542a995e309ad723d7556c1de87d69c2c0eb8b90697d3c6cd260cdb33c3e0fc80c7d7f00b
@@ -1,12 +1,15 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "http"
4
3
  require "down/http"
4
+ require "http"
5
5
  require "securerandom"
6
+ require "uri"
6
7
 
7
8
  module Miteru
8
9
  class HTTPClient
9
10
  DEFAULT_UA = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/68.0.3440.106 Safari/537.36"
11
+ URLSCAN_UA = "miteru/#{Miteru::VERSION}"
12
+
10
13
  attr_reader :ssl_context
11
14
  def initialize
12
15
  ctx = OpenSSL::SSL::SSLContext.new
@@ -26,7 +29,11 @@ module Miteru
26
29
 
27
30
  def get(url, options = {})
28
31
  options = options.merge default_options
29
- HTTP.follow.timeout(write: 2, connect: 5, read: 10).headers(default_headers).get(url, options)
32
+
33
+ HTTP.follow
34
+ .timeout(write: 2, connect: 5, read: 10)
35
+ .headers(urlscan_url?(url) ? urlscan_headers : default_headers)
36
+ .get(url, options)
30
37
  end
31
38
 
32
39
  def self.get(url, options = {})
@@ -50,5 +57,14 @@ module Miteru
50
57
  def default_options
51
58
  { ssl_context: ssl_context }
52
59
  end
60
+
61
+ def urlscan_headers
62
+ { user_agent: URLSCAN_UA }
63
+ end
64
+
65
+ def urlscan_url?(url)
66
+ uri = URI(url)
67
+ uri.hostname == "urlscan.io"
68
+ end
53
69
  end
54
70
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Miteru
4
- VERSION = "0.10.0"
4
+ VERSION = "0.10.1"
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: miteru
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.10.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manabu Niseki