httplog 1.4.3 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +8 -0
- data/README.md +4 -6
- data/httplog.gemspec +3 -2
- data/lib/httplog/adapters/net_http.rb +11 -1
- data/lib/httplog/http_log.rb +13 -9
- data/lib/httplog/version.rb +1 -1
- metadata +21 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 97cbba2cdb0af09dcf6664e290981b074a40f9c91d81be74a737a746bfc1e612
|
4
|
+
data.tar.gz: 228590a39ab68d89d3261f219e2bac4945f4fde315219943cbbacdfc1aaa2922
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d857f2dc7142fb7243371afd4d3993b65ced6092ecb6ac361abbd2957bc1884e18131ca707b3e2c9dc694ad9996c09e12ddf7b31f978d8d55def35322159a861
|
7
|
+
data.tar.gz: eafbb1ef94500b468083f8073049749e6073d2ec423fadae8f6aca3221624bb914f28a489305f35cd5fb222b247eb81f5b2446f4694f919959267d83c0bfcbe7
|
data/CHANGELOG.md
CHANGED
@@ -1,3 +1,11 @@
|
|
1
|
+
## 1.5.0 - 2021-05-20
|
2
|
+
|
3
|
+
* Support for Ruby 2.7 and frozen strings
|
4
|
+
* Development dependency updates
|
5
|
+
* Dropped support for net/http v3
|
6
|
+
* Performance tweaks
|
7
|
+
* Fix for RestClient body read issue (WARNING: this may be reverted, see [#105](https://github.com/trusche/httplog/issues/105))
|
8
|
+
|
1
9
|
## 1.4.3 - 2020-06-10
|
2
10
|
|
3
11
|
* Masking `password` parameter by default... doh.
|
data/README.md
CHANGED
@@ -1,7 +1,5 @@
|
|
1
1
|
## httplog
|
2
2
|
|
3
|
-
**VERSION 1.4.0 and 1.4.1 HAVE BEEN YANKED** from rubygems.org due to [this issue](https://github.com/trusche/httplog/issues/89), please update to version 1.4.2 or higher. Sorry about that...
|
4
|
-
|
5
3
|
[![Gem Version](https://badge.fury.io/rb/httplog.svg)](http://badge.fury.io/rb/httplog) [![Build Status](https://travis-ci.org/trusche/httplog.svg?branch=master)](https://travis-ci.org/trusche/httplog) [![Code Climate](https://codeclimate.com/github/trusche/httplog.svg)](https://codeclimate.com/github/trusche/httplog)
|
6
4
|
[![Release Version](https://img.shields.io/github/release/trusche/httplog.svg)](https://img.shields.io/github/release/trusche/httplog.svg)
|
7
5
|
<a href="https://www.bearer.sh?ref=httplog"><img src="/bearer-badge.png" height="20px"/></a>
|
@@ -12,7 +10,7 @@ Requires ruby >= 2.5
|
|
12
10
|
|
13
11
|
This gem works with the following ruby modules and libraries:
|
14
12
|
|
15
|
-
* [Net::HTTP](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/index.html)
|
13
|
+
* [Net::HTTP](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/index.html) v4+
|
16
14
|
* [Ethon](https://github.com/typhoeus/ethon)
|
17
15
|
* [Excon](https://github.com/geemus/excon)
|
18
16
|
* [OpenURI](http://www.ruby-doc.org/stdlib-1.9.3/libdoc/open-uri/rdoc/index.html)
|
@@ -103,6 +101,9 @@ HttpLog.configure do |config|
|
|
103
101
|
|
104
102
|
# Mask the values of sensitive request parameters
|
105
103
|
config.filter_parameters = %w[password]
|
104
|
+
|
105
|
+
# Customize the prefix with a proc or lambda
|
106
|
+
config.prefix = ->{ "[httplog] #{Time.now} " }
|
106
107
|
end
|
107
108
|
```
|
108
109
|
|
@@ -267,9 +268,6 @@ a suggestion for a fix, please open an issue or, even better, submit a pull requ
|
|
267
268
|
|
268
269
|
* Benchmarking only covers the time between starting the HTTP request and receiving the response. It does *not* cover the time it takes to establish the TCP connection.
|
269
270
|
|
270
|
-
* When using [REST Client](https://github.com/rest-client/rest-client), POST requests might be missing the requests
|
271
|
-
data. See #54 for details.
|
272
|
-
|
273
271
|
### Running the specs
|
274
272
|
|
275
273
|
Make sure you have the necessary dependencies installed by running `bundle install`.
|
data/httplog.gemspec
CHANGED
@@ -26,14 +26,15 @@ Gem::Specification.new do |gem|
|
|
26
26
|
|
27
27
|
gem.add_development_dependency 'ethon', ['~> 0.11']
|
28
28
|
gem.add_development_dependency 'excon', ['~> 0.60']
|
29
|
-
gem.add_development_dependency 'faraday', ['~>
|
29
|
+
gem.add_development_dependency 'faraday', ['~> 1.3']
|
30
30
|
gem.add_development_dependency 'guard-rspec', ['~> 4.7']
|
31
31
|
gem.add_development_dependency 'http', ['~> 4.0']
|
32
32
|
gem.add_development_dependency 'httparty', ['~> 0.16']
|
33
33
|
gem.add_development_dependency 'httpclient', ['~> 2.8']
|
34
|
+
gem.add_development_dependency 'rest-client', ['~> 2.0']
|
34
35
|
gem.add_development_dependency 'listen', ['~> 3.0']
|
35
36
|
gem.add_development_dependency 'patron', ['~> 0.12']
|
36
|
-
gem.add_development_dependency 'rake', ['~>
|
37
|
+
gem.add_development_dependency 'rake', ['~> 13.0']
|
37
38
|
gem.add_development_dependency 'rspec', ['~> 3.7']
|
38
39
|
gem.add_development_dependency 'simplecov', ['~> 0.15']
|
39
40
|
gem.add_development_dependency 'thin', ['~> 1.7']
|
@@ -11,12 +11,22 @@ module Net
|
|
11
11
|
bm = Benchmark.realtime do
|
12
12
|
@response = orig_request(req, body, &block)
|
13
13
|
end
|
14
|
+
body_stream = req.body_stream
|
15
|
+
request_body = if body_stream
|
16
|
+
body_stream.to_s # read and rewind for RestClient::Payload::Base
|
17
|
+
body_stream.rewind if body_stream.respond_to?(:rewind) # RestClient::Payload::Base has no method rewind
|
18
|
+
body_stream.read
|
19
|
+
elsif req.body.nil? || req.body.empty?
|
20
|
+
body
|
21
|
+
else
|
22
|
+
req.body
|
23
|
+
end
|
14
24
|
|
15
25
|
if HttpLog.url_approved?(url) && started?
|
16
26
|
HttpLog.call(
|
17
27
|
method: req.method,
|
18
28
|
url: url,
|
19
|
-
request_body:
|
29
|
+
request_body: request_body,
|
20
30
|
request_headers: req.each_header.collect,
|
21
31
|
response_code: @response.code,
|
22
32
|
response_body: @response.body,
|
data/lib/httplog/http_log.rb
CHANGED
@@ -121,22 +121,24 @@ module HttpLog
|
|
121
121
|
raise BodyParsingError, '(not available yet)'
|
122
122
|
end
|
123
123
|
|
124
|
-
|
125
|
-
|
124
|
+
body_copy = body.dup
|
125
|
+
body_copy = body.to_s if defined?(HTTP::Response::Body) && body.is_a?(HTTP::Response::Body)
|
126
|
+
return nil if body_copy.nil? || body_copy.empty?
|
126
127
|
|
127
|
-
|
128
|
+
|
129
|
+
if encoding =~ /gzip/
|
128
130
|
begin
|
129
|
-
sio = StringIO.new(
|
131
|
+
sio = StringIO.new(body_copy.to_s)
|
130
132
|
gz = Zlib::GzipReader.new(sio)
|
131
|
-
|
133
|
+
body_copy = gz.read
|
132
134
|
rescue Zlib::GzipFile::Error
|
133
135
|
log("(gzip decompression failed)")
|
134
136
|
end
|
135
137
|
end
|
136
138
|
|
137
|
-
result = utf_encoded(
|
139
|
+
result = utf_encoded(body_copy.to_s, content_type)
|
138
140
|
|
139
|
-
if mask_body
|
141
|
+
if mask_body
|
140
142
|
if content_type =~ /json/
|
141
143
|
result = begin
|
142
144
|
masked_data config.json_parser.load(result)
|
@@ -259,12 +261,14 @@ module HttpLog
|
|
259
261
|
# in its entirety.
|
260
262
|
return (config.filter_parameters.include?(key.downcase) ? PARAM_MASK : msg) if key
|
261
263
|
|
262
|
-
# Otherwise, we'll parse Strings for key=
|
264
|
+
# Otherwise, we'll parse Strings for key=value pairs,
|
265
|
+
# for name="key"\n value...
|
263
266
|
case msg
|
264
267
|
when *string_classes
|
265
268
|
config.filter_parameters.reduce(msg) do |m,key|
|
266
269
|
scrubbed = m.to_s.encode('UTF-8', invalid: :replace, undef: :replace)
|
267
|
-
scrubbed.gsub(/(#{key})=[^&]+/i, "#{key}=#{PARAM_MASK}")
|
270
|
+
scrubbed.to_s.gsub(/(#{key})=[^&]+/i, "#{key}=#{PARAM_MASK}")
|
271
|
+
.gsub(/name="#{key}"\s+\K[\s\w]+/, "#{PARAM_MASK}\r\n") # multi-part Faraday
|
268
272
|
end
|
269
273
|
# ...and recurse over hashes
|
270
274
|
when *hash_classes
|
data/lib/httplog/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: httplog
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Thilo Rusche
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: ethon
|
@@ -44,14 +44,14 @@ dependencies:
|
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '1.3'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
|
-
version: '
|
54
|
+
version: '1.3'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: guard-rspec
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
@@ -108,6 +108,20 @@ dependencies:
|
|
108
108
|
- - "~>"
|
109
109
|
- !ruby/object:Gem::Version
|
110
110
|
version: '2.8'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rest-client
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '2.0'
|
118
|
+
type: :development
|
119
|
+
prerelease: false
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
requirements:
|
122
|
+
- - "~>"
|
123
|
+
- !ruby/object:Gem::Version
|
124
|
+
version: '2.0'
|
111
125
|
- !ruby/object:Gem::Dependency
|
112
126
|
name: listen
|
113
127
|
requirement: !ruby/object:Gem::Requirement
|
@@ -142,14 +156,14 @@ dependencies:
|
|
142
156
|
requirements:
|
143
157
|
- - "~>"
|
144
158
|
- !ruby/object:Gem::Version
|
145
|
-
version: '
|
159
|
+
version: '13.0'
|
146
160
|
type: :development
|
147
161
|
prerelease: false
|
148
162
|
version_requirements: !ruby/object:Gem::Requirement
|
149
163
|
requirements:
|
150
164
|
- - "~>"
|
151
165
|
- !ruby/object:Gem::Version
|
152
|
-
version: '
|
166
|
+
version: '13.0'
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: rspec
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|
@@ -274,7 +288,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
274
288
|
- !ruby/object:Gem::Version
|
275
289
|
version: '0'
|
276
290
|
requirements: []
|
277
|
-
rubygems_version: 3.
|
291
|
+
rubygems_version: 3.1.4
|
278
292
|
signing_key:
|
279
293
|
specification_version: 4
|
280
294
|
summary: Log outgoing HTTP requests.
|