Permalink
Browse files

Require Rack.

  • Loading branch information...
1 parent 7eea471 commit ea72c975ad135efa113477b6920b3aa5dbab5da1 @mdub committed Dec 6, 2011
Showing with 8 additions and 7 deletions.
  1. +8 −7 lib/sham_rack/net_http.rb
View
@@ -1,10 +1,11 @@
require "net/http"
+require "rack"
require "sham_rack/registry"
-class << Net::HTTP
+class << Net::HTTP
alias :new_without_sham_rack :new
-
+
def new(address, port = nil, *proxy_args)
port ||= Net::HTTP.default_port
rack_app = ShamRack.application_for(address, port)
@@ -20,14 +21,14 @@ def new(address, port = nil, *proxy_args)
module ShamRack
module NetHttp
-
+
module Extensions
attr_accessor :rack_app
def start
if block_given?
- yield self
+ yield self
else
self
end
@@ -47,14 +48,14 @@ def rack_env(request, body)
rack_env.merge!(header_env(request))
rack_env.merge!(server_env)
end
-
+
def server_env
{
- "SERVER_NAME" => @address,
+ "SERVER_NAME" => @address,
"SERVER_PORT" => @port.to_s
}
end
-
+
def header_env(request)
env = {}
request.each_header do |header, content|

0 comments on commit ea72c97

Please sign in to comment.