Class: Web::CGD
- Includes:
- Parser
- Defined in:
- lib/web/cgi.rb,
lib/web/sapi/fastcgi.rb,
lib/web/sapi/webrick.rb,
lib/web/sapi/mod_ruby.rb
Overview
Purpose
this is the implementation of the cgi interface. As dbi to dbd, cgi to cgd
Defined Under Namespace
Classes: Fastcgi, ModRuby, Webrick
Constant Summary
Constants included from Parser
Instance Attribute Summary collapse
-
#cookies ⇒ Object
Returns the value of attribute cookies.
-
#env ⇒ Object
Returns the value of attribute env.
-
#input ⇒ Object
Returns the value of attribute input.
-
#multiple_params ⇒ Object
Returns the value of attribute multiple_params.
-
#options ⇒ Object
Returns the value of attribute options.
-
#output ⇒ Object
Returns the value of attribute output.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(options = {}) ⇒ CGD
constructor
A new instance of CGD.
-
#nph? ⇒ Boolean
should this be server specific?.
- #send_header(header) ⇒ Object
-
#send_nph_header(header) ⇒ Object
:nodoc:.
Methods included from Parser
#downcase_env, #mod_ruby_query_string, mod_ruby_query_string, #multipart?, #normalize, normalize, parse_cookie, #parse_cookie, #parse_multipart, #parse_params, #parse_query_string, parse_query_string, #parse_query_string_typed, #parse_request, #query_string, #read_multipart
Constructor Details
#initialize(options = {}) ⇒ CGD
Returns a new instance of CGD.
528 529 530 531 532 533 534 535 536 537 538 539 |
# File 'lib/web/cgi.rb', line 528 def initialize(={}) @options = @input = [:in] || $stdin @output = [:out] || $stdout @env = downcase_env( [:env] || ENV ) @env['document_root'] = [:document_root] || Web.get_docroot || @env['document_root'] @env['script_name' ] = [:script_name] || @env['script_name'] parse_request end |
Instance Attribute Details
#cookies ⇒ Object
Returns the value of attribute cookies.
511 512 513 |
# File 'lib/web/cgi.rb', line 511 def @cookies end |
#env ⇒ Object
Returns the value of attribute env.
511 512 513 |
# File 'lib/web/cgi.rb', line 511 def env @env end |
#input ⇒ Object
Returns the value of attribute input.
511 512 513 |
# File 'lib/web/cgi.rb', line 511 def input @input end |
#multiple_params ⇒ Object
Returns the value of attribute multiple_params.
511 512 513 |
# File 'lib/web/cgi.rb', line 511 def multiple_params @multiple_params end |
#options ⇒ Object
Returns the value of attribute options.
511 512 513 |
# File 'lib/web/cgi.rb', line 511 def @options end |
#output ⇒ Object
Returns the value of attribute output.
511 512 513 |
# File 'lib/web/cgi.rb', line 511 def output @output end |
Class Method Details
.create(options = {}) ⇒ Object
515 516 517 518 519 520 521 522 523 524 525 526 |
# File 'lib/web/cgi.rb', line 515 def CGD::create(={}) case CGI::server_sniff when :fcgi require 'web/sapi/fastcgi' Web::CGD::Fastcgi.new( ) when :mod_ruby require 'web/sapi/mod_ruby' Web::CGD::ModRuby.new( ) else CGD.new() end end |
Instance Method Details
#close ⇒ Object
541 542 543 |
# File 'lib/web/cgi.rb', line 541 def close end |
#nph? ⇒ Boolean
should this be server specific?
546 547 548 |
# File 'lib/web/cgi.rb', line 546 def nph? @options[:nph] || /IIS/.match(env["server_software"]) end |
#send_header(header) ⇒ Object
550 551 552 553 554 555 556 557 558 559 560 |
# File 'lib/web/cgi.rb', line 550 def send_header( header ) send_nph_header( header ) if (nph?) header.sort.each { |name, value| value.each { |v| output << "#{ name }: #{ v }\r\n" } } output << "\r\n" end |
#send_nph_header(header) ⇒ Object
:nodoc:
562 563 564 565 566 567 568 569 570 571 572 |
# File 'lib/web/cgi.rb', line 562 def send_nph_header( header ) #:nodoc: output << "#{ env['server_protocol'] || 'HTTP/1.0' }: " output << "#{ header['Status'] }\r\n" output << "Date: #{ Web::rfc1123_date(Time.now) }\r\n" header.delete("Status") unless header.has_key? "Server" header["Server"] = [ env["server_software"] || "" ] end end |