request-replay 0.6.2 → 0.6.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +6 -0
- data/README.md +1 -0
- data/Rakefile +1 -1
- data/lib/request-replay.rb +18 -9
- data/request-replay.gemspec +3 -3
- data/test/test_basic.rb +9 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 16053b14d0f25a8a0a55a8416692f3a40438e06c
|
4
|
+
data.tar.gz: 8fb2ba84a1f33fbed931f0542cc692dfa96e932c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1608f535929798711724cc4c8a5b0ef2aea2294085226d472f9bf27295a06de5385817e0a0cd349bee0fb1bd4a49b0ed98fb2d963d77bb639c35e7fbf47ca4e5
|
7
|
+
data.tar.gz: 9a5826abe20eccc9b24827e2df6065fad4b573cec50c4a08186626fb2a55faf4bc63e91b9140a090413606831abb7b7ec2b8b62a2a2a72560469ffb5e8b92238
|
data/CHANGES.md
CHANGED
@@ -1,5 +1,11 @@
|
|
1
1
|
# CHANGES
|
2
2
|
|
3
|
+
## request-replay 0.6.3 -- 2013-10-07
|
4
|
+
|
5
|
+
* Fixed an issue where Rack::Request does not try to rewind rack.input for
|
6
|
+
form POST. We rewind for them. Thanks @yyjim
|
7
|
+
* Extracted more constants. Might boost performance a bit.
|
8
|
+
|
3
9
|
## request-replay 0.6.2 -- 2013-10-01
|
4
10
|
|
5
11
|
* Added :rewrite_env option for rewriting env for specific use.
|
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/request-replay.rb
CHANGED
@@ -5,9 +5,17 @@ require 'stringio'
|
|
5
5
|
class RequestReplay
|
6
6
|
autoload :Middleware, 'request-replay/middleware'
|
7
7
|
|
8
|
-
NEWLINE
|
9
|
-
HTTP_VERSION
|
10
|
-
RACK_INPUT
|
8
|
+
NEWLINE = "\r\n" .freeze
|
9
|
+
HTTP_VERSION = 'HTTP/1.1' .freeze
|
10
|
+
RACK_INPUT = 'rack.input' .freeze
|
11
|
+
RACK_ERRORS = 'rack.errors' .freeze
|
12
|
+
REQUEST_METHOD = 'REQUEST_METHOD'.freeze
|
13
|
+
PATH_INFO = 'PATH_INFO' .freeze
|
14
|
+
QUERY_STRING = 'QUERY_STRING' .freeze
|
15
|
+
CONTENT_TYPE = 'CONTENT_TYPE' .freeze
|
16
|
+
CONTENT_LENGTH = 'CONTENT_LENGTH'.freeze
|
17
|
+
HEADER_CTYPE = 'Content-Type' .freeze
|
18
|
+
HEADER_CLENGTH = 'Content-Length'.freeze
|
11
19
|
|
12
20
|
def initialize env, host, options={}
|
13
21
|
@env, (@host, @port), @options = env, host.split(':', 2), options
|
@@ -16,6 +24,7 @@ class RequestReplay
|
|
16
24
|
@buf = StringIO.new
|
17
25
|
IO.copy_stream(env[RACK_INPUT], @buf)
|
18
26
|
@buf.rewind
|
27
|
+
env[RACK_INPUT].rewind
|
19
28
|
end
|
20
29
|
end
|
21
30
|
|
@@ -35,8 +44,8 @@ class RequestReplay
|
|
35
44
|
IO.select([sock], [], [], read_wait) if read_wait
|
36
45
|
yield(sock) if block_given?
|
37
46
|
rescue => e
|
38
|
-
@env[
|
39
|
-
@env[
|
47
|
+
@env[RACK_ERRORS].puts("[#{self.class.name}] Error: #{e.inspect}") if
|
48
|
+
@env[RACK_ERRORS]
|
40
49
|
ensure
|
41
50
|
sock.close
|
42
51
|
end
|
@@ -55,7 +64,7 @@ class RequestReplay
|
|
55
64
|
end
|
56
65
|
|
57
66
|
def request
|
58
|
-
"#{@env[
|
67
|
+
"#{@env[REQUEST_METHOD] || 'GET'} #{request_path} #{HTTP_VERSION}"
|
59
68
|
end
|
60
69
|
|
61
70
|
def headers
|
@@ -63,7 +72,7 @@ class RequestReplay
|
|
63
72
|
end
|
64
73
|
|
65
74
|
def request_path
|
66
|
-
"/#{@env[
|
75
|
+
"/#{@env[PATH_INFO]}?#{@env[QUERY_STRING]}".
|
67
76
|
sub(%r{^//}, '/').sub(/\?$/, '')
|
68
77
|
end
|
69
78
|
|
@@ -72,8 +81,8 @@ class RequestReplay
|
|
72
81
|
@env.inject({}){ |r, (k, v)|
|
73
82
|
r[capitalize_headers(k[5..-1])] = v if k.start_with?('HTTP_')
|
74
83
|
r
|
75
|
-
}.merge(
|
76
|
-
|
84
|
+
}.merge(HEADER_CTYPE => @env[CONTENT_TYPE ],
|
85
|
+
HEADER_CLENGTH => @env[CONTENT_LENGTH]).
|
77
86
|
merge(add_headers).select{ |_, v| v }
|
78
87
|
end
|
79
88
|
|
data/request-replay.gemspec
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: request-replay 0.6.
|
2
|
+
# stub: request-replay 0.6.3 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.3"
|
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)"]
|
10
|
-
s.date = "2013-10-
|
10
|
+
s.date = "2013-10-07"
|
11
11
|
s.description = "Replay the request via Rack env"
|
12
12
|
s.email = ["godfat (XD) godfat.org"]
|
13
13
|
s.files = [
|
data/test/test_basic.rb
CHANGED
@@ -95,6 +95,15 @@ Pork: BEEF\r
|
|
95
95
|
errors.string.should.start_with? '[RequestReplay] Error:'
|
96
96
|
end
|
97
97
|
|
98
|
+
should 'not affect Rack::Request' do
|
99
|
+
input = StringIO.new('a=0&b=1')
|
100
|
+
e = {'rack.input' => input, 'REQUEST_METHOD' => 'POST'}
|
101
|
+
t = request[e]
|
102
|
+
serv.accept.close
|
103
|
+
t.join
|
104
|
+
Rack::Request.new(e).POST.should.eq('a' => '0', 'b' => '1')
|
105
|
+
end
|
106
|
+
|
98
107
|
describe RequestReplay::Middleware do
|
99
108
|
should 'PUT' do
|
100
109
|
app = Rack::Builder.app do
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: request-replay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Lin Jen-Shin (godfat)
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-10-
|
11
|
+
date: 2013-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bacon
|