httplog 1.3.1 → 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 +32 -0
- data/README.md +53 -22
- data/httplog.gemspec +7 -4
- data/lib/httplog/adapters/ethon.rb +2 -1
- data/lib/httplog/adapters/excon.rb +2 -1
- data/lib/httplog/adapters/http.rb +5 -3
- data/lib/httplog/adapters/httpclient.rb +6 -4
- data/lib/httplog/adapters/net_http.rb +13 -2
- data/lib/httplog/adapters/patron.rb +2 -1
- data/lib/httplog/configuration.rb +27 -21
- data/lib/httplog/http_log.rb +138 -49
- data/lib/httplog/version.rb +1 -1
- metadata +37 -51
- data/.gitignore +0 -7
- data/.rspec +0 -2
- data/.rubocop.yml +0 -55
- data/.rubocop_todo.yml +0 -36
- data/.ruby-version +0 -1
- data/.travis.yml +0 -17
- data/Gemfile +0 -4
- data/Gemfile.lock +0 -130
- data/Guardfile +0 -25
- data/MIT-LICENSE +0 -20
- data/Rakefile +0 -46
- data/gemfiles/http3.gemfile +0 -7
- data/gemfiles/http4.gemfile +0 -7
- data/gemfiles/http5.gemfile +0 -7
- data/gemfiles/rack1.gemfile +0 -7
- data/gemfiles/rack2.gemfile +0 -7
- data/spec/adapters/ethon_adapter.rb +0 -26
- data/spec/adapters/excon_adapter.rb +0 -16
- data/spec/adapters/faraday_adapter.rb +0 -59
- data/spec/adapters/http_adapter.rb +0 -27
- data/spec/adapters/http_base_adapter.rb +0 -39
- data/spec/adapters/httparty_adapter.rb +0 -16
- data/spec/adapters/httpclient_adapter.rb +0 -31
- data/spec/adapters/net_http_adapter.rb +0 -21
- data/spec/adapters/open_uri_adapter.rb +0 -19
- data/spec/adapters/patron_adapter.rb +0 -36
- data/spec/adapters/typhoeus_adapter.rb +0 -28
- data/spec/configuration_spec.rb +0 -22
- data/spec/lib/http_client_spec.rb +0 -15
- data/spec/lib/http_log_spec.rb +0 -320
- data/spec/log/.gitkeep +0 -0
- data/spec/spec_helper.rb +0 -45
- data/spec/support/index.html +0 -8
- data/spec/support/index.html.gz +0 -0
- data/spec/support/log4r.yml +0 -17
- data/spec/support/not_gzipped.html.gz +0 -8
- data/spec/support/shared_examples.rb +0 -79
- data/spec/support/test.bin +0 -0
- data/spec/support/test.pdf +0 -198
- data/spec/support/test_server.rb +0 -34
- data/spec/support/utf8-invalid.html +0 -0
- data/spec/support/utf8.html +0 -8
data/spec/support/index.html.gz
DELETED
Binary file
|
data/spec/support/log4r.yml
DELETED
@@ -1,17 +0,0 @@
|
|
1
|
-
log4r_config:
|
2
|
-
loggers:
|
3
|
-
- name : test
|
4
|
-
level : DEBUG
|
5
|
-
trace : 'true'
|
6
|
-
outputters :
|
7
|
-
- datefile
|
8
|
-
|
9
|
-
outputters:
|
10
|
-
- type: DateFileOutputter
|
11
|
-
name: datefile
|
12
|
-
dirname: "./spec/log"
|
13
|
-
filename: "log4r.log"
|
14
|
-
formatter:
|
15
|
-
date_pattern: '%H:%M:%S'
|
16
|
-
pattern : '%d %l: %m '
|
17
|
-
type : PatternFormatter
|
@@ -1,79 +0,0 @@
|
|
1
|
-
RSpec.shared_examples 'logs request' do |method|
|
2
|
-
subject { log }
|
3
|
-
it { is_expected.to include(HttpLog::LOG_PREFIX + "Sending: #{method} http://#{host}:#{port}#{path}") }
|
4
|
-
end
|
5
|
-
|
6
|
-
RSpec.shared_examples 'logs nothing' do
|
7
|
-
subject { log }
|
8
|
-
it { is_expected.to eq('') }
|
9
|
-
end
|
10
|
-
|
11
|
-
RSpec.shared_examples 'logs expected response' do
|
12
|
-
it { is_expected.to include("Response:#{adapter.expected_response_body}") }
|
13
|
-
end
|
14
|
-
|
15
|
-
RSpec.shared_examples 'logs data' do
|
16
|
-
# Some adapters (YOU, Faraday!) re-order the keys for no bloody
|
17
|
-
# reason whatsover. So we need to check them individually. And some
|
18
|
-
# (guess who?) use non-standard URL encoding for spaces...
|
19
|
-
it do
|
20
|
-
data.split('&').each do |param|
|
21
|
-
is_expected.to match(Regexp.new(param.gsub(' ', '( |%20|\\\+)')))
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
RSpec.shared_examples 'logs status' do |status|
|
27
|
-
it { is_expected.to include(["Status:", status].compact.join(' ')) }
|
28
|
-
end
|
29
|
-
|
30
|
-
RSpec.shared_examples 'logs benchmark' do
|
31
|
-
it { is_expected.to match(/Benchmark: \d+\.\d+ seconds/) }
|
32
|
-
end
|
33
|
-
|
34
|
-
RSpec.shared_examples 'data logging disabled' do
|
35
|
-
let(:log_data) { false }
|
36
|
-
it { is_expected.to_not include('Data:') }
|
37
|
-
end
|
38
|
-
|
39
|
-
RSpec.shared_examples 'response logging disabled' do
|
40
|
-
let(:log_response) { false }
|
41
|
-
it { is_expected.to_not include('Response:') }
|
42
|
-
end
|
43
|
-
|
44
|
-
RSpec.shared_examples 'benchmark logging disabled' do
|
45
|
-
let(:log_benchmark) { false }
|
46
|
-
it { is_expected.to_not include('Benchmark:') }
|
47
|
-
end
|
48
|
-
|
49
|
-
RSpec.shared_examples 'with prefix response lines' do
|
50
|
-
let(:prefix_response_lines) { true }
|
51
|
-
it { is_expected.to include('Response:') }
|
52
|
-
it { is_expected.to include('<html>') }
|
53
|
-
end
|
54
|
-
|
55
|
-
RSpec.shared_examples 'with line numbers' do
|
56
|
-
let(:prefix_response_lines) { true }
|
57
|
-
let(:prefix_line_numbers) { true }
|
58
|
-
it { is_expected.to include('Response:') }
|
59
|
-
it { is_expected.to include('1: <html>') }
|
60
|
-
end
|
61
|
-
|
62
|
-
RSpec.shared_examples 'with request logging disabled' do
|
63
|
-
let(:log_request) { false }
|
64
|
-
it { is_expected.to_not include('Sending: GET') }
|
65
|
-
end
|
66
|
-
|
67
|
-
RSpec.shared_examples 'with connection logging disabled' do
|
68
|
-
let(:log_connect) { false }
|
69
|
-
it { is_expected.to_not include('Connecting:') }
|
70
|
-
end
|
71
|
-
|
72
|
-
RSpec.shared_examples 'filtered parameters' do
|
73
|
-
let(:filter_parameters) { %w(foo) }
|
74
|
-
|
75
|
-
it 'masks the filtered value' do
|
76
|
-
# is_expected.to include('foo=[FILTERED]&').or exclude('foo')
|
77
|
-
is_expected.to_not include('secret')
|
78
|
-
end
|
79
|
-
end
|
data/spec/support/test.bin
DELETED
Binary file
|
data/spec/support/test.pdf
DELETED
@@ -1,198 +0,0 @@
|
|
1
|
-
%PDF-1.3
|
2
|
-
%����
|
3
|
-
|
4
|
-
1 0 obj
|
5
|
-
<<
|
6
|
-
/Type /Catalog
|
7
|
-
/Outlines 2 0 R
|
8
|
-
/Pages 3 0 R
|
9
|
-
>>
|
10
|
-
endobj
|
11
|
-
|
12
|
-
2 0 obj
|
13
|
-
<<
|
14
|
-
/Type /Outlines
|
15
|
-
/Count 0
|
16
|
-
>>
|
17
|
-
endobj
|
18
|
-
|
19
|
-
3 0 obj
|
20
|
-
<<
|
21
|
-
/Type /Pages
|
22
|
-
/Count 2
|
23
|
-
/Kids [ 4 0 R 6 0 R ]
|
24
|
-
>>
|
25
|
-
endobj
|
26
|
-
|
27
|
-
4 0 obj
|
28
|
-
<<
|
29
|
-
/Type /Page
|
30
|
-
/Parent 3 0 R
|
31
|
-
/Resources <<
|
32
|
-
/Font <<
|
33
|
-
/F1 9 0 R
|
34
|
-
>>
|
35
|
-
/ProcSet 8 0 R
|
36
|
-
>>
|
37
|
-
/MediaBox [0 0 612.0000 792.0000]
|
38
|
-
/Contents 5 0 R
|
39
|
-
>>
|
40
|
-
endobj
|
41
|
-
|
42
|
-
5 0 obj
|
43
|
-
<< /Length 1074 >>
|
44
|
-
stream
|
45
|
-
2 J
|
46
|
-
BT
|
47
|
-
0 0 0 rg
|
48
|
-
/F1 0027 Tf
|
49
|
-
57.3750 722.2800 Td
|
50
|
-
( A Simple PDF File ) Tj
|
51
|
-
ET
|
52
|
-
BT
|
53
|
-
/F1 0010 Tf
|
54
|
-
69.2500 688.6080 Td
|
55
|
-
( This is a small demonstration .pdf file - ) Tj
|
56
|
-
ET
|
57
|
-
BT
|
58
|
-
/F1 0010 Tf
|
59
|
-
69.2500 664.7040 Td
|
60
|
-
( just for use in the Virtual Mechanics tutorials. More text. And more ) Tj
|
61
|
-
ET
|
62
|
-
BT
|
63
|
-
/F1 0010 Tf
|
64
|
-
69.2500 652.7520 Td
|
65
|
-
( text. And more text. And more text. And more text. ) Tj
|
66
|
-
ET
|
67
|
-
BT
|
68
|
-
/F1 0010 Tf
|
69
|
-
69.2500 628.8480 Td
|
70
|
-
( And more text. And more text. And more text. And more text. And more ) Tj
|
71
|
-
ET
|
72
|
-
BT
|
73
|
-
/F1 0010 Tf
|
74
|
-
69.2500 616.8960 Td
|
75
|
-
( text. And more text. Boring, zzzzz. And more text. And more text. And ) Tj
|
76
|
-
ET
|
77
|
-
BT
|
78
|
-
/F1 0010 Tf
|
79
|
-
69.2500 604.9440 Td
|
80
|
-
( more text. And more text. And more text. And more text. And more text. ) Tj
|
81
|
-
ET
|
82
|
-
BT
|
83
|
-
/F1 0010 Tf
|
84
|
-
69.2500 592.9920 Td
|
85
|
-
( And more text. And more text. ) Tj
|
86
|
-
ET
|
87
|
-
BT
|
88
|
-
/F1 0010 Tf
|
89
|
-
69.2500 569.0880 Td
|
90
|
-
( And more text. And more text. And more text. And more text. And more ) Tj
|
91
|
-
ET
|
92
|
-
BT
|
93
|
-
/F1 0010 Tf
|
94
|
-
69.2500 557.1360 Td
|
95
|
-
( text. And more text. And more text. Even more. Continued on page 2 ...) Tj
|
96
|
-
ET
|
97
|
-
endstream
|
98
|
-
endobj
|
99
|
-
|
100
|
-
6 0 obj
|
101
|
-
<<
|
102
|
-
/Type /Page
|
103
|
-
/Parent 3 0 R
|
104
|
-
/Resources <<
|
105
|
-
/Font <<
|
106
|
-
/F1 9 0 R
|
107
|
-
>>
|
108
|
-
/ProcSet 8 0 R
|
109
|
-
>>
|
110
|
-
/MediaBox [0 0 612.0000 792.0000]
|
111
|
-
/Contents 7 0 R
|
112
|
-
>>
|
113
|
-
endobj
|
114
|
-
|
115
|
-
7 0 obj
|
116
|
-
<< /Length 676 >>
|
117
|
-
stream
|
118
|
-
2 J
|
119
|
-
BT
|
120
|
-
0 0 0 rg
|
121
|
-
/F1 0027 Tf
|
122
|
-
57.3750 722.2800 Td
|
123
|
-
( Simple PDF File 2 ) Tj
|
124
|
-
ET
|
125
|
-
BT
|
126
|
-
/F1 0010 Tf
|
127
|
-
69.2500 688.6080 Td
|
128
|
-
( ...continued from page 1. Yet more text. And more text. And more text. ) Tj
|
129
|
-
ET
|
130
|
-
BT
|
131
|
-
/F1 0010 Tf
|
132
|
-
69.2500 676.6560 Td
|
133
|
-
( And more text. And more text. And more text. And more text. And more ) Tj
|
134
|
-
ET
|
135
|
-
BT
|
136
|
-
/F1 0010 Tf
|
137
|
-
69.2500 664.7040 Td
|
138
|
-
( text. Oh, how boring typing this stuff. But not as boring as watching ) Tj
|
139
|
-
ET
|
140
|
-
BT
|
141
|
-
/F1 0010 Tf
|
142
|
-
69.2500 652.7520 Td
|
143
|
-
( paint dry. And more text. And more text. And more text. And more text. ) Tj
|
144
|
-
ET
|
145
|
-
BT
|
146
|
-
/F1 0010 Tf
|
147
|
-
69.2500 640.8000 Td
|
148
|
-
( Boring. More, a little more text. The end, and just as well. ) Tj
|
149
|
-
ET
|
150
|
-
endstream
|
151
|
-
endobj
|
152
|
-
|
153
|
-
8 0 obj
|
154
|
-
[/PDF /Text]
|
155
|
-
endobj
|
156
|
-
|
157
|
-
9 0 obj
|
158
|
-
<<
|
159
|
-
/Type /Font
|
160
|
-
/Subtype /Type1
|
161
|
-
/Name /F1
|
162
|
-
/BaseFont /Helvetica
|
163
|
-
/Encoding /WinAnsiEncoding
|
164
|
-
>>
|
165
|
-
endobj
|
166
|
-
|
167
|
-
10 0 obj
|
168
|
-
<<
|
169
|
-
/Creator (Rave \(http://www.nevrona.com/rave\))
|
170
|
-
/Producer (Nevrona Designs)
|
171
|
-
/CreationDate (D:20060301072826)
|
172
|
-
>>
|
173
|
-
endobj
|
174
|
-
|
175
|
-
xref
|
176
|
-
0 11
|
177
|
-
0000000000 65535 f
|
178
|
-
0000000019 00000 n
|
179
|
-
0000000093 00000 n
|
180
|
-
0000000147 00000 n
|
181
|
-
0000000222 00000 n
|
182
|
-
0000000390 00000 n
|
183
|
-
0000001522 00000 n
|
184
|
-
0000001690 00000 n
|
185
|
-
0000002423 00000 n
|
186
|
-
0000002456 00000 n
|
187
|
-
0000002574 00000 n
|
188
|
-
|
189
|
-
trailer
|
190
|
-
<<
|
191
|
-
/Size 11
|
192
|
-
/Root 1 0 R
|
193
|
-
/Info 10 0 R
|
194
|
-
>>
|
195
|
-
|
196
|
-
startxref
|
197
|
-
2714
|
198
|
-
%%EOF
|
data/spec/support/test_server.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'rack'
|
5
|
-
|
6
|
-
module Httplog
|
7
|
-
module Test
|
8
|
-
class Server
|
9
|
-
def call(env)
|
10
|
-
@root = __dir__
|
11
|
-
path = Rack::Utils.unescape(env['PATH_INFO'])
|
12
|
-
path += 'index.html' if path == '/'
|
13
|
-
file = @root + path.to_s
|
14
|
-
|
15
|
-
params = Rack::Utils.parse_nested_query(env['QUERY_STRING'])
|
16
|
-
|
17
|
-
headers = { 'Content-Type' => 'text/html' }
|
18
|
-
|
19
|
-
if params['redirect']
|
20
|
-
[301, { 'Location' => '/index.html' }, '']
|
21
|
-
|
22
|
-
elsif File.exist?(file)
|
23
|
-
headers['Content-Type'] = 'application/octet-stream' if File.extname(file) == '.bin'
|
24
|
-
headers['Content-Type'] = 'application/pdf' if File.extname(file) == '.pdf'
|
25
|
-
headers['Content-Type'] = 'text/html; charset=UTF-8' if path =~ /utf8/
|
26
|
-
headers['Content-Encoding'] = 'gzip' if File.extname(file) == '.gz'
|
27
|
-
[200, headers, File.binread(file)]
|
28
|
-
else
|
29
|
-
[404, { 'Content-Type' => 'text/plain' }, 'file not found']
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
Binary file
|