This repository has been archived by the owner on Dec 25, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* lib/wee/pageless/session.rb, lib/wee/pageless/application.rb: Remove
dependency of WEBrick::Cookie, use CGI::Cookie instead. * lib/wee/adaptors/fastcgi.rb: Added preliminary FastCGI adaptor (does not work yet with Pageless applications). * lib/wee/adaptors/webrick.rb: reordered line
- Loading branch information
mneumann
committed
Apr 4, 2005
1 parent
0d26d1a
commit 6f03145
Showing
5 changed files
with
93 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
require 'fcgi' | ||
|
||
Socket.do_not_reverse_lookup = true | ||
|
||
# A FastCGI adaptor for Wee. | ||
# | ||
# Depends on ruby-fcgi (http://raa.ruby-lang.org/list.rhtml?name=fcgi) or via | ||
# Rubygems (gem install fcgi). | ||
# | ||
# Example of usage: | ||
# | ||
# require 'wee/adaptors/fastcgi' | ||
# Wee::FastCGIAdaptor.start('/app', application) | ||
# | ||
# == Setup FastCGI with Lighttpd | ||
# | ||
# # lighttpd.conf | ||
# server.modules = ( | ||
# "mod_fastcgi" | ||
# ) | ||
# | ||
# fastcgi.server = ( | ||
# "/app" => | ||
# ( "fcgi" => | ||
# ( | ||
# "host" => 127.0.0.1", | ||
# "port" => 3000, | ||
# "check-local" => "disable" | ||
# ) | ||
# ) | ||
# ) | ||
# | ||
# Now start the Wee application (the file must be executable): | ||
# | ||
# spawn-fcgi -f ./run.rb -p 3000 | ||
# | ||
# Finally start the lighttpd server: | ||
# | ||
# lighttpd -D -f lighttpd.conf | ||
# | ||
|
||
class Wee::FastCGIAdaptor | ||
def self.start(mount_path, application, request_class=Wee::Request) | ||
FCGI.each_cgi {|cgi| | ||
query = Hash.new | ||
|
||
# TODO: WEBrick like: return a string which has a to_list method! | ||
cgi.params.each {|k, v| | ||
raise if v.empty? | ||
obj = v.first | ||
obj.instance_variable_set("@__as_list", v) | ||
def obj.as_list() @__as_list end | ||
|
||
query[k] = obj | ||
} | ||
|
||
# TODO | ||
header = [] | ||
|
||
context = Wee::Context.new(request_class.new(mount_path, | ||
cgi.script_name, header, query, cgi.cookies)) | ||
|
||
application.handle_request(context) | ||
|
||
header = {} | ||
header['status'] = context.response.status.to_s | ||
|
||
context.response.header.each { |k,v| header[k] = v } | ||
if context.response.cookies? | ||
header['cookie'] = context.response.cookies | ||
end | ||
|
||
cgi.out(header) { context.response.content } | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,13 @@ | ||
require 'cgi' | ||
|
||
class Wee::PagelessApplication < Wee::Application | ||
def request_handler_expired(context) | ||
context.response = Wee::RedirectResponse.new(context.request.build_url( | ||
:request_handler_id => nil, | ||
:page_id => nil)) | ||
|
||
# TODO: depends on WEBrick | ||
cookie = WEBrick::Cookie.new('SID', '') | ||
cookie.max_age = 0 | ||
cookie = CGI::Cookie.new('SID', '') | ||
cookie.expires = Time.at(0) | ||
context.response.cookies << cookie | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters