kronk 1.8.3 → 1.8.4
Sign up to get free protection for your applications and to get access to all the features.
- data/History.rdoc +11 -1
- data/lib/kronk.rb +1 -1
- data/lib/kronk/cmd.rb +12 -6
- data/lib/kronk/request.rb +14 -9
- data/lib/kronk/response.rb +3 -0
- data/test/test_input_reader.rb +3 -3
- data/test/test_player.rb +5 -5
- data/test/test_request.rb +12 -3
- data/test/test_request_parser.rb +2 -2
- metadata +65 -16
data/History.rdoc
CHANGED
data/lib/kronk.rb
CHANGED
data/lib/kronk/cmd.rb
CHANGED
@@ -204,8 +204,8 @@ Parse and run diffs against data from live and cached http responses.
|
|
204
204
|
end
|
205
205
|
|
206
206
|
|
207
|
-
opt.on('-
|
208
|
-
'
|
207
|
+
opt.on('-I', '--head [HEADER1,HEADER2]', Array,
|
208
|
+
'Use all or given headers only in the response') do |value|
|
209
209
|
options[:show_headers] ||= []
|
210
210
|
|
211
211
|
if value
|
@@ -215,12 +215,12 @@ Parse and run diffs against data from live and cached http responses.
|
|
215
215
|
options[:show_headers] = true
|
216
216
|
end
|
217
217
|
|
218
|
-
options[:no_body] =
|
218
|
+
options[:no_body] = true
|
219
219
|
end
|
220
220
|
|
221
221
|
|
222
|
-
opt.on('-
|
223
|
-
'
|
222
|
+
opt.on('-i', '--include [HEADER1,HEADER2]', Array,
|
223
|
+
'Include all or given headers in response') do |value|
|
224
224
|
options[:show_headers] ||= []
|
225
225
|
|
226
226
|
if value
|
@@ -230,7 +230,7 @@ Parse and run diffs against data from live and cached http responses.
|
|
230
230
|
options[:show_headers] = true
|
231
231
|
end
|
232
232
|
|
233
|
-
options[:no_body] =
|
233
|
+
options[:no_body] = false
|
234
234
|
end
|
235
235
|
|
236
236
|
|
@@ -394,6 +394,12 @@ Parse and run diffs against data from live and cached http responses.
|
|
394
394
|
end
|
395
395
|
|
396
396
|
|
397
|
+
opt.on('--default-host STR', String,
|
398
|
+
'Default host to use if missing') do |value|
|
399
|
+
Kronk.config[:default_host] = value
|
400
|
+
end
|
401
|
+
|
402
|
+
|
397
403
|
opt.on('-F', '--form STR', String,
|
398
404
|
'Set request body with form headers; overrides -d') do |value|
|
399
405
|
options[:form] = value
|
data/lib/kronk/request.rb
CHANGED
@@ -47,13 +47,18 @@ class Kronk
|
|
47
47
|
# path and options.
|
48
48
|
|
49
49
|
def self.build_uri uri, opts={}
|
50
|
-
uri
|
51
|
-
suffix = opts[:uri_suffix]
|
50
|
+
uri ||= opts[:host]
|
52
51
|
|
53
|
-
uri = "
|
54
|
-
uri = "
|
55
|
-
|
56
|
-
uri = URI.parse
|
52
|
+
uri = "#{uri}#{opts[:path]}#{opts[:uri_suffix]}"
|
53
|
+
uri = "http://#{uri}" unless uri.to_s =~ %r{^(\w+://|/)}
|
54
|
+
|
55
|
+
uri = URI.parse uri unless URI === uri
|
56
|
+
|
57
|
+
unless uri.host
|
58
|
+
host = Kronk.config[:default_host]
|
59
|
+
host = "http://#{host}" unless host.to_s =~ %r{^\w+://}
|
60
|
+
uri = URI.parse(host) + uri
|
61
|
+
end
|
57
62
|
|
58
63
|
if opts[:query]
|
59
64
|
query = build_query opts[:query]
|
@@ -94,7 +99,7 @@ class Kronk
|
|
94
99
|
lines.shift.strip =~ REQUEST_LINE_MATCHER
|
95
100
|
opts.merge! :http_method => $1,
|
96
101
|
:host => $2,
|
97
|
-
:
|
102
|
+
:path => ($3 || $4)
|
98
103
|
|
99
104
|
lines.each_with_index do |line, i|
|
100
105
|
case line
|
@@ -114,7 +119,7 @@ class Kronk
|
|
114
119
|
opts[:data] = lines[body_start..-1].join("\n") if body_start
|
115
120
|
|
116
121
|
opts.delete(:host) if !opts[:host]
|
117
|
-
opts.delete(:
|
122
|
+
opts.delete(:path) if !opts[:path]
|
118
123
|
opts.delete(:headers) if opts[:headers].empty?
|
119
124
|
opts.delete(:http_method) if !opts[:http_method]
|
120
125
|
opts.delete(:data) if opts[:data] && opts[:data].strip.empty?
|
@@ -451,7 +456,7 @@ class Kronk
|
|
451
456
|
def to_hash
|
452
457
|
hash = {
|
453
458
|
:host => "#{@uri.scheme}://#{@uri.host}:#{@uri.port}",
|
454
|
-
:
|
459
|
+
:path => @uri.request_uri,
|
455
460
|
:user_agent => self.user_agent,
|
456
461
|
:timeout => @timeout,
|
457
462
|
:http_method => self.http_method,
|
data/lib/kronk/response.rb
CHANGED
@@ -500,8 +500,11 @@ class Kronk
|
|
500
500
|
def follow_redirect opts={}, &block
|
501
501
|
return if !redirect?
|
502
502
|
new_opts = @request ? @request.to_hash : {}
|
503
|
+
|
503
504
|
new_opts[:http_method] = "GET" if @code == "303"
|
504
505
|
new_opts.merge!(opts)
|
506
|
+
|
507
|
+
new_opts.delete(:path)
|
505
508
|
new_opts.delete(:auth) if !opts[:trust_location] &&
|
506
509
|
(!@request || self.location.host != self.uri.host)
|
507
510
|
|
data/test/test_input_reader.rb
CHANGED
@@ -25,7 +25,7 @@ class TestInputReader < Test::Unit::TestCase
|
|
25
25
|
def test_get_next
|
26
26
|
(1..3).each do |num|
|
27
27
|
expected = {
|
28
|
-
:
|
28
|
+
:path => "/path#{num}"
|
29
29
|
}
|
30
30
|
assert_equal expected, @input.get_next
|
31
31
|
end
|
@@ -43,7 +43,7 @@ class TestInputReader < Test::Unit::TestCase
|
|
43
43
|
"Authorization" => "Basic Ym9iOmZvb2Jhcg=="
|
44
44
|
},
|
45
45
|
:http_method => "GET",
|
46
|
-
:
|
46
|
+
:path => "/path",
|
47
47
|
:host => "example.com:80",
|
48
48
|
}
|
49
49
|
|
@@ -65,7 +65,7 @@ class TestInputReader < Test::Unit::TestCase
|
|
65
65
|
"Authorization" => "Basic Ym9iOmZvb2Jhcg=="
|
66
66
|
},
|
67
67
|
:http_method => "GET",
|
68
|
-
:
|
68
|
+
:path => "/path",
|
69
69
|
:host => "example.com:80",
|
70
70
|
}
|
71
71
|
|
data/test/test_player.rb
CHANGED
@@ -162,21 +162,21 @@ class TestPlayer < Test::Unit::TestCase
|
|
162
162
|
@player.input.io.rewind
|
163
163
|
@player.input.io.close_write
|
164
164
|
|
165
|
-
@player.queue.concat [{:
|
165
|
+
@player.queue.concat [{:path => "/req1"}, {:path => "/req2"}]
|
166
166
|
|
167
167
|
part1 = (1..2).map{|n| "/req#{n}"}
|
168
168
|
part2 = (3..5).map{|n| "/req#{n}"}
|
169
169
|
|
170
170
|
part1.each do |path|
|
171
171
|
mock_requests "example.com", "beta-example.com",
|
172
|
-
:
|
173
|
-
:query
|
172
|
+
:path => path,
|
173
|
+
:query => "foo=bar"
|
174
174
|
end
|
175
175
|
|
176
176
|
part2.each do |path|
|
177
177
|
mock_requests "example.com", "beta-example.com",
|
178
|
-
:
|
179
|
-
:query
|
178
|
+
:path => path,
|
179
|
+
:query => "foo=bar"
|
180
180
|
end
|
181
181
|
|
182
182
|
@player.compare "example.com", "beta-example.com", :query => "foo=bar"
|
data/test/test_request.rb
CHANGED
@@ -42,10 +42,10 @@ class TestRequest < Test::Unit::TestCase
|
|
42
42
|
|
43
43
|
|
44
44
|
def test_parse_to_hash
|
45
|
-
expected = {:
|
45
|
+
expected = {:path => "/foobar"}
|
46
46
|
assert_equal expected, Kronk::Request.parse_to_hash("/foobar")
|
47
47
|
|
48
|
-
expected = {:http_method => "GET", :
|
48
|
+
expected = {:http_method => "GET", :path => "/foobar"}
|
49
49
|
assert_equal expected, Kronk::Request.parse_to_hash("GET /foobar")
|
50
50
|
|
51
51
|
expected.merge! :host => "example.com"
|
@@ -62,7 +62,7 @@ class TestRequest < Test::Unit::TestCase
|
|
62
62
|
|
63
63
|
|
64
64
|
def test_parse_to_hash_url
|
65
|
-
expected = {:host => "http://example.com", :
|
65
|
+
expected = {:host => "http://example.com", :path => "/foobar?foo=bar"}
|
66
66
|
assert_equal expected,
|
67
67
|
Kronk::Request.parse_to_hash("http://example.com/foobar?foo=bar")
|
68
68
|
end
|
@@ -130,6 +130,15 @@ class TestRequest < Test::Unit::TestCase
|
|
130
130
|
end
|
131
131
|
|
132
132
|
|
133
|
+
def test_build_path
|
134
|
+
uri = Kronk::Request.build_uri "http://example.com/",
|
135
|
+
:path => "/path",
|
136
|
+
:uri_suffix => "/to/resource"
|
137
|
+
|
138
|
+
assert_equal "http://example.com//path/to/resource", uri.to_s
|
139
|
+
end
|
140
|
+
|
141
|
+
|
133
142
|
def test_build_uri_from_uri
|
134
143
|
query = {'a' => '1', 'b' => '2'}
|
135
144
|
uri = Kronk::Request.build_uri URI.parse("http://example.com/path"),
|
data/test/test_request_parser.rb
CHANGED
@@ -17,10 +17,10 @@ class TestRequestParser < Test::Unit::TestCase
|
|
17
17
|
|
18
18
|
|
19
19
|
def test_parse
|
20
|
-
expected = {:
|
20
|
+
expected = {:path => "/foobar"}
|
21
21
|
assert_equal expected, Kronk::Player::RequestParser.parse("/foobar")
|
22
22
|
|
23
|
-
expected = {:http_method => "GET", :
|
23
|
+
expected = {:http_method => "GET", :path => "/foobar"}
|
24
24
|
assert_equal expected, Kronk::Player::RequestParser.parse("GET /foobar")
|
25
25
|
|
26
26
|
expected.merge! :host => "example.com"
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kronk
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.8.
|
4
|
+
version: 1.8.4
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-03-20 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|
16
|
-
requirement:
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,15 @@ dependencies:
|
|
21
21
|
version: '1.5'
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements:
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '1.5'
|
25
30
|
- !ruby/object:Gem::Dependency
|
26
31
|
name: cookiejar
|
27
|
-
requirement:
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
28
33
|
none: false
|
29
34
|
requirements:
|
30
35
|
- - ~>
|
@@ -32,10 +37,15 @@ dependencies:
|
|
32
37
|
version: 0.3.0
|
33
38
|
type: :runtime
|
34
39
|
prerelease: false
|
35
|
-
version_requirements:
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ~>
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: 0.3.0
|
36
46
|
- !ruby/object:Gem::Dependency
|
37
47
|
name: plist
|
38
|
-
requirement:
|
48
|
+
requirement: !ruby/object:Gem::Requirement
|
39
49
|
none: false
|
40
50
|
requirements:
|
41
51
|
- - ~>
|
@@ -43,10 +53,15 @@ dependencies:
|
|
43
53
|
version: 3.1.0
|
44
54
|
type: :development
|
45
55
|
prerelease: false
|
46
|
-
version_requirements:
|
56
|
+
version_requirements: !ruby/object:Gem::Requirement
|
57
|
+
none: false
|
58
|
+
requirements:
|
59
|
+
- - ~>
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: 3.1.0
|
47
62
|
- !ruby/object:Gem::Dependency
|
48
63
|
name: nokogiri
|
49
|
-
requirement:
|
64
|
+
requirement: !ruby/object:Gem::Requirement
|
50
65
|
none: false
|
51
66
|
requirements:
|
52
67
|
- - ~>
|
@@ -54,10 +69,15 @@ dependencies:
|
|
54
69
|
version: '1.4'
|
55
70
|
type: :development
|
56
71
|
prerelease: false
|
57
|
-
version_requirements:
|
72
|
+
version_requirements: !ruby/object:Gem::Requirement
|
73
|
+
none: false
|
74
|
+
requirements:
|
75
|
+
- - ~>
|
76
|
+
- !ruby/object:Gem::Version
|
77
|
+
version: '1.4'
|
58
78
|
- !ruby/object:Gem::Dependency
|
59
79
|
name: mocha
|
60
|
-
requirement:
|
80
|
+
requirement: !ruby/object:Gem::Requirement
|
61
81
|
none: false
|
62
82
|
requirements:
|
63
83
|
- - ~>
|
@@ -65,18 +85,44 @@ dependencies:
|
|
65
85
|
version: 0.9.12
|
66
86
|
type: :development
|
67
87
|
prerelease: false
|
68
|
-
version_requirements:
|
88
|
+
version_requirements: !ruby/object:Gem::Requirement
|
89
|
+
none: false
|
90
|
+
requirements:
|
91
|
+
- - ~>
|
92
|
+
- !ruby/object:Gem::Version
|
93
|
+
version: 0.9.12
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rdoc
|
96
|
+
requirement: !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ~>
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: '3.10'
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: !ruby/object:Gem::Requirement
|
105
|
+
none: false
|
106
|
+
requirements:
|
107
|
+
- - ~>
|
108
|
+
- !ruby/object:Gem::Version
|
109
|
+
version: '3.10'
|
69
110
|
- !ruby/object:Gem::Dependency
|
70
111
|
name: hoe
|
71
|
-
requirement:
|
112
|
+
requirement: !ruby/object:Gem::Requirement
|
72
113
|
none: false
|
73
114
|
requirements:
|
74
115
|
- - ~>
|
75
116
|
- !ruby/object:Gem::Version
|
76
|
-
version: '2.
|
117
|
+
version: '2.13'
|
77
118
|
type: :development
|
78
119
|
prerelease: false
|
79
|
-
version_requirements:
|
120
|
+
version_requirements: !ruby/object:Gem::Requirement
|
121
|
+
none: false
|
122
|
+
requirements:
|
123
|
+
- - ~>
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
version: '2.13'
|
80
126
|
description: ! 'Kronk runs diffs against data from live and cached http responses.
|
81
127
|
|
82
128
|
Kronk was made possible by the sponsoring of AT&T Interactive.'
|
@@ -173,6 +219,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
173
219
|
- - ! '>='
|
174
220
|
- !ruby/object:Gem::Version
|
175
221
|
version: '0'
|
222
|
+
segments:
|
223
|
+
- 0
|
224
|
+
hash: -3368818525968030457
|
176
225
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
177
226
|
none: false
|
178
227
|
requirements:
|
@@ -181,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
181
230
|
version: '0'
|
182
231
|
requirements: []
|
183
232
|
rubyforge_project: kronk
|
184
|
-
rubygems_version: 1.8.
|
233
|
+
rubygems_version: 1.8.18
|
185
234
|
signing_key:
|
186
235
|
specification_version: 3
|
187
236
|
summary: Kronk runs diffs against data from live and cached http responses
|