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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 82468210714a1dd60ceadcd91e95752c0e85ce85
4
- data.tar.gz: 906d7755d38d5a0748707068bc1f31d7c34beadb
3
+ metadata.gz: 16053b14d0f25a8a0a55a8416692f3a40438e06c
4
+ data.tar.gz: 8fb2ba84a1f33fbed931f0542cc692dfa96e932c
5
5
  SHA512:
6
- metadata.gz: cf7b7b776083558e322f502a0de20cccf7dc51e4cd14f0be2a8eddfd8316fe3748add3a749ac336f50567e6c33755da185b8a2bd52618d2ef706a521f9f691e3
7
- data.tar.gz: f61d88e1673fb50cc512e87b8702dc2ddeb51bf6e7976a90ecf3982033c1f243d477299eb5fe1b4db6dc199da29f773091af90dcaf39262d367cf1eabd5cc17b
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
@@ -45,6 +45,7 @@ run lambda{ |env| [200, {}, [env.inspect]] }
45
45
 
46
46
  ## CONTRIBUTORS:
47
47
 
48
+ * Jim Wang (@yyjim)
48
49
  * Lin Jen-Shin (@godfat)
49
50
 
50
51
  ## LICENSE:
data/Rakefile CHANGED
@@ -8,6 +8,6 @@ end
8
8
 
9
9
  Gemgem.init(dir) do |s|
10
10
  s.name = 'request-replay'
11
- s.version = '0.6.2'
11
+ s.version = '0.6.3'
12
12
  %w[bacon muack rack].each{ |g| s.add_development_dependency(g) }
13
13
  end
@@ -5,9 +5,17 @@ require 'stringio'
5
5
  class RequestReplay
6
6
  autoload :Middleware, 'request-replay/middleware'
7
7
 
8
- NEWLINE = "\r\n"
9
- HTTP_VERSION = 'HTTP/1.1'
10
- RACK_INPUT = '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['rack.errors'].puts("[#{self.class.name}] Error: #{e.inspect}") if
39
- @env['rack.errors']
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['REQUEST_METHOD'] || 'GET'} #{request_path} #{HTTP_VERSION}"
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['PATH_INFO']}?#{@env['QUERY_STRING']}".
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('Content-Type' => @env['CONTENT_TYPE' ],
76
- 'Content-Length' => @env['CONTENT_LENGTH']).
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
 
@@ -1,13 +1,13 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: request-replay 0.6.2 ruby lib
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.2"
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-01"
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.2
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-01 00:00:00.000000000 Z
11
+ date: 2013-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bacon