rack-singleshot 0.2.0 → 0.2.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -31,10 +31,11 @@ module Rack
31
31
  exit
32
32
  end
33
33
 
34
+
34
35
  def read_request
35
- verb, path, version, headers, body = parse_request(@stdin)
36
+ verb, path, query_string, version, headers, body = parse_request(@stdin)
36
37
 
37
- env_for(verb, path, version, headers, body)
38
+ env_for(verb, path, query_string, version, headers, body)
38
39
  end
39
40
 
40
41
  def parse_request(socket, chunksize = 1024)
@@ -61,6 +62,7 @@ module Rack
61
62
  def request_parts_from(parser)
62
63
  [parser.http_method,
63
64
  parser.request_path,
65
+ parser.query_string,
64
66
  parser.http_version.join('.'),
65
67
  parse_headers(parser.headers)]
66
68
  end
@@ -93,7 +95,7 @@ module Rack
93
95
  end
94
96
  end
95
97
 
96
- def env_for(verb, path, version, headers, body)
98
+ def env_for(verb, path, query_string, version, headers, body)
97
99
  env = headers
98
100
 
99
101
  scheme = ['yes', 'on', '1'].include?(env['HTTPS']) ? 'https' : 'http'
@@ -104,7 +106,7 @@ module Rack
104
106
  env.update 'REQUEST_METHOD' => verb
105
107
  env.update 'SCRIPT_NAME' => ''
106
108
  env.update 'PATH_INFO' => uri.path
107
- env.update 'QUERY_STRING' => uri.query || ''
109
+ env.update 'QUERY_STRING' => query_string
108
110
  env.update 'SERVER_NAME' => uri.host
109
111
  env.update 'SERVER_PORT' => uri.port.to_s
110
112
 
@@ -33,6 +33,10 @@ RESPONSE
33
33
  get '/' do
34
34
  'response body'
35
35
  end
36
+
37
+ get '/params' do
38
+ params.inspect
39
+ end
36
40
  end
37
41
 
38
42
  before(:each) do
@@ -56,5 +60,17 @@ REQUEST
56
60
 
57
61
  @out.read.should =~ /response body\Z/
58
62
  end
63
+
64
+ it 'supports query string parameters' do
65
+ @in << <<-REQUEST.gsub("\n", "\r\n")
66
+ GET /params?foo=bar&baz=bang HTTP/1.1
67
+ Server-Name: localhost
68
+
69
+ REQUEST
70
+
71
+ @server.run
72
+
73
+ @out.read.should =~ /{"foo"=>"bar", "baz"=>"bang"}/
74
+ end
59
75
  end
60
76
  end
metadata CHANGED
@@ -1,144 +1,136 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: rack-singleshot
3
- version: !ruby/object:Gem::Version
4
- hash: 23
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.1
5
5
  prerelease:
6
- segments:
7
- - 0
8
- - 2
9
- - 0
10
- version: 0.2.0
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Ben Burkert
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2013-02-19 00:00:00 -08:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
12
+ date: 2013-04-06 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
22
15
  name: rack
23
- prerelease: false
24
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
33
22
  type: :runtime
34
- version_requirements: *id001
35
- - !ruby/object:Gem::Dependency
36
- name: http_parser.rb
37
23
  prerelease: false
38
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: !ruby/object:Gem::Requirement
39
25
  none: false
40
- requirements:
41
- - - ">="
42
- - !ruby/object:Gem::Version
43
- hash: 3
44
- segments:
45
- - 0
46
- version: "0"
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ - !ruby/object:Gem::Dependency
31
+ name: http_parser.rb
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
47
38
  type: :runtime
48
- version_requirements: *id002
49
- - !ruby/object:Gem::Dependency
50
- name: rspec
51
39
  prerelease: false
52
- requirement: &id003 !ruby/object:Gem::Requirement
40
+ version_requirements: !ruby/object:Gem::Requirement
53
41
  none: false
54
- requirements:
55
- - - ">="
56
- - !ruby/object:Gem::Version
57
- hash: 3
58
- segments:
59
- - 0
60
- version: "0"
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: rspec
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
61
54
  type: :development
62
- version_requirements: *id003
63
- - !ruby/object:Gem::Dependency
64
- name: rake
65
55
  prerelease: false
66
- requirement: &id004 !ruby/object:Gem::Requirement
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: rake
64
+ requirement: !ruby/object:Gem::Requirement
67
65
  none: false
68
- requirements:
69
- - - ">="
70
- - !ruby/object:Gem::Version
71
- hash: 3
72
- segments:
73
- - 0
74
- version: "0"
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
75
70
  type: :development
76
- version_requirements: *id004
77
- - !ruby/object:Gem::Dependency
78
- name: sinatra
79
71
  prerelease: false
80
- requirement: &id005 !ruby/object:Gem::Requirement
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: sinatra
80
+ requirement: !ruby/object:Gem::Requirement
81
81
  none: false
82
- requirements:
83
- - - ">="
84
- - !ruby/object:Gem::Version
85
- hash: 3
86
- segments:
87
- - 0
88
- version: "0"
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
89
86
  type: :development
90
- version_requirements: *id005
91
- description: |
92
- Handles a single request to/from STDIN/STDOUT. Exits when the response
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ description: ! 'Handles a single request to/from STDIN/STDOUT. Exits when the response
95
+
93
96
  has finished. Sutable for running via inetd.
94
97
 
95
- email:
98
+ '
99
+ email:
96
100
  - ben@benburkert.com
97
- executables:
101
+ executables:
98
102
  - singleshot
99
103
  extensions: []
100
-
101
104
  extra_rdoc_files: []
102
-
103
- files:
105
+ files:
104
106
  - ./lib/rack/singleshot.rb
105
107
  - ./spec/singleshot_spec.rb
106
108
  - ./spec/spec_helper.rb
107
109
  - bin/singleshot
108
- has_rdoc: true
109
110
  homepage: http://github.com/benburkert/rack-singleshot
110
111
  licenses: []
111
-
112
112
  post_install_message:
113
113
  rdoc_options: []
114
-
115
- require_paths:
114
+ require_paths:
116
115
  - lib
117
- required_ruby_version: !ruby/object:Gem::Requirement
116
+ required_ruby_version: !ruby/object:Gem::Requirement
118
117
  none: false
119
- requirements:
120
- - - ">="
121
- - !ruby/object:Gem::Version
122
- hash: 3
123
- segments:
124
- - 0
125
- version: "0"
126
- required_rubygems_version: !ruby/object:Gem::Requirement
118
+ requirements:
119
+ - - ! '>='
120
+ - !ruby/object:Gem::Version
121
+ version: '0'
122
+ required_rubygems_version: !ruby/object:Gem::Requirement
127
123
  none: false
128
- requirements:
129
- - - ">="
130
- - !ruby/object:Gem::Version
131
- hash: 3
132
- segments:
133
- - 0
134
- version: "0"
124
+ requirements:
125
+ - - ! '>='
126
+ - !ruby/object:Gem::Version
127
+ version: '0'
135
128
  requirements: []
136
-
137
129
  rubyforge_project:
138
- rubygems_version: 1.6.2
130
+ rubygems_version: 1.8.23
139
131
  signing_key:
140
132
  specification_version: 3
141
133
  summary: A single-shot rack handler.
142
- test_files:
134
+ test_files:
143
135
  - ./spec/singleshot_spec.rb
144
136
  - ./spec/spec_helper.rb