httplog 1.3.1 → 1.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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/Guardfile
DELETED
@@ -1,25 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
# A sample Guardfile
|
4
|
-
# More info at https://github.com/guard/guard#readme
|
5
|
-
|
6
|
-
guard 'rspec', cmd: 'bundle exec rspec' do
|
7
|
-
watch(%r{^spec/.+_spec\.rb$})
|
8
|
-
watch(%r{^lib/(.+)\.rb$}) { |m| "spec/lib/#{m[1]}_spec.rb" }
|
9
|
-
watch('spec/spec_helper.rb') { 'spec' }
|
10
|
-
|
11
|
-
# Rails example
|
12
|
-
watch(%r{^app/(.+)\.rb$}) { |m| "spec/#{m[1]}_spec.rb" }
|
13
|
-
watch(%r{^app/(.*)(\.erb|\.haml)$}) { |m| "spec/#{m[1]}#{m[2]}_spec.rb" }
|
14
|
-
watch(%r{^app/controllers/(.+)_(controller)\.rb$}) { |m| ["spec/routing/#{m[1]}_routing_spec.rb", "spec/#{m[2]}s/#{m[1]}_#{m[2]}_spec.rb", "spec/acceptance/#{m[1]}_spec.rb"] }
|
15
|
-
watch(%r{^spec/support/(.+)\.rb$}) { 'spec' }
|
16
|
-
watch('config/routes.rb') { 'spec/routing' }
|
17
|
-
watch('app/controllers/application_controller.rb') { 'spec/controllers' }
|
18
|
-
|
19
|
-
# Capybara request specs
|
20
|
-
watch(%r{^app/views/(.+)/.*\.(erb|haml)$}) { |m| "spec/requests/#{m[1]}_spec.rb" }
|
21
|
-
|
22
|
-
# Turnip features and steps
|
23
|
-
watch(%r{^spec/acceptance/(.+)\.feature$})
|
24
|
-
watch(%r{^spec/acceptance/steps/(.+)_steps\.rb$}) { |m| Dir[File.join("**/#{m[1]}.feature")][0] || 'spec/acceptance' }
|
25
|
-
end
|
data/MIT-LICENSE
DELETED
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright 2011 Thilo Rusche
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
-
a copy of this software and associated documentation files (the
|
5
|
-
"Software"), to deal in the Software without restriction, including
|
6
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
-
permit persons to whom the Software is furnished to do so, subject to
|
9
|
-
the following conditions:
|
10
|
-
|
11
|
-
The above copyright notice and this permission notice shall be
|
12
|
-
included in all copies or substantial portions of the Software.
|
13
|
-
|
14
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/Rakefile
DELETED
@@ -1,46 +0,0 @@
|
|
1
|
-
#!/usr/bin/env rake
|
2
|
-
# frozen_string_literal: true
|
3
|
-
|
4
|
-
begin
|
5
|
-
require 'bundler/setup'
|
6
|
-
rescue LoadError
|
7
|
-
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
8
|
-
end
|
9
|
-
begin
|
10
|
-
require 'rdoc/task'
|
11
|
-
rescue LoadError
|
12
|
-
require 'rdoc/rdoc'
|
13
|
-
require 'rake/rdoctask'
|
14
|
-
RDoc::Task = Rake::RDocTask
|
15
|
-
end
|
16
|
-
require 'rspec/core/rake_task'
|
17
|
-
|
18
|
-
desc 'Run specs'
|
19
|
-
RSpec::Core::RakeTask.new(:spec)
|
20
|
-
|
21
|
-
desc 'Generate documentation'
|
22
|
-
RDoc::Task.new(:rdoc) do |rdoc|
|
23
|
-
rdoc.rdoc_dir = 'rdoc'
|
24
|
-
rdoc.title = 'HttpLog'
|
25
|
-
rdoc.options << '--line-numbers' << '--inline-source'
|
26
|
-
rdoc.rdoc_files.include('README.rdoc')
|
27
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
28
|
-
end
|
29
|
-
|
30
|
-
require 'rake/testtask'
|
31
|
-
|
32
|
-
Rake::TestTask.new(:test) do |t|
|
33
|
-
t.libs << 'lib'
|
34
|
-
t.libs << 'test'
|
35
|
-
t.pattern = 'test/**/*_test.rb'
|
36
|
-
t.verbose = false
|
37
|
-
end
|
38
|
-
|
39
|
-
# ----- Packaging -----
|
40
|
-
task :build do
|
41
|
-
sh 'gem build httplog.gemspec'
|
42
|
-
mkdir_p 'pkg'
|
43
|
-
sh 'mv *.gem pkg/ '
|
44
|
-
end
|
45
|
-
|
46
|
-
task default: :spec
|
data/gemfiles/http3.gemfile
DELETED
data/gemfiles/http4.gemfile
DELETED
data/gemfiles/http5.gemfile
DELETED
data/gemfiles/rack1.gemfile
DELETED
data/gemfiles/rack2.gemfile
DELETED
@@ -1,26 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'ethon'
|
4
|
-
class EthonAdapter < HTTPBaseAdapter
|
5
|
-
def send_get_request
|
6
|
-
easy = Ethon::Easy.new
|
7
|
-
easy.http_request(parse_uri(true).to_s, :get, headers: @headers)
|
8
|
-
easy.perform
|
9
|
-
end
|
10
|
-
|
11
|
-
def send_head_request
|
12
|
-
easy = Ethon::Easy.new
|
13
|
-
easy.http_request(parse_uri.to_s, :head, headers: @headers)
|
14
|
-
easy.perform
|
15
|
-
end
|
16
|
-
|
17
|
-
def send_post_request
|
18
|
-
easy = Ethon::Easy.new
|
19
|
-
easy.http_request(parse_uri.to_s, :post, headers: @headers, body: @data)
|
20
|
-
easy.perform
|
21
|
-
end
|
22
|
-
|
23
|
-
def self.is_libcurl?
|
24
|
-
true
|
25
|
-
end
|
26
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'excon'
|
4
|
-
class ExconAdapter < HTTPBaseAdapter
|
5
|
-
def send_get_request
|
6
|
-
Excon.get(parse_uri(true).to_s, headers: @headers)
|
7
|
-
end
|
8
|
-
|
9
|
-
def send_head_request
|
10
|
-
Excon.head(parse_uri.to_s, headers: @headers)
|
11
|
-
end
|
12
|
-
|
13
|
-
def send_post_request
|
14
|
-
Excon.post(parse_uri.to_s, body: @data, headers: @headers)
|
15
|
-
end
|
16
|
-
end
|
@@ -1,59 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'faraday'
|
4
|
-
class FaradayAdapter < HTTPBaseAdapter
|
5
|
-
def send_get_request
|
6
|
-
connection.get do |req|
|
7
|
-
req.url parse_uri(true).to_s
|
8
|
-
req.headers = @headers
|
9
|
-
end
|
10
|
-
end
|
11
|
-
|
12
|
-
def send_head_request
|
13
|
-
connection.head do |req|
|
14
|
-
req.url parse_uri.to_s
|
15
|
-
req.headers = @headers
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
def send_post_request
|
20
|
-
connection.post do |req|
|
21
|
-
req.url parse_uri.to_s
|
22
|
-
req.headers = @headers
|
23
|
-
req.body = @data
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
def send_post_form_request
|
28
|
-
connection.post do |req|
|
29
|
-
req.url parse_uri.to_s
|
30
|
-
req.headers = @headers
|
31
|
-
req.body = @params
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def send_multipart_post_request
|
36
|
-
file_upload = Faraday::UploadIO.new(@params['file'], 'text/plain')
|
37
|
-
|
38
|
-
connection.post do |req|
|
39
|
-
req.url parse_uri.to_s
|
40
|
-
req.headers = @headers
|
41
|
-
req.body = @params.merge('file' => file_upload)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
def logs_form_data?
|
46
|
-
false
|
47
|
-
end
|
48
|
-
|
49
|
-
private
|
50
|
-
|
51
|
-
def connection
|
52
|
-
Faraday.new(url: "#{@protocol}://#{@host}:#{@port}") do |faraday|
|
53
|
-
faraday.request :multipart
|
54
|
-
faraday.request :url_encoded
|
55
|
-
|
56
|
-
faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
|
57
|
-
end
|
58
|
-
end
|
59
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'http'
|
4
|
-
class HTTPAdapter < HTTPBaseAdapter
|
5
|
-
def send_get_request
|
6
|
-
client.get(parse_uri(true).to_s)
|
7
|
-
end
|
8
|
-
|
9
|
-
def send_head_request
|
10
|
-
client.head(parse_uri.to_s)
|
11
|
-
end
|
12
|
-
|
13
|
-
def send_post_request
|
14
|
-
client.post(parse_uri.to_s, body: @data)
|
15
|
-
end
|
16
|
-
|
17
|
-
def send_post_form_request
|
18
|
-
client.post(parse_uri.to_s, form: @params)
|
19
|
-
end
|
20
|
-
|
21
|
-
private
|
22
|
-
|
23
|
-
def client
|
24
|
-
method_name = respond_to?(:with_headers) ? :with_headers : :headers
|
25
|
-
::HTTP.send(method_name, @headers)
|
26
|
-
end
|
27
|
-
end
|
@@ -1,39 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class HTTPBaseAdapter
|
4
|
-
def initialize(options = {})
|
5
|
-
@host = options.fetch(:host, 'localhost')
|
6
|
-
@port = options.fetch(:port, 80)
|
7
|
-
@path = options.fetch(:path, '/')
|
8
|
-
@headers = options.fetch(:headers, {})
|
9
|
-
@data = options.fetch(:data, nil)
|
10
|
-
@params = options.fetch(:params, {})
|
11
|
-
@protocol = options.fetch(:protocol, 'http')
|
12
|
-
end
|
13
|
-
|
14
|
-
def logs_data?
|
15
|
-
true
|
16
|
-
end
|
17
|
-
|
18
|
-
def logs_form_data?
|
19
|
-
true
|
20
|
-
end
|
21
|
-
|
22
|
-
def parse_uri(query=false)
|
23
|
-
uri = "#{@protocol}://#{@host}:#{@port}#{@path}"
|
24
|
-
uri = [uri, URI::encode(@data)].join('?') if query && @data
|
25
|
-
URI.parse(uri)
|
26
|
-
end
|
27
|
-
|
28
|
-
def expected_response_body
|
29
|
-
"\n<html>"
|
30
|
-
end
|
31
|
-
|
32
|
-
def self.is_libcurl?
|
33
|
-
false
|
34
|
-
end
|
35
|
-
|
36
|
-
def self.should_log_headers?
|
37
|
-
true
|
38
|
-
end
|
39
|
-
end
|
@@ -1,16 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'httparty'
|
4
|
-
class HTTPartyAdapter < HTTPBaseAdapter
|
5
|
-
def send_get_request
|
6
|
-
HTTParty.get(parse_uri(true).to_s, headers: @headers)
|
7
|
-
end
|
8
|
-
|
9
|
-
def send_head_request
|
10
|
-
HTTParty.head(parse_uri.to_s, headers: @headers)
|
11
|
-
end
|
12
|
-
|
13
|
-
def send_post_request
|
14
|
-
HTTParty.post(parse_uri.to_s, body: @data, headers: @headers)
|
15
|
-
end
|
16
|
-
end
|
@@ -1,31 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class HTTPClientAdapter < HTTPBaseAdapter
|
4
|
-
def send_get_request
|
5
|
-
::HTTPClient.get(parse_uri(true), header: @headers)
|
6
|
-
end
|
7
|
-
|
8
|
-
def send_head_request
|
9
|
-
::HTTPClient.head(parse_uri, header: @headers)
|
10
|
-
end
|
11
|
-
|
12
|
-
def send_post_request
|
13
|
-
::HTTPClient.post(parse_uri, body: @data, header: @headers)
|
14
|
-
end
|
15
|
-
|
16
|
-
def send_post_form_request
|
17
|
-
::HTTPClient.post(parse_uri, body: @params, header: @headers)
|
18
|
-
end
|
19
|
-
|
20
|
-
def send_multipart_post_request
|
21
|
-
send_post_form_request
|
22
|
-
end
|
23
|
-
|
24
|
-
def self.response_should_be
|
25
|
-
HTTP::Message
|
26
|
-
end
|
27
|
-
|
28
|
-
def logs_form_data?
|
29
|
-
false
|
30
|
-
end
|
31
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class NetHTTPAdapter < HTTPBaseAdapter
|
4
|
-
def send_get_request
|
5
|
-
path = @path
|
6
|
-
path = [@path, URI::encode(@data)].join('?') if @data
|
7
|
-
Net::HTTP.get_response(@host, path, @port)
|
8
|
-
end
|
9
|
-
|
10
|
-
def send_head_request
|
11
|
-
Net::HTTP.new(@host, @port).head(@path, @headers)
|
12
|
-
end
|
13
|
-
|
14
|
-
def send_post_request
|
15
|
-
Net::HTTP.new(@host, @port).post(@path, @data)
|
16
|
-
end
|
17
|
-
|
18
|
-
def send_post_form_request
|
19
|
-
Net::HTTP.post_form(parse_uri, @params)
|
20
|
-
end
|
21
|
-
end
|
@@ -1,19 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
class OpenUriAdapter < HTTPBaseAdapter
|
4
|
-
def send_get_request
|
5
|
-
open(parse_uri(true)) # rubocop:disable Security/Open
|
6
|
-
end
|
7
|
-
|
8
|
-
def expected_response_body
|
9
|
-
' (not available yet)'
|
10
|
-
end
|
11
|
-
|
12
|
-
def self.should_log_headers?
|
13
|
-
false
|
14
|
-
end
|
15
|
-
|
16
|
-
def logs_data?
|
17
|
-
false
|
18
|
-
end
|
19
|
-
end
|
@@ -1,36 +0,0 @@
|
|
1
|
-
# frozen_string_literal: true
|
2
|
-
|
3
|
-
require 'patron'
|
4
|
-
class PatronAdapter < HTTPBaseAdapter
|
5
|
-
def send_get_request
|
6
|
-
session = Patron::Session.new
|
7
|
-
session.get(parse_uri(true).to_s, @headers)
|
8
|
-
end
|
9
|
-
|
10
|
-
def send_head_request
|
11
|
-
session = Patron::Session.new
|
12
|
-
session.head(parse_uri.to_s, @headers)
|
13
|
-
end
|
14
|
-
|
15
|
-
def send_post_request
|
16
|
-
session = Patron::Session.new
|
17
|
-
session.post(parse_uri.to_s, @data, @headers)
|
18
|
-
end
|
19
|
-
|
20
|
-
def send_post_form_request
|
21
|
-
session = Patron::Session.new
|
22
|
-
session.post(parse_uri.to_s, @params, @headers)
|
23
|
-
end
|
24
|
-
|
25
|
-
def send_multipart_post_request
|
26
|
-
data = @params.dup
|
27
|
-
file = @params.delete('file')
|
28
|
-
|
29
|
-
session = Patron::Session.new
|
30
|
-
session.post_multipart(parse_uri.to_s, data, { file: file.path }, @headers)
|
31
|
-
end
|
32
|
-
|
33
|
-
def self.is_libcurl?
|
34
|
-
true
|
35
|
-
end
|
36
|
-
end
|