nice_http 1.7.19 → 1.7.20

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: f5c9c95b7031d49d93d263fcc40d5180baf5dd75c17e06cbb6f9e8cb010da33d
4
- data.tar.gz: 22ee748e969828d65b3d6699c223611968e98dd1c66d7d5db3968d9878c562da
3
+ metadata.gz: 8df2bebdf1781bae2315f64b8dd0f28b86da978ef33719a0c4b78c78d42c8f67
4
+ data.tar.gz: 05e11c172e6ec2e1739e33fb06b312d4070ba9b51a0d8b7db91068b43e73b8e5
5
5
  SHA512:
6
- metadata.gz: 2b980933c16b27ceff268462e40278ade1bc7b4c44195ec9bf10c445dbe9e519ae8807567b7d5c660600c0f1191048f4a807862b7eb0332e65f51728cf5627d2
7
- data.tar.gz: 5e42409ecda294b53f2691989c13dbaeeea20992e9ad146bc882901365cac4c9eaeee4caf477d368c5318eff6cafb932431c7f5dd603ead76ea453febe66efd7
6
+ metadata.gz: f81761dfa105cb2372101f4464d977cd7ac86883a6fc5161933c9d7848fe8beff04d7da5af98737cf233e647c77fa82e2527e0c7e9cc7ed4cf3e905b222ac332
7
+ data.tar.gz: 87b979e0f709241a30cbb0fb6d2b5aaca2eaf24af5916aa26bf8560219d7ec54d367e61dadb85ee628928ed2bf34c6bfc12c755901d524a20fee05c7381131ef
data/.yardopts CHANGED
@@ -2,8 +2,9 @@
2
2
  --title 'nice_http - NiceHttp -- simplest library for accessing and testing HTTP and REST resources.'
3
3
  --charset utf-8
4
4
  --markup markdown
5
- 'lib/nice_http.rb'
6
- 'lib/nice_http/http_methods.rb'
7
- 'lib/nice_http/utils.rb'
8
- '*.md'
9
- 'LICENSE'
5
+ -
6
+ lib/nice_http.rb
7
+ lib/nice_http/http_methods.rb
8
+ lib/nice_http/utils.rb
9
+
10
+ LICENSE
data/README.md CHANGED
@@ -380,6 +380,11 @@ Other values you can supply:
380
380
  * :file_run, will generate a log file with the name where the object was created and extension .log, fex: myfile.rb.log
381
381
  * String, the path and file name where the logs will be stored.
382
382
 
383
+ In case you want to hide the header values from the requests on the logs use the option `log_headers`. Possible values:
384
+ * :all, (default), will log all header values.
385
+ * :none, won't log any value of the headers.
386
+ * :partial, will log only the last 10 characters of the header values.
387
+
383
388
  Example of logs:
384
389
  ```
385
390
  I, [2019-03-22T18:38:58.518964 #29412] INFO -- : (47266856647720): Http connection created. host:reqres.in, port:443, ssl:true, mode:, proxy_host: , proxy_port:
@@ -7,7 +7,7 @@ require_relative "nice_http/http_methods"
7
7
 
8
8
  ######################################################
9
9
  # Attributes you can access using NiceHttp.the_attribute:
10
- # :host, :port, :ssl, :headers, :debug, :log, :proxy_host, :proxy_port,
10
+ # :host, :port, :ssl, :headers, :debug, :log, :log_headers, :proxy_host, :proxy_port,
11
11
  # :last_request, :last_response, :request_id, :use_mocks, :connections,
12
12
  # :active, :auto_redirect, :values_for, :create_stats, :stats
13
13
  #
@@ -24,6 +24,7 @@ require_relative "nice_http/http_methods"
24
24
  # :file, will be generated a log file with name: nice_http_YY-mm-dd-HHMMSS.log.
25
25
  # :file_run, will generate a log file with the name where the object was created and extension .log, fex: myfile.rb.log
26
26
  # String the path and file name where the logs will be stored.
27
+ # @attr [Symbol] log_headers. :all, :partial, :none (default :all) If :all will log all the headers. If :partial will log the last 10 characters. If :none no headers.
27
28
  # @attr [String] proxy_host the proxy host to be used
28
29
  # @attr [Integer] proxy_port the proxy port to be used
29
30
  # @attr [String] last_request The last request with all the content sent
@@ -66,7 +67,7 @@ class NiceHttp
66
67
  end
67
68
 
68
69
  class << self
69
- attr_accessor :host, :port, :ssl, :headers, :debug, :log_path, :log, :proxy_host, :proxy_port,
70
+ attr_accessor :host, :port, :ssl, :headers, :debug, :log_path, :log, :proxy_host, :proxy_port, :log_headers,
70
71
  :last_request, :last_response, :request_id, :use_mocks, :connections,
71
72
  :active, :auto_redirect, :log_files, :values_for, :create_stats, :stats
72
73
  end
@@ -89,6 +90,7 @@ class NiceHttp
89
90
  @debug = false
90
91
  @log = :fix_file
91
92
  @log_path = ''
93
+ @log_headers = :all
92
94
  @proxy_host = nil
93
95
  @proxy_port = nil
94
96
  @last_request = nil
@@ -128,12 +130,12 @@ class NiceHttp
128
130
  end
129
131
 
130
132
  attr_reader :host, :port, :ssl, :debug, :log, :log_path, :proxy_host, :proxy_port, :response, :num_redirects
131
- attr_accessor :headers, :cookies, :use_mocks, :auto_redirect, :logger, :values_for
133
+ attr_accessor :headers, :cookies, :use_mocks, :auto_redirect, :logger, :values_for, :log_headers
132
134
 
133
135
  ######################################################
134
136
  # Change the default values for NiceHttp supplying a Hash
135
137
  #
136
- # @param par [Hash] keys: :host, :port, :ssl, :headers, :debug, :log, :log_path, :proxy_host, :proxy_port, :use_mocks, :auto_redirect, :values_for, :create_stats
138
+ # @param par [Hash] keys: :host, :port, :ssl, :headers, :debug, :log, :log_path, :proxy_host, :proxy_port, :use_mocks, :auto_redirect, :values_for, :create_stats, :log_headers
137
139
  ######################################################
138
140
  def self.defaults=(par = {})
139
141
  @host = par[:host] if par.key?(:host)
@@ -144,6 +146,7 @@ class NiceHttp
144
146
  @debug = par[:debug] if par.key?(:debug)
145
147
  @log_path = par[:log_path] if par.key?(:log_path)
146
148
  @log = par[:log] if par.key?(:log)
149
+ @log_headers = par[:log_headers] if par.key?(:log_headers)
147
150
  @proxy_host = par[:proxy_host] if par.key?(:proxy_host)
148
151
  @proxy_port = par[:proxy_port] if par.key?(:proxy_port)
149
152
  @use_mocks = par[:use_mocks] if par.key?(:use_mocks)
@@ -293,6 +296,7 @@ class NiceHttp
293
296
  # debug -- true, false (default)
294
297
  # log_path -- string with path for the logs, empty string (default)
295
298
  # log -- :no, :screen, :file, :fix_file (default).
299
+ # log_headers -- :all, :none, :partial (default).
296
300
  # A string with a path can be supplied.
297
301
  # If :fix_file: nice_http.log
298
302
  # In case :file it will be generated a log file with name: nice_http_YY-mm-dd-HHMMSS.log
@@ -319,6 +323,7 @@ class NiceHttp
319
323
  @debug = self.class.debug
320
324
  @log = self.class.log
321
325
  @log_path = self.class.log_path
326
+ @log_headers = self.class.log_headers
322
327
  @proxy_host = self.class.proxy_host
323
328
  @proxy_port = self.class.proxy_port
324
329
  @use_mocks = self.class.use_mocks
@@ -347,6 +352,7 @@ class NiceHttp
347
352
  @debug = args[:debug] if args.keys.include?(:debug)
348
353
  @log = args[:log] if args.keys.include?(:log)
349
354
  @log_path = args[:log_path] if args.keys.include?(:log_path)
355
+ @log_headers = args[:log_headers] if args.keys.include?(:log_headers)
350
356
  @proxy_host = args[:proxy_host] if args.keys.include?(:proxy_host)
351
357
  @proxy_port = args[:proxy_port] if args.keys.include?(:proxy_port)
352
358
  @use_mocks = args[:use_mocks] if args.keys.include?(:use_mocks)
@@ -433,7 +439,6 @@ class NiceHttp
433
439
  @ssl = true if !uri.scheme.nil? && (uri.scheme == "https")
434
440
  @prepath = uri.path unless uri.path == "/"
435
441
  end
436
-
437
442
  raise InfoMissing, :port if @port.to_s == ""
438
443
  raise InfoMissing, :host if @host.to_s == ""
439
444
  raise InfoMissing, :ssl unless @ssl.is_a?(TrueClass) or @ssl.is_a?(FalseClass)
@@ -442,6 +447,7 @@ class NiceHttp
442
447
  raise InfoMissing, :use_mocks unless @use_mocks.is_a?(TrueClass) or @use_mocks.is_a?(FalseClass)
443
448
  raise InfoMissing, :headers unless @headers.is_a?(Hash)
444
449
  raise InfoMissing, :values_for unless @values_for.is_a?(Hash)
450
+ raise InfoMissing, :log_headers unless [:all, :none, :partial].include?(@log_headers)
445
451
 
446
452
  begin
447
453
  if !@proxy_host.nil? && !@proxy_port.nil?
@@ -196,7 +196,23 @@ module NiceHttpManageRequest
196
196
  end
197
197
 
198
198
  headers_ts = ""
199
- headers_t.each { |key, val| headers_ts += key.to_s + ":" + val.to_s() + ", " }
199
+
200
+ if @log_headers == :none
201
+ @logger.info "No header values since option log_headers is set to :none"
202
+ headers_t.each { |key, val| headers_ts += key.to_s + ":" + "''" + ", " }
203
+ elsif @log_headers == :partial
204
+ @logger.info "Just the last 10 characters on header values since option log_headers is set to :partial"
205
+ headers_t.each { |key, val|
206
+ if val.to_s.size>10
207
+ headers_ts += key.to_s + ": ..." + (val.to_s[-10..-1] || val.to_s) + ", "
208
+ else
209
+ headers_ts += key.to_s + ":" + (val.to_s[-10..-1] || val.to_s) + ", "
210
+ end
211
+ }
212
+ else
213
+ headers_t.each { |key, val| headers_ts += key.to_s + ":" + val.to_s() + ", " }
214
+ end
215
+
200
216
  message = "\n\n#{"- " * 25}\n"
201
217
  if arguments.size == 1 and arguments[0].kind_of?(Hash) and arguments[0].key?(:name)
202
218
  message += "#{method_s.upcase} Request: #{arguments[0][:name]}"
metadata CHANGED
@@ -1,55 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nice_http
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.7.19
4
+ version: 1.7.20
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mario Ruiz
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-09-03 00:00:00.000000000 Z
11
+ date: 2019-10-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: nice_hash
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - ">="
18
- - !ruby/object:Gem::Version
19
- version: 1.14.0
20
17
  - - "~>"
21
18
  - !ruby/object:Gem::Version
22
- version: '1.14'
19
+ version: '1.15'
20
+ - - ">="
21
+ - !ruby/object:Gem::Version
22
+ version: 1.15.3
23
23
  type: :runtime
24
24
  prerelease: false
25
25
  version_requirements: !ruby/object:Gem::Requirement
26
26
  requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- version: 1.14.0
30
27
  - - "~>"
31
28
  - !ruby/object:Gem::Version
32
- version: '1.14'
29
+ version: '1.15'
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: 1.15.3
33
33
  - !ruby/object:Gem::Dependency
34
34
  name: rspec
35
35
  requirement: !ruby/object:Gem::Requirement
36
36
  requirements:
37
- - - ">="
38
- - !ruby/object:Gem::Version
39
- version: 3.8.0
40
37
  - - "~>"
41
38
  - !ruby/object:Gem::Version
42
39
  version: '3.8'
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ version: 3.8.0
43
43
  type: :development
44
44
  prerelease: false
45
45
  version_requirements: !ruby/object:Gem::Requirement
46
46
  requirements:
47
- - - ">="
48
- - !ruby/object:Gem::Version
49
- version: 3.8.0
50
47
  - - "~>"
51
48
  - !ruby/object:Gem::Version
52
49
  version: '3.8'
50
+ - - ">="
51
+ - !ruby/object:Gem::Version
52
+ version: 3.8.0
53
53
  description: NiceHttp -- simplest library for accessing and testing HTTP and REST
54
54
  resources. Get http logs and statistics automatically. Use hashes on your requests.
55
55
  Access JSON even easier.
@@ -87,7 +87,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
87
87
  - !ruby/object:Gem::Version
88
88
  version: '0'
89
89
  requirements: []
90
- rubygems_version: 3.0.3
90
+ rubyforge_project:
91
+ rubygems_version: 2.7.6
91
92
  signing_key:
92
93
  specification_version: 4
93
94
  summary: NiceHttp -- simplest library for accessing and testing HTTP and REST resources.