about summary refs log tree commit homepage
diff options
context:
space:
mode:
authorzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-02-20 06:40:48 +0000
committerzedshaw <zedshaw@19e92222-5c0b-0410-8929-a290d50e31e9>2006-02-20 06:40:48 +0000
commit766875e7af15b96fad25c5556aa22940b47e7bf5 (patch)
tree0d9f965204d7635705697f916d751a93d8ea47a7
parent1c7d2316b2cef5bff1254f215e57a2395895bd41 (diff)
downloadunicorn-766875e7af15b96fad25c5556aa22940b47e7bf5.tar.gz
git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@48 19e92222-5c0b-0410-8929-a290d50e31e9
-rw-r--r--README7
-rw-r--r--Rakefile2
-rw-r--r--lib/mongrel.rb31
3 files changed, 22 insertions, 18 deletions
diff --git a/README b/README
index 1de4c7d..4b34c60 100644
--- a/README
+++ b/README
@@ -11,9 +11,10 @@ scream without too many portability issues.
 
 == Status
 
-The 0.3.2 release supports Ruby On Rails much better than previously, and also
-sports the beginning of a command and plugin infrastructure.  This last part
-isn't documented yet.
+The 0.3.6 release supports Ruby On Rails much better than previously, and also
+sports the beginning of a command and plugin infrastructure.  There is now a more
+complete CGIWrapper that handles most of the CGI usage, but still doesn't do the
+MIME decoding or file upload/send (it leaves that to CGI).
 
 After you've installed (either with gem install mongrel or via source) you should
 have the mongrel_rails command available in your PATH.  Then you just do the following:
diff --git a/Rakefile b/Rakefile
index be1533f..9afee77 100644
--- a/Rakefile
+++ b/Rakefile
@@ -30,7 +30,7 @@ end
 
 setup_extension("http11", "http11")
 
-version="0.3.5"
+version="0.3.6"
 summary = "A small fast HTTP library and server that runs Rails, Camping, and Nitro apps."
 test_file = "test/test_ws.rb"
 author="Zed A. Shaw"
diff --git a/lib/mongrel.rb b/lib/mongrel.rb
index 05d7b71..39d3c96 100644
--- a/lib/mongrel.rb
+++ b/lib/mongrel.rb
@@ -103,6 +103,9 @@ module Mongrel
     # The port of our server as given by the HttpServer.new(host,port) call.
     SERVER_PORT='SERVER_PORT'
 
+    # SERVER_NAME and SERVER_PORT come from this.
+    HTTP_HOST='HTTP_HOST'
+
     # Official server protocol key in the HttpRequest parameters.
     SERVER_PROTOCOL='SERVER_PROTOCOL'
     # Mongrel claims to support HTTP/1.1.
@@ -112,7 +115,7 @@ module Mongrel
     SERVER_SOFTWARE='SERVER_SOFTWARE'
     
     # Current Mongrel version (used for SERVER_SOFTWARE and other response headers).
-    MONGREL_VERSION='Mongrel 0.3.5'
+    MONGREL_VERSION='Mongrel 0.3.6'
 
     # The standard empty 404 response for bad requests.  Use Error4040Handler for custom stuff.
     ERROR_404_RESPONSE="HTTP/1.1 404 Not Found\r\nConnection: close\r\nServer: #{MONGREL_VERSION}\r\n\r\nNOT FOUND"
@@ -149,7 +152,7 @@ module Mongrel
       
       # fix up the CGI requirements
       params[Const::CONTENT_LENGTH] = params[Const::HTTP_CONTENT_LENGTH] || 0
-      params[Const::CONTENT_TYPE] ||= params[Const::HTTP_CONTENT_TYPE]
+      params[Const::CONTENT_TYPE] = params[Const::HTTP_CONTENT_TYPE] if params[Const::HTTP_CONTENT_TYPE]
 
       # now, if the initial_body isn't long enough for the content length we have to fill it
       # TODO: adapt for big ass stuff by writing to a temp file
@@ -363,8 +366,9 @@ module Mongrel
               params[Const::SCRIPT_NAME] = script_name
               params[Const::GATEWAY_INTERFACE]=Const::GATEWAY_INTERFACE_VALUE
               params[Const::REMOTE_ADDR]=client.peeraddr[3]
-              params[Const::SERVER_NAME]=@host
-              params[Const::SERVER_PORT]=@port
+              host,port = params[Const::HTTP_HOST].split(":")
+              params[Const::SERVER_NAME]=host
+              params[Const::SERVER_PORT]=port if port
               params[Const::SERVER_PROTOCOL]=Const::SERVER_PROTOCOL_VALUE
               params[Const::SERVER_SOFTWARE]=Const::MONGREL_VERSION
 
@@ -374,8 +378,8 @@ module Mongrel
             else
               client.write(Const::ERROR_404_RESPONSE)
             end
-
-            break
+            
+            break #done
           else
             # gotta stream and read again until we can get the parser to be character safe
             # TODO: make this more efficient since this means we're parsing a lot repeatedly
@@ -702,16 +706,15 @@ module Mongrel
     # message in the status we have to do a bit of parsing.
     def status
       if not @status
-        @status = @head["Status"] || @head["status"]
-        
-        if @status
-          @status[0 ... @status.index(' ')] || "200"
-        else
-          @status = "200"
-        end
+        stat = @head["Status"]
+        stat = stat.split(' ')[0] if stat
+
+        @status = stat || "200"
       end
+
+      @status
     end
-    
+
     # Used to wrap the normal args variable used inside CGI.
     def args
       @args