aboutsummaryrefslogtreecommitdiffstats
path: root/lib/webrick/httpresponse.rb
diff options
context:
space:
mode:
authordrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-26 01:12:54 +0000
committerdrbrain <drbrain@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-01-26 01:12:54 +0000
commit28afe277a8e543da0e6353bdacbcad0b69739e06 (patch)
tree1591c370f08ab4db6c888eea99f2936262e137ca /lib/webrick/httpresponse.rb
parent89232d1dd97251b6fc626d4338c49e9e8c4f6535 (diff)
downloadruby-28afe277a8e543da0e6353bdacbcad0b69739e06.tar.gz
* lib/webrick/accesslog.rb: Improved WEBrick documentation.
* lib/webrick/cgi.rb: ditto. * lib/webrick/config.rb: ditto. * lib/webrick/cookie.rb: ditto. * lib/webrick/httpauth/authenticator.rb: ditto. * lib/webrick/httpauth/basicauth.rb: ditto. * lib/webrick/httpauth/digestauth.rb: ditto. * lib/webrick/httpproxy.rb: ditto. * lib/webrick/httprequest.rb: ditto. * lib/webrick/httpresponse.rb: ditto. * lib/webrick/https.rb: ditto. * lib/webrick/httpserver.rb: ditto. * lib/webrick/httpservlet/cgihandler.rb: ditto. * lib/webrick/httpservlet/filehandler.rb: ditto. * lib/webrick/httpservlet/prochandler.rb: ditto. * lib/webrick/httputils.rb: ditto. * lib/webrick/httpversion.rb: ditto. * lib/webrick/log.rb: ditto. * lib/webrick/server.rb: ditto. * lib/webrick/ssl.rb: ditto. * lib/webrick/utils.rb: ditto. * lib/webrick/version.rb: ditto. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38945 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/webrick/httpresponse.rb')
-rw-r--r--lib/webrick/httpresponse.rb78
1 files changed, 69 insertions, 9 deletions
diff --git a/lib/webrick/httpresponse.rb b/lib/webrick/httpresponse.rb
index 5adbc82173..8e3eb39a31 100644
--- a/lib/webrick/httpresponse.rb
+++ b/lib/webrick/httpresponse.rb
@@ -16,11 +16,34 @@ require 'webrick/httpstatus'
module WEBrick
##
- # An HTTP response.
+ # An HTTP response. This is filled in by the service or do_* methods of a
+ # WEBrick HTTP Servlet.
class HTTPResponse
- attr_reader :http_version, :status, :header
+
+ ##
+ # HTTP Response version
+
+ attr_reader :http_version
+
+ ##
+ # Response status code (200)
+
+ attr_reader :status
+
+ ##
+ # Response header
+
+ attr_reader :header
+
+ ##
+ # Response cookies
+
attr_reader :cookies
+
+ ##
+ # Response reason phrase ("OK")
+
attr_accessor :reason_phrase
##
@@ -28,13 +51,45 @@ module WEBrick
attr_accessor :body
- attr_accessor :request_method, :request_uri, :request_http_version
+ ##
+ # Request method for this response
+
+ attr_accessor :request_method
+
+ ##
+ # Request URI for this response
+
+ attr_accessor :request_uri
+
+ ##
+ # Request HTTP version for this response
+
+ attr_accessor :request_http_version
+
+ ##
+ # Filename of the static file in this response. Only used by the
+ # FileHandler servlet.
+
attr_accessor :filename
+
+ ##
+ # Is this a keep-alive response?
+
attr_accessor :keep_alive
- attr_reader :config, :sent_size
##
- # Creates a new HTTP response object
+ # Configuration for this response
+
+ attr_reader :config
+
+ ##
+ # Bytes sent in this response
+
+ attr_reader :sent_size
+
+ ##
+ # Creates a new HTTP response object. WEBrick::Config::HTTP is the
+ # default configuration.
def initialize(config)
@config = config
@@ -145,7 +200,7 @@ module WEBrick
##
# Sends the response on +socket+
- def send_response(socket)
+ def send_response(socket) # :nodoc:
begin
setup_header()
send_header(socket)
@@ -162,7 +217,7 @@ module WEBrick
##
# Sets up the headers for sending
- def setup_header()
+ def setup_header() # :nodoc:
@reason_phrase ||= HTTPStatus::reason_phrase(@status)
@header['server'] ||= @config[:ServerSoftware]
@header['date'] ||= Time.now.httpdate
@@ -225,7 +280,7 @@ module WEBrick
##
# Sends the headers on +socket+
- def send_header(socket)
+ def send_header(socket) # :nodoc:
if @http_version.major > 0
data = status_line()
@header.each{|key, value|
@@ -243,7 +298,7 @@ module WEBrick
##
# Sends the body on +socket+
- def send_body(socket)
+ def send_body(socket) # :nodoc:
case @body
when IO then send_body_io(socket)
else send_body_string(socket)
@@ -325,6 +380,8 @@ module WEBrick
private
+ # :stopdoc:
+
def send_body_io(socket)
begin
if @request_method == "HEAD"
@@ -400,5 +457,8 @@ module WEBrick
def _write_data(socket, data)
socket << data
end
+
+ # :startdoc:
end
+
end