http-dump 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -4
- data/README.md +10 -0
- data/lib/http-dump.rb +6 -2
- data/lib/http-dump/version.rb +1 -1
- data/spec/http-dump_spec.rb +26 -0
- metadata +16 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4ead3b98fef4a7c3c5327688727e3cfd0d6ce134
|
4
|
+
data.tar.gz: 5baf3cafebeaeaec302da2ae7129e6fd8fa28a90
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 210b241a5f87affd2b9b2e96cc18458cffc6ed518e9619e1e7dc25dff5715e16950c90cdf9c6034a180ab38f18c80c77d9499e5ea6e795dcb4412d6acd192e5d
|
7
|
+
data.tar.gz: e5140d293c4ce462e8ac3f8add81ecc6c3aa6e1ef2ee025927ebb0a8ed6bc8f84bf8ef29f8465adddbb4fe4e2d5811ee335ba371d0f7fe40a429301810895a27
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
@@ -117,6 +117,16 @@ HTTPDump.dump {
|
|
117
117
|
}
|
118
118
|
```
|
119
119
|
|
120
|
+
### HTTPDump.output_encoding=
|
121
|
+
|
122
|
+
In some cases, encoding of request and response is not matched and it causes `Encoding::CompatibilityError`.
|
123
|
+
|
124
|
+
`HTTPDump.output_encoding=` may resolve the issue.
|
125
|
+
|
126
|
+
```ruby
|
127
|
+
HTTPDump.output_encoding = "utf-8"
|
128
|
+
```
|
129
|
+
|
120
130
|
### http-dump/enable
|
121
131
|
|
122
132
|
```sh
|
data/lib/http-dump.rb
CHANGED
@@ -3,7 +3,7 @@ require "http-dump/version"
|
|
3
3
|
|
4
4
|
class HTTPDump
|
5
5
|
class << self
|
6
|
-
attr_accessor :output, :quiet_format
|
6
|
+
attr_accessor :output, :quiet_format, :output_encoding
|
7
7
|
def enable!(options = {})
|
8
8
|
require 'webmock'
|
9
9
|
WebMock.enable!(options)
|
@@ -50,7 +50,11 @@ class HTTPDump
|
|
50
50
|
res << body
|
51
51
|
end
|
52
52
|
end
|
53
|
-
|
53
|
+
if @output_encoding
|
54
|
+
res.map{|d| d.force_encoding @output_encoding }.join("\n")
|
55
|
+
else
|
56
|
+
res.join("\n")
|
57
|
+
end
|
54
58
|
end
|
55
59
|
end
|
56
60
|
end
|
data/lib/http-dump/version.rb
CHANGED
data/spec/http-dump_spec.rb
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
# coding: utf-8
|
1
2
|
require 'spec_helper'
|
2
3
|
require 'uri'
|
3
4
|
require 'open-uri'
|
@@ -9,6 +10,7 @@ describe HTTPDump do
|
|
9
10
|
before(:each) do
|
10
11
|
HTTPDump.disable!
|
11
12
|
HTTPDump.output = output
|
13
|
+
HTTPDump.output_encoding = nil
|
12
14
|
end
|
13
15
|
|
14
16
|
after(:each) do
|
@@ -48,6 +50,30 @@ describe HTTPDump do
|
|
48
50
|
end
|
49
51
|
end
|
50
52
|
|
53
|
+
context '.output_encoding=' do
|
54
|
+
let(:request_header_with_utf8) { {"X-My-Header" => "日本語".force_encoding("utf-8")} }
|
55
|
+
let(:response_body_with_ascii) { "日本語".force_encoding("ascii") }
|
56
|
+
|
57
|
+
it 'raises encoding error if encoding of request and response is not matched and output_encoding is not set' do
|
58
|
+
expect {
|
59
|
+
stub_request(:get, 'http://example.com/').to_return({:body => response_body_with_ascii, :status => 200}).times(1)
|
60
|
+
HTTPDump.dump {
|
61
|
+
open('http://example.com/', request_header_with_utf8)
|
62
|
+
}
|
63
|
+
}.to raise_error(Encoding::CompatibilityError)
|
64
|
+
end
|
65
|
+
|
66
|
+
it 'does not raise encoding error if encoding of request and response is not matched but output_encoding is set' do
|
67
|
+
expect {
|
68
|
+
HTTPDump.output_encoding = "utf-8"
|
69
|
+
stub_request(:get, 'http://example.com/').to_return({:body => response_body_with_ascii, :status => 200}).times(1)
|
70
|
+
HTTPDump.dump {
|
71
|
+
open('http://example.com/', request_header_with_utf8)
|
72
|
+
}
|
73
|
+
}.not_to raise_error
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
51
77
|
it '.enable!' do
|
52
78
|
HTTPDump.enable!
|
53
79
|
HTTPDump.should_not_receive(:enable!)
|
metadata
CHANGED
@@ -1,69 +1,69 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: http-dump
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Yuichi Tateno
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-08-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: webmock
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- -
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- -
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - ~>
|
31
|
+
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '2.14'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - ~>
|
38
|
+
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '2.14'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: bundler
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- -
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
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
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
56
|
name: rake
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
|
-
- -
|
59
|
+
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
61
|
version: '0'
|
62
62
|
type: :development
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
|
-
- -
|
66
|
+
- - ">="
|
67
67
|
- !ruby/object:Gem::Version
|
68
68
|
version: '0'
|
69
69
|
description: Dump http request use WebMock.
|
@@ -73,9 +73,9 @@ executables: []
|
|
73
73
|
extensions: []
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
|
-
- .gitignore
|
77
|
-
- .rspec
|
78
|
-
- .travis.yml
|
76
|
+
- ".gitignore"
|
77
|
+
- ".rspec"
|
78
|
+
- ".travis.yml"
|
79
79
|
- Gemfile
|
80
80
|
- LICENSE.txt
|
81
81
|
- README.md
|
@@ -96,17 +96,17 @@ require_paths:
|
|
96
96
|
- lib
|
97
97
|
required_ruby_version: !ruby/object:Gem::Requirement
|
98
98
|
requirements:
|
99
|
-
- -
|
99
|
+
- - ">="
|
100
100
|
- !ruby/object:Gem::Version
|
101
101
|
version: '0'
|
102
102
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
103
103
|
requirements:
|
104
|
-
- -
|
104
|
+
- - ">="
|
105
105
|
- !ruby/object:Gem::Version
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.4.5
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Dump http request use WebMock.
|