Skip to content

Commit

Permalink
Fix more 1.9.2 bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
benburkert committed Nov 21, 2010
1 parent b575833 commit 33dde29
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 12 deletions.
9 changes: 6 additions & 3 deletions Gemfile
Expand Up @@ -11,8 +11,11 @@ group :test do
gem 'rake'
gem 'sinatra', :require => 'sinatra/base'
gem 'rspec', '>=2.0.0'
gem 'ruby-debug'
gem 'mongrel'
gem 'cgi_multipart_eof_fix'
gem 'realweb'

unless RUBY_VERSION == '1.9.2'
gem 'ruby-debug'
gem 'mongrel'
gem 'cgi_multipart_eof_fix'
end
end
13 changes: 8 additions & 5 deletions lib/rack/client/adapter/base.rb
Expand Up @@ -43,13 +43,16 @@ def build_env(request_method, url, headers = {}, body = nil)
env.update 'SCRIPT_NAME' => ''
env.update 'QUERY_STRING' => uri.query.to_s

input = case body
when nil then StringIO.new
when String then StringIO.new(body)
end
input, errors = StringIO.new(body.to_s), StringIO.new

if input.respond_to?(:set_encoding)
input.set_encoding('ASCII-8BIT')
errors.set_encoding('ASCII-8BIT')
end


env.update 'rack.input' => input
env.update 'rack.errors' => StringIO.new
env.update 'rack.errors' => errors
env.update 'rack.url_scheme' => uri.scheme || 'http'
env.update 'rack.version' => Rack::VERSION
env.update 'rack.multithread' => true
Expand Down
2 changes: 1 addition & 1 deletion lib/rack/client/handler/net_http.rb
Expand Up @@ -72,7 +72,7 @@ def parse_stream(net_response)
def parse_headers(net_response)
headers = Headers.new

net_response.each do |(k,v)|
net_response.each do |k,v|
headers.update(k => v)
end

Expand Down
8 changes: 6 additions & 2 deletions spec/shared/handler_api.rb
Expand Up @@ -7,8 +7,12 @@
end

it 'has the correct headers' do
request { get('/get/hello_world') }
response { headers.keys.should == %w[Content-Type Date Content-Length Connection] }
request { get('/get/hello_world') }
response do
%w[Content-Type Date Content-Length Connection].each do |header|
headers.keys.include?(header).should == true
end
end
end

it 'has the correct body' do
Expand Down
2 changes: 1 addition & 1 deletion spec/spec_apps/hello_world.ru
@@ -1 +1 @@
run lambda { [200, {}, 'Hello World!'] }
run lambda {|_| [200, {}, 'Hello World!'] }

0 comments on commit 33dde29

Please sign in to comment.