request-replay 0.6.0 → 0.6.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +7 -0
- data/Rakefile +1 -1
- data/lib/request-replay.rb +3 -0
- data/lib/request-replay/middleware.rb +4 -2
- data/request-replay.gemspec +2 -2
- data/test/test_basic.rb +42 -4
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 757f765cde5cb73d14e26de907f2bc03322973ee
|
4
|
+
data.tar.gz: 0fa338334b76b3d678a2e676a3fe86e19a1d5cff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3c9a20be6d4bb76253ddebefd6aa54176564d7909b8508e1e7bd02fada6d0e9a7c986f6a678bde351276af31a34c0f4d4a1ab63ada383990369a33062789d19f
|
7
|
+
data.tar.gz: 739d4d94923788d1e27f1f12539c03c7182e1679ed601164e39d655bb2ab147a8061aef27c85ca0fbad557a3ed9af8a54df6d7a0bfe88dc84c93f2fe8a4dabd0
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,12 @@
|
|
1
1
|
# CHANGES
|
2
2
|
|
3
|
+
## request-replay 0.6.1 -- 2013-10-01
|
4
|
+
|
5
|
+
* Print error messages to env['rack.errors']
|
6
|
+
* Fixed a bug where the underlying Rack app might be modifying
|
7
|
+
the original env, making request-replay cannot reliably rebuild
|
8
|
+
the request.
|
9
|
+
|
3
10
|
## request-replay 0.6.0 -- 2013-10-01
|
4
11
|
|
5
12
|
* Added :read_wait option for waiting for the remote server responding.
|
data/Rakefile
CHANGED
data/lib/request-replay.rb
CHANGED
@@ -34,6 +34,9 @@ class RequestReplay
|
|
34
34
|
sock.close_write
|
35
35
|
IO.select([sock], [], [], read_wait) if read_wait
|
36
36
|
yield(sock) if block_given?
|
37
|
+
rescue => e
|
38
|
+
@env['rack.errors'].puts("[#{self.class.name}] Error: #{e.inspect}") if
|
39
|
+
@env['rack.errors']
|
37
40
|
ensure
|
38
41
|
sock.close
|
39
42
|
end
|
@@ -8,8 +8,10 @@ class RequestReplay::Middleware
|
|
8
8
|
|
9
9
|
def call env
|
10
10
|
# We don't want to read the socket in a thread, so create it in main
|
11
|
-
# thread, and send the data in a thread as we don't care the responses
|
12
|
-
|
11
|
+
# thread, and send the data in a thread as we don't care the responses.
|
12
|
+
# Also, unfortunately, we need to dup env because other middleware
|
13
|
+
# might be modifying it and make it not able to get the original env.
|
14
|
+
Thread.new(RequestReplay.new(env.dup, @host, @options), &:start)
|
13
15
|
@app.call(env)
|
14
16
|
end
|
15
17
|
end
|
data/request-replay.gemspec
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: request-replay 0.6.
|
2
|
+
# stub: request-replay 0.6.1 ruby lib
|
3
3
|
|
4
4
|
Gem::Specification.new do |s|
|
5
5
|
s.name = "request-replay"
|
6
|
-
s.version = "0.6.
|
6
|
+
s.version = "0.6.1"
|
7
7
|
|
8
8
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
9
9
|
s.authors = ["Lin Jen-Shin (godfat)"]
|
data/test/test_basic.rb
CHANGED
@@ -40,6 +40,10 @@ describe RequestReplay do
|
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
43
|
+
after do
|
44
|
+
Muack.verify
|
45
|
+
end
|
46
|
+
|
43
47
|
should 'GET' do
|
44
48
|
verify[request[{'REQUEST_METHOD' => 'GET'}, 'Host' => 'ex.com'], <<-HTTP]
|
45
49
|
GET /?q=1 HTTP/1.1\r
|
@@ -77,19 +81,53 @@ Pork: BEEF\r
|
|
77
81
|
HTTP
|
78
82
|
end
|
79
83
|
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
+
should 'puts error' do
|
85
|
+
any_instance_of(TCPSocket) do |sock|
|
86
|
+
mock(sock).read{ raise 'ERROR' }
|
87
|
+
end
|
88
|
+
|
89
|
+
errors = StringIO.new
|
90
|
+
begin
|
91
|
+
request['rack.errors' => errors].value
|
92
|
+
ensure
|
93
|
+
serv.accept.close
|
84
94
|
end
|
95
|
+
errors.string.should.start_with? '[RequestReplay] Error:'
|
96
|
+
end
|
85
97
|
|
98
|
+
describe RequestReplay::Middleware do
|
86
99
|
should 'PUT' do
|
100
|
+
app = Rack::Builder.app do
|
101
|
+
use RequestReplay::Middleware, hopt
|
102
|
+
run lambda{ |env| [200, {}, []] }
|
103
|
+
end
|
104
|
+
|
87
105
|
app.call(env.merge('REQUEST_METHOD' => 'PUT'))
|
88
106
|
sock = serv.accept
|
89
107
|
sock.read.should.eq <<-HTTP
|
90
108
|
PUT /?q=1 HTTP/1.1\r
|
91
109
|
Host: localhost\r
|
92
110
|
Pork: BEEF\r
|
111
|
+
\r
|
112
|
+
HTTP
|
113
|
+
sock.close
|
114
|
+
end
|
115
|
+
|
116
|
+
should 'retain original env' do
|
117
|
+
app = Rack::Builder.app do
|
118
|
+
use RequestReplay::Middleware, hopt
|
119
|
+
run lambda{ |env|
|
120
|
+
env['PATH_INFO'] = '/bad'
|
121
|
+
[200, {}, []]
|
122
|
+
}
|
123
|
+
end
|
124
|
+
|
125
|
+
app.call(env)
|
126
|
+
sock = serv.accept
|
127
|
+
sock.read.should.eq <<-HTTP
|
128
|
+
GET /?q=1 HTTP/1.1\r
|
129
|
+
Host: localhost\r
|
130
|
+
Pork: BEEF\r
|
93
131
|
\r
|
94
132
|
HTTP
|
95
133
|
sock.close
|