httplog 0.99.7 → 1.0.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: fdf8fed4c68c3f380c025f745a64533d1c3f3873
4
- data.tar.gz: 946eb415393fbba0743ef028209e818a2653a423
3
+ metadata.gz: 4603f2bab3809871813bd149f2356ea700f89b3d
4
+ data.tar.gz: 37d78609e492343c5c1153bb4c92bca7ec38de22
5
5
  SHA512:
6
- metadata.gz: 1e49c66ac0b8b66c7c969f6a0ed32e6f9fa3c169df51e059ace3c0185e3c8c9b9038bb79e43c7c4eb5ed12cb573e9aede05717b579210fc0985a182c562fcf28
7
- data.tar.gz: 1352a156b8dd461758e8dce9f5b2153b27cf016032e09ae2ad65dfbe01b8565cdafb408c781f7280a55b8ba12837eb09d3cab453a3cb5a1f58f41c157e9662a0
6
+ metadata.gz: 00c37ed11badf49dc23722834b42994be41e7e0f01ccc44cfb57997eac08ad56d558fd0d1ad932aeed44e8ab131cdc7e2284efca526788a3885c47b9f629262c
7
+ data.tar.gz: f82837fba14d48ff65f5df5c89a34ed50e6d2b8401306756aada44fe5f3cef823369ea95b732b48bf4e9690a06f0999c4b49d2f047e75442fd4c177dd6ca9a82
data/README.md CHANGED
@@ -2,8 +2,6 @@
2
2
 
3
3
  [![Gem Version](https://badge.fury.io/rb/httplog.png)](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.png)](https://codeclimate.com/github/trusche/httplog)
4
4
 
5
- **+++ This is the README for version 0.99.0 and higher. If you're on previous versions, please refer to [this README version](https://github.com/trusche/httplog/tree/v0.3.3), since the configuration syntax has changed.+++**
6
-
7
5
  Log outgoing HTTP requests made from your application. Helps with debugging pesky API error responses, or just generally understanding what's going on under the hood.
8
6
 
9
7
  **+++Requires ruby 2.2 or higher. If you're stuck with an older version of ruby for some reason, you're stuck with httplog v0.3.3.+++**
@@ -27,7 +25,7 @@ These libraries are at least partially supported, where they use one of the abov
27
25
  In theory, it should also work with any library built on top of these. But the difference between theory and practice is bigger in practice than in theory.
28
26
 
29
27
  This is very much a development and debugging tool; it is **not recommended** to
30
- use this in a production environment as it is moneky-patching the respective HTTP implementations.
28
+ use this in a production environment as it is monkey-patching the respective HTTP implementations.
31
29
  You have been warned - use at your own risk.
32
30
 
33
31
  ### Installation
@@ -7,7 +7,7 @@ if defined?(Ethon)
7
7
  module Http
8
8
  alias_method :orig_http_request, :http_request
9
9
  def http_request(url, action_name, options = {})
10
- @action_name = action_name # remember this for compact logging
10
+ @action_name = action_name # remember this for compact logging
11
11
  if HttpLog.url_approved?(url)
12
12
  HttpLog.log_request(action_name, url)
13
13
  HttpLog.log_headers(options[:headers])
@@ -28,14 +28,20 @@ if defined?(Ethon)
28
28
  reponse_code = orig_perform
29
29
  end
30
30
 
31
- # Not sure where the acutal status code is stored - so let's
31
+ # Not sure where the actual status code is stored - so let's
32
32
  # extract it from the response header.
33
33
  status = response_headers.scan(/HTTP\/... (\d{3})/).flatten.first
34
34
  encoding = response_headers.scan(/Content-Encoding: (\S+)/).flatten.first
35
35
  content_type = response_headers.scan(/Content-Type: (\S+(; charset=\S+)?)/).flatten.first
36
+
37
+ # Hard to believe that Ethon wouldn't parse out the headers into
38
+ # an array; probably overlooked it. Anyway, let's do it ourselves:
39
+ headers = response_headers.split(/\r?\n/)[1..-1]
40
+
36
41
  HttpLog.log_compact(@action_name, @url, @return_code, bm)
37
42
  HttpLog.log_status(status)
38
43
  HttpLog.log_benchmark(bm)
44
+ HttpLog.log_headers(headers)
39
45
  HttpLog.log_body(response_body, encoding, content_type)
40
46
  return_code
41
47
  end
@@ -27,7 +27,7 @@ if defined?(Excon)
27
27
  datum = @data.merge(params)
28
28
  datum[:headers] = @data[:headers].merge(datum[:headers] || {})
29
29
  url = _httplog_url(datum)
30
-
30
+
31
31
  if HttpLog.url_approved?(url)
32
32
  HttpLog.log_compact(datum[:method], url, datum[:status] || result.status, bm)
33
33
  HttpLog.log_benchmark(bm)
@@ -56,8 +56,8 @@ if defined?(Excon)
56
56
  end
57
57
  response = datum[:response]
58
58
  headers = response[:headers] || {}
59
- content_type =
60
59
  HttpLog.log_status(response[:status])
60
+ HttpLog.log_headers(headers)
61
61
  HttpLog.log_body(response[:body], headers['Content-Encoding'], headers['Content-Type'])
62
62
  datum
63
63
  end
@@ -27,6 +27,7 @@ if defined?(::HTTPClient)
27
27
  HttpLog.log_compact(req.header.request_method, req.header.request_uri, res.status_code, bm)
28
28
  HttpLog.log_status(res.status_code)
29
29
  HttpLog.log_benchmark(bm)
30
+ HttpLog.log_headers(headers)
30
31
  HttpLog.log_body(res.body, headers['Content-Encoding'], headers['Content-Type'])
31
32
  conn.push(res)
32
33
  end
@@ -46,7 +47,7 @@ if defined?(::HTTPClient)
46
47
  end
47
48
  orig_create_socket(site)
48
49
  end
49
-
50
+
50
51
  else
51
52
  def create_socket(host, port)
52
53
  if HttpLog.url_approved?("#{host}:#{port}")
@@ -20,6 +20,7 @@ if defined?(Patron)
20
20
  HttpLog.log_compact(action_name, url, @response.status, bm)
21
21
  HttpLog.log_status(@response.status)
22
22
  HttpLog.log_benchmark(bm)
23
+ HttpLog.log_headers(headers)
23
24
  HttpLog.log_body(@response.body, headers['Content-Encoding'], headers['Content-Type'])
24
25
  end
25
26
 
@@ -1,3 +1,3 @@
1
1
  module HttpLog
2
- VERSION = "0.99.7"
2
+ VERSION = "1.0.0"
3
3
  end
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.99.7
4
+ version: 1.0.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: 2017-07-19 00:00:00.000000000 Z
11
+ date: 2017-11-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rspec