httplog 0.2.7 → 0.2.8

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: 26d68ccbe75956716551dd1c429ebec57d1930fe
4
- data.tar.gz: 365d302175b5c0c7470d8ec25184791aafe0efb7
3
+ metadata.gz: bc801e5fc39b6c93832bbadaa2c1204e2d969339
4
+ data.tar.gz: 3e040bc3c9bda9eb1ae93bf66c3828dd5df4482d
5
5
  SHA512:
6
- metadata.gz: ddee93a1e7282327c9efe1273c3c7b603d5691e49743b5214b8fd430f3564469a946a04a845dea6ee27f4b22a104f583421d6c8def81ac77227c00f739f85a65
7
- data.tar.gz: 300a45a60aa947acc95b9cd9dbec6affe40467f8e49efad0a56d486738d03d9ce3fcd15997d7144efc3b8855c8844157e61a88a6970c03a77cc5958dbf119d65
6
+ metadata.gz: a25911aaa39b63cf038adf005c47d2c5793f171e3ad6d37d72ca54535b38243870a6508c825e7fb5ea4628121d371aee3025d357ed835cbc38b37c15a3e98b09
7
+ data.tar.gz: 28955f8848345352693e58227659977db677739c9cf11e2a34dbdaf075a8c245fad92cbe0b8ab8ac1d129b48bde312d0ff25c9fac46e5501d0b1b0f271b8bbed
data/README.md CHANGED
@@ -15,6 +15,7 @@ So far this gem works with the following ruby modules and libraries:
15
15
  * [Patron](https://github.com/toland/patron)
16
16
  * [HTTPClient](https://github.com/nahi/httpclient)
17
17
  * [HTTParty](https://github.com/jnunemaker/httparty)
18
+ * [HTTP](http://rubygems.org/gems/http)
18
19
 
19
20
  These libraries are at least partially supported, where they use one of the above as adapters:
20
21
 
@@ -54,8 +55,8 @@ You can override the following default options:
54
55
 
55
56
  # only log requests made to specified hosts (URLs)
56
57
  HttpLog.options[:url_whitelist_pattern] = /.*/
57
- # overrides whitelist
58
- HttpLog.options[:url_blacklist_pattern] = nil
58
+ # overrides whitelist
59
+ HttpLog.options[:url_blacklist_pattern] = nil
59
60
 
60
61
  So if you want to use this in a Rails app:
61
62
 
@@ -109,6 +110,8 @@ With the default configuration, the log output might look like this:
109
110
  * When using Ethon or Patron, and any library based on them (such as Typhoeus),
110
111
  the TCP connection is not logged (since it's established by libcurl).
111
112
 
113
+ * 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.
114
+
112
115
  ### Running the specs
113
116
 
114
117
  Make sure you have the necessary dependencies installed by running `bundle install`.
@@ -132,3 +135,4 @@ Thanks to these fine folks for contributing pull requests:
132
135
  * [Nikos Dimitrakopoulos](https://github.com/nikosd)
133
136
  * [Marcos Hack](https://github.com/marcoshack)
134
137
  * [Andrew Hammond](https://github.com/andrhamm)
138
+ * [Chris Keele](https://github.com/christhekeele)
data/lib/httplog.rb CHANGED
@@ -5,3 +5,4 @@ require "httplog/adapters/httpclient"
5
5
  require "httplog/adapters/excon"
6
6
  require "httplog/adapters/ethon"
7
7
  require "httplog/adapters/patron"
8
+ require "httplog/adapters/http"
@@ -0,0 +1,44 @@
1
+ if defined?(::HTTP::Client) and defined?(::HTTP::Connection)
2
+ module ::HTTP
3
+ class Client
4
+ alias_method(:orig_make_request, :make_request) unless method_defined?(:orig_make_request)
5
+
6
+ def make_request(req, options)
7
+
8
+ log_enabled = HttpLog.url_approved?(req.uri)
9
+
10
+ if log_enabled
11
+ HttpLog.log_request(req.verb, req.uri)
12
+ HttpLog.log_headers(req.headers.to_h)
13
+ HttpLog.log_data(req.body) if req.verb == :post
14
+ end
15
+
16
+ bm = Benchmark.realtime do
17
+ @response = orig_make_request(req, options)
18
+ end
19
+
20
+ if log_enabled
21
+ HttpLog.log_compact(req.verb, req.uri, @response.code, bm)
22
+ HttpLog.log_status(@response.code)
23
+ HttpLog.log_benchmark(bm)
24
+ HttpLog.log_headers(@response.headers.to_h)
25
+ HttpLog.log_body(@response.body, @response.headers["Content-Encoding"])
26
+ end
27
+
28
+ @response
29
+ end
30
+
31
+ end
32
+
33
+ class Connection
34
+ alias_method(:orig_initialize, :initialize) unless method_defined?(:orig_initialize)
35
+
36
+ def initialize(req, options)
37
+
38
+ HttpLog.log_connection(req.uri.host, req.uri.port) if HttpLog.url_approved?(req.uri)
39
+
40
+ orig_initialize(req, options)
41
+ end
42
+ end
43
+ end
44
+ end
@@ -1,4 +1,4 @@
1
1
  module HttpLog
2
- VERSION = "0.2.7"
2
+ VERSION = "0.2.8"
3
3
  end
4
4
 
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: 0.2.7
4
+ version: 0.2.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Thilo Rusche
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-07-31 00:00:00.000000000 Z
11
+ date: 2015-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - '>='
165
165
  - !ruby/object:Gem::Version
166
166
  version: '0'
167
+ - !ruby/object:Gem::Dependency
168
+ name: http
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - '>='
179
+ - !ruby/object:Gem::Version
180
+ version: '0'
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: simplecov
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -220,6 +234,7 @@ files:
220
234
  - lib/httplog.rb
221
235
  - lib/httplog/adapters/ethon.rb
222
236
  - lib/httplog/adapters/excon.rb
237
+ - lib/httplog/adapters/http.rb
223
238
  - lib/httplog/adapters/httpclient.rb
224
239
  - lib/httplog/adapters/net_http.rb
225
240
  - lib/httplog/adapters/patron.rb
@@ -244,7 +259,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
244
259
  version: '0'
245
260
  requirements: []
246
261
  rubyforge_project:
247
- rubygems_version: 2.2.2
262
+ rubygems_version: 2.4.4
248
263
  signing_key:
249
264
  specification_version: 4
250
265
  summary: Logs outgoing HTTP requests.