Skip to content
This repository has been archived by the owner on Dec 25, 2020. It is now read-only.

Commit

Permalink
* lib/wee/pageless/session.rb, lib/wee/pageless/application.rb: Remove
Browse files Browse the repository at this point in the history
	  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
Show file tree
Hide file tree
Showing 5 changed files with 93 additions and 7 deletions.
9 changes: 9 additions & 0 deletions ChangeLog
@@ -1,3 +1,12 @@
Mon Apr 4 13:03:08 CET 2005 Michael Neumann <mneumann@ntecs.de>
* 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

Sun Apr 3 13:24:04 CET 2005 Michael Neumann <mneumann@ntecs.de>

* lib/wee/adaptors/webrick.rb: doc fix
Expand Down
76 changes: 76 additions & 0 deletions lib/wee/adaptors/fastcgi.rb
@@ -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
4 changes: 2 additions & 2 deletions lib/wee/adaptors/webrick.rb
@@ -1,5 +1,7 @@
require 'webrick'

Socket.do_not_reverse_lookup = true

# Example of usage:
#
# require 'wee/adaptors/webrick'
Expand All @@ -20,8 +22,6 @@
# start(:Port => 2000)
#

Socket.do_not_reverse_lookup = true

class Wee::WEBrickAdaptor < WEBrick::HTTPServlet::AbstractServlet

# Convenience method
Expand Down
7 changes: 4 additions & 3 deletions lib/wee/pageless/application.rb
@@ -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
4 changes: 2 additions & 2 deletions lib/wee/pageless/session.rb
@@ -1,4 +1,5 @@
require 'thread'
require 'cgi'

# A session class, which does not have a page-store and as such cannot
# backtrack.
Expand Down Expand Up @@ -77,8 +78,7 @@ def handle_new_page_view(context)
end

def set_response(context, response)
# TODO: depends on WEBrick!
response.cookies << WEBrick::Cookie.new('SID', self.id)
response.cookies << CGI::Cookie.new('SID', self.id)
response.header.delete('Expire')
response.header['Pragma'] = 'No-Cache'
super
Expand Down

0 comments on commit 6f03145

Please sign in to comment.