1
0
Fork 0
mirror of https://github.com/puma/puma.git synced 2022-11-09 13:48:40 -05:00

Change to compensate for people who use CGIWrapper with bad status. Uses the given host from the client rather than the actual host (makes redirect work). Bumped version number.

git-svn-id: svn+ssh://rubyforge.org/var/svn/mongrel/trunk@48 19e92222-5c0b-0410-8929-a290d50e31e9
This commit is contained in:
zedshaw 2006-02-20 06:40:48 +00:00
parent 1c7d2316b2
commit 766875e7af
3 changed files with 22 additions and 18 deletions

7
README
View file

@ -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:

View file

@ -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"

View file

@ -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