{"payload":{"allShortcutsEnabled":false,"fileTree":{"lib/webrick":{"items":[{"name":"httpauth","path":"lib/webrick/httpauth","contentType":"directory"},{"name":"httpservlet","path":"lib/webrick/httpservlet","contentType":"directory"},{"name":"accesslog.rb","path":"lib/webrick/accesslog.rb","contentType":"file"},{"name":"cgi.rb","path":"lib/webrick/cgi.rb","contentType":"file"},{"name":"compat.rb","path":"lib/webrick/compat.rb","contentType":"file"},{"name":"config.rb","path":"lib/webrick/config.rb","contentType":"file"},{"name":"cookie.rb","path":"lib/webrick/cookie.rb","contentType":"file"},{"name":"htmlutils.rb","path":"lib/webrick/htmlutils.rb","contentType":"file"},{"name":"httpauth.rb","path":"lib/webrick/httpauth.rb","contentType":"file"},{"name":"httpproxy.rb","path":"lib/webrick/httpproxy.rb","contentType":"file"},{"name":"httprequest.rb","path":"lib/webrick/httprequest.rb","contentType":"file"},{"name":"httpresponse.rb","path":"lib/webrick/httpresponse.rb","contentType":"file"},{"name":"https.rb","path":"lib/webrick/https.rb","contentType":"file"},{"name":"httpserver.rb","path":"lib/webrick/httpserver.rb","contentType":"file"},{"name":"httpservlet.rb","path":"lib/webrick/httpservlet.rb","contentType":"file"},{"name":"httpstatus.rb","path":"lib/webrick/httpstatus.rb","contentType":"file"},{"name":"httputils.rb","path":"lib/webrick/httputils.rb","contentType":"file"},{"name":"httpversion.rb","path":"lib/webrick/httpversion.rb","contentType":"file"},{"name":"log.rb","path":"lib/webrick/log.rb","contentType":"file"},{"name":"server.rb","path":"lib/webrick/server.rb","contentType":"file"},{"name":"ssl.rb","path":"lib/webrick/ssl.rb","contentType":"file"},{"name":"utils.rb","path":"lib/webrick/utils.rb","contentType":"file"},{"name":"version.rb","path":"lib/webrick/version.rb","contentType":"file"}],"totalCount":23},"lib":{"items":[{"name":"cgi","path":"lib/cgi","contentType":"directory"},{"name":"drb","path":"lib/drb","contentType":"directory"},{"name":"irb","path":"lib/irb","contentType":"directory"},{"name":"matrix","path":"lib/matrix","contentType":"directory"},{"name":"minitest","path":"lib/minitest","contentType":"directory"},{"name":"net","path":"lib/net","contentType":"directory"},{"name":"optparse","path":"lib/optparse","contentType":"directory"},{"name":"racc","path":"lib/racc","contentType":"directory"},{"name":"rake","path":"lib/rake","contentType":"directory"},{"name":"rbconfig","path":"lib/rbconfig","contentType":"directory"},{"name":"rdoc","path":"lib/rdoc","contentType":"directory"},{"name":"rexml","path":"lib/rexml","contentType":"directory"},{"name":"rinda","path":"lib/rinda","contentType":"directory"},{"name":"rss","path":"lib/rss","contentType":"directory"},{"name":"rubygems","path":"lib/rubygems","contentType":"directory"},{"name":"shell","path":"lib/shell","contentType":"directory"},{"name":"test","path":"lib/test","contentType":"directory"},{"name":"uri","path":"lib/uri","contentType":"directory"},{"name":"webrick","path":"lib/webrick","contentType":"directory"},{"name":"xmlrpc","path":"lib/xmlrpc","contentType":"directory"},{"name":"yaml","path":"lib/yaml","contentType":"directory"},{"name":"English.rb","path":"lib/English.rb","contentType":"file"},{"name":"abbrev.rb","path":"lib/abbrev.rb","contentType":"file"},{"name":"base64.rb","path":"lib/base64.rb","contentType":"file"},{"name":"benchmark.rb","path":"lib/benchmark.rb","contentType":"file"},{"name":"cgi.rb","path":"lib/cgi.rb","contentType":"file"},{"name":"cmath.rb","path":"lib/cmath.rb","contentType":"file"},{"name":"complex.rb","path":"lib/complex.rb","contentType":"file"},{"name":"csv.rb","path":"lib/csv.rb","contentType":"file"},{"name":"debug.rb","path":"lib/debug.rb","contentType":"file"},{"name":"delegate.rb","path":"lib/delegate.rb","contentType":"file"},{"name":"drb.rb","path":"lib/drb.rb","contentType":"file"},{"name":"e2mmap.rb","path":"lib/e2mmap.rb","contentType":"file"},{"name":"erb.rb","path":"lib/erb.rb","contentType":"file"},{"name":"fileutils.rb","path":"lib/fileutils.rb","contentType":"file"},{"name":"find.rb","path":"lib/find.rb","contentType":"file"},{"name":"forwardable.rb","path":"lib/forwardable.rb","contentType":"file"},{"name":"getoptlong.rb","path":"lib/getoptlong.rb","contentType":"file"},{"name":"gserver.rb","path":"lib/gserver.rb","contentType":"file"},{"name":"ipaddr.rb","path":"lib/ipaddr.rb","contentType":"file"},{"name":"irb.rb","path":"lib/irb.rb","contentType":"file"},{"name":"logger.rb","path":"lib/logger.rb","contentType":"file"},{"name":"mathn.rb","path":"lib/mathn.rb","contentType":"file"},{"name":"matrix.rb","path":"lib/matrix.rb","contentType":"file"},{"name":"mkmf.rb","path":"lib/mkmf.rb","contentType":"file"},{"name":"monitor.rb","path":"lib/monitor.rb","contentType":"file"},{"name":"mutex_m.rb","path":"lib/mutex_m.rb","contentType":"file"},{"name":"observer.rb","path":"lib/observer.rb","contentType":"file"},{"name":"open-uri.rb","path":"lib/open-uri.rb","contentType":"file"},{"name":"open3.rb","path":"lib/open3.rb","contentType":"file"},{"name":"optparse.rb","path":"lib/optparse.rb","contentType":"file"},{"name":"ostruct.rb","path":"lib/ostruct.rb","contentType":"file"},{"name":"pp.rb","path":"lib/pp.rb","contentType":"file"},{"name":"prettyprint.rb","path":"lib/prettyprint.rb","contentType":"file"},{"name":"prime.rb","path":"lib/prime.rb","contentType":"file"},{"name":"profile.rb","path":"lib/profile.rb","contentType":"file"},{"name":"profiler.rb","path":"lib/profiler.rb","contentType":"file"},{"name":"pstore.rb","path":"lib/pstore.rb","contentType":"file"},{"name":"rake.rb","path":"lib/rake.rb","contentType":"file"},{"name":"rational.rb","path":"lib/rational.rb","contentType":"file"},{"name":"rdoc.rb","path":"lib/rdoc.rb","contentType":"file"},{"name":"resolv-replace.rb","path":"lib/resolv-replace.rb","contentType":"file"},{"name":"resolv.rb","path":"lib/resolv.rb","contentType":"file"},{"name":"rss.rb","path":"lib/rss.rb","contentType":"file"},{"name":"rubygems.rb","path":"lib/rubygems.rb","contentType":"file"},{"name":"scanf.rb","path":"lib/scanf.rb","contentType":"file"},{"name":"securerandom.rb","path":"lib/securerandom.rb","contentType":"file"},{"name":"set.rb","path":"lib/set.rb","contentType":"file"},{"name":"shell.rb","path":"lib/shell.rb","contentType":"file"},{"name":"shellwords.rb","path":"lib/shellwords.rb","contentType":"file"},{"name":"singleton.rb","path":"lib/singleton.rb","contentType":"file"},{"name":"sync.rb","path":"lib/sync.rb","contentType":"file"},{"name":"tempfile.rb","path":"lib/tempfile.rb","contentType":"file"},{"name":"thread.rb","path":"lib/thread.rb","contentType":"file"},{"name":"thwait.rb","path":"lib/thwait.rb","contentType":"file"},{"name":"time.rb","path":"lib/time.rb","contentType":"file"},{"name":"timeout.rb","path":"lib/timeout.rb","contentType":"file"},{"name":"tmpdir.rb","path":"lib/tmpdir.rb","contentType":"file"},{"name":"tracer.rb","path":"lib/tracer.rb","contentType":"file"},{"name":"tsort.rb","path":"lib/tsort.rb","contentType":"file"},{"name":"ubygems.rb","path":"lib/ubygems.rb","contentType":"file"},{"name":"un.rb","path":"lib/un.rb","contentType":"file"},{"name":"uri.rb","path":"lib/uri.rb","contentType":"file"},{"name":"weakref.rb","path":"lib/weakref.rb","contentType":"file"},{"name":"webrick.rb","path":"lib/webrick.rb","contentType":"file"},{"name":"xmlrpc.rb","path":"lib/xmlrpc.rb","contentType":"file"},{"name":"yaml.rb","path":"lib/yaml.rb","contentType":"file"}],"totalCount":87},"":{"items":[{"name":"bcc32","path":"bcc32","contentType":"directory"},{"name":"benchmark","path":"benchmark","contentType":"directory"},{"name":"bin","path":"bin","contentType":"directory"},{"name":"bootstraptest","path":"bootstraptest","contentType":"directory"},{"name":"cygwin","path":"cygwin","contentType":"directory"},{"name":"defs","path":"defs","contentType":"directory"},{"name":"doc","path":"doc","contentType":"directory"},{"name":"enc","path":"enc","contentType":"directory"},{"name":"ext","path":"ext","contentType":"directory"},{"name":"include","path":"include","contentType":"directory"},{"name":"lib","path":"lib","contentType":"directory"},{"name":"man","path":"man","contentType":"directory"},{"name":"misc","path":"misc","contentType":"directory"},{"name":"missing","path":"missing","contentType":"directory"},{"name":"nacl","path":"nacl","contentType":"directory"},{"name":"sample","path":"sample","contentType":"directory"},{"name":"spec","path":"spec","contentType":"directory"},{"name":"symbian","path":"symbian","contentType":"directory"},{"name":"template","path":"template","contentType":"directory"},{"name":"test","path":"test","contentType":"directory"},{"name":"tool","path":"tool","contentType":"directory"},{"name":"win32","path":"win32","contentType":"directory"},{"name":".document","path":".document","contentType":"file"},{"name":".editorconfig","path":".editorconfig","contentType":"file"},{"name":".gdbinit","path":".gdbinit","contentType":"file"},{"name":".gitignore","path":".gitignore","contentType":"file"},{"name":".indent.pro","path":".indent.pro","contentType":"file"},{"name":".travis.yml","path":".travis.yml","contentType":"file"},{"name":"BSDL","path":"BSDL","contentType":"file"},{"name":"COPYING","path":"COPYING","contentType":"file"},{"name":"COPYING.ja","path":"COPYING.ja","contentType":"file"},{"name":"ChangeLog","path":"ChangeLog","contentType":"file"},{"name":"GPL","path":"GPL","contentType":"file"},{"name":"KNOWNBUGS.rb","path":"KNOWNBUGS.rb","contentType":"file"},{"name":"LEGAL","path":"LEGAL","contentType":"file"},{"name":"Makefile.in","path":"Makefile.in","contentType":"file"},{"name":"NEWS","path":"NEWS","contentType":"file"},{"name":"README","path":"README","contentType":"file"},{"name":"README.EXT","path":"README.EXT","contentType":"file"},{"name":"README.EXT.ja","path":"README.EXT.ja","contentType":"file"},{"name":"README.ja","path":"README.ja","contentType":"file"},{"name":"addr2line.c","path":"addr2line.c","contentType":"file"},{"name":"addr2line.h","path":"addr2line.h","contentType":"file"},{"name":"array.c","path":"array.c","contentType":"file"},{"name":"bignum.c","path":"bignum.c","contentType":"file"},{"name":"class.c","path":"class.c","contentType":"file"},{"name":"common.mk","path":"common.mk","contentType":"file"},{"name":"compar.c","path":"compar.c","contentType":"file"},{"name":"compile.c","path":"compile.c","contentType":"file"},{"name":"complex.c","path":"complex.c","contentType":"file"},{"name":"configure.in","path":"configure.in","contentType":"file"},{"name":"constant.h","path":"constant.h","contentType":"file"},{"name":"cont.c","path":"cont.c","contentType":"file"},{"name":"debug.c","path":"debug.c","contentType":"file"},{"name":"dir.c","path":"dir.c","contentType":"file"},{"name":"dln.c","path":"dln.c","contentType":"file"},{"name":"dln.h","path":"dln.h","contentType":"file"},{"name":"dln_find.c","path":"dln_find.c","contentType":"file"},{"name":"dmydln.c","path":"dmydln.c","contentType":"file"},{"name":"dmyencoding.c","path":"dmyencoding.c","contentType":"file"},{"name":"dmyext.c","path":"dmyext.c","contentType":"file"},{"name":"dmyversion.c","path":"dmyversion.c","contentType":"file"},{"name":"encoding.c","path":"encoding.c","contentType":"file"},{"name":"enum.c","path":"enum.c","contentType":"file"},{"name":"enumerator.c","path":"enumerator.c","contentType":"file"},{"name":"error.c","path":"error.c","contentType":"file"},{"name":"eval.c","path":"eval.c","contentType":"file"},{"name":"eval_error.c","path":"eval_error.c","contentType":"file"},{"name":"eval_intern.h","path":"eval_intern.h","contentType":"file"},{"name":"eval_jump.c","path":"eval_jump.c","contentType":"file"},{"name":"file.c","path":"file.c","contentType":"file"},{"name":"gc.c","path":"gc.c","contentType":"file"},{"name":"gc.h","path":"gc.h","contentType":"file"},{"name":"gem_prelude.rb","path":"gem_prelude.rb","contentType":"file"},{"name":"golf_prelude.rb","path":"golf_prelude.rb","contentType":"file"},{"name":"goruby.c","path":"goruby.c","contentType":"file"},{"name":"hash.c","path":"hash.c","contentType":"file"},{"name":"ia64.s","path":"ia64.s","contentType":"file"},{"name":"inits.c","path":"inits.c","contentType":"file"},{"name":"insns.def","path":"insns.def","contentType":"file"},{"name":"internal.h","path":"internal.h","contentType":"file"},{"name":"io.c","path":"io.c","contentType":"file"},{"name":"iseq.c","path":"iseq.c","contentType":"file"},{"name":"iseq.h","path":"iseq.h","contentType":"file"},{"name":"lex.c.blt","path":"lex.c.blt","contentType":"file"},{"name":"load.c","path":"load.c","contentType":"file"},{"name":"main.c","path":"main.c","contentType":"file"},{"name":"marshal.c","path":"marshal.c","contentType":"file"},{"name":"math.c","path":"math.c","contentType":"file"},{"name":"method.h","path":"method.h","contentType":"file"},{"name":"node.c","path":"node.c","contentType":"file"},{"name":"node.h","path":"node.h","contentType":"file"},{"name":"numeric.c","path":"numeric.c","contentType":"file"},{"name":"object.c","path":"object.c","contentType":"file"},{"name":"pack.c","path":"pack.c","contentType":"file"},{"name":"parse.y","path":"parse.y","contentType":"file"},{"name":"prelude.rb","path":"prelude.rb","contentType":"file"},{"name":"probes.d","path":"probes.d","contentType":"file"},{"name":"probes_helper.h","path":"probes_helper.h","contentType":"file"},{"name":"proc.c","path":"proc.c","contentType":"file"},{"name":"process.c","path":"process.c","contentType":"file"},{"name":"random.c","path":"random.c","contentType":"file"},{"name":"range.c","path":"range.c","contentType":"file"},{"name":"rational.c","path":"rational.c","contentType":"file"},{"name":"re.c","path":"re.c","contentType":"file"},{"name":"regcomp.c","path":"regcomp.c","contentType":"file"},{"name":"regenc.c","path":"regenc.c","contentType":"file"},{"name":"regenc.h","path":"regenc.h","contentType":"file"},{"name":"regerror.c","path":"regerror.c","contentType":"file"},{"name":"regexec.c","path":"regexec.c","contentType":"file"},{"name":"regint.h","path":"regint.h","contentType":"file"},{"name":"regparse.c","path":"regparse.c","contentType":"file"},{"name":"regparse.h","path":"regparse.h","contentType":"file"},{"name":"regsyntax.c","path":"regsyntax.c","contentType":"file"},{"name":"ruby.c","path":"ruby.c","contentType":"file"},{"name":"ruby_atomic.h","path":"ruby_atomic.h","contentType":"file"},{"name":"safe.c","path":"safe.c","contentType":"file"},{"name":"signal.c","path":"signal.c","contentType":"file"},{"name":"siphash.c","path":"siphash.c","contentType":"file"},{"name":"siphash.h","path":"siphash.h","contentType":"file"},{"name":"sparc.c","path":"sparc.c","contentType":"file"},{"name":"sprintf.c","path":"sprintf.c","contentType":"file"},{"name":"st.c","path":"st.c","contentType":"file"},{"name":"strftime.c","path":"strftime.c","contentType":"file"},{"name":"string.c","path":"string.c","contentType":"file"},{"name":"struct.c","path":"struct.c","contentType":"file"},{"name":"thread.c","path":"thread.c","contentType":"file"},{"name":"thread_pthread.c","path":"thread_pthread.c","contentType":"file"},{"name":"thread_pthread.h","path":"thread_pthread.h","contentType":"file"},{"name":"thread_win32.c","path":"thread_win32.c","contentType":"file"},{"name":"thread_win32.h","path":"thread_win32.h","contentType":"file"},{"name":"time.c","path":"time.c","contentType":"file"},{"name":"timev.h","path":"timev.h","contentType":"file"},{"name":"transcode.c","path":"transcode.c","contentType":"file"},{"name":"transcode_data.h","path":"transcode_data.h","contentType":"file"},{"name":"util.c","path":"util.c","contentType":"file"},{"name":"variable.c","path":"variable.c","contentType":"file"},{"name":"version.c","path":"version.c","contentType":"file"},{"name":"version.h","path":"version.h","contentType":"file"},{"name":"vm.c","path":"vm.c","contentType":"file"},{"name":"vm_backtrace.c","path":"vm_backtrace.c","contentType":"file"},{"name":"vm_core.h","path":"vm_core.h","contentType":"file"},{"name":"vm_debug.h","path":"vm_debug.h","contentType":"file"},{"name":"vm_dump.c","path":"vm_dump.c","contentType":"file"},{"name":"vm_eval.c","path":"vm_eval.c","contentType":"file"},{"name":"vm_exec.c","path":"vm_exec.c","contentType":"file"},{"name":"vm_exec.h","path":"vm_exec.h","contentType":"file"},{"name":"vm_insnhelper.c","path":"vm_insnhelper.c","contentType":"file"},{"name":"vm_insnhelper.h","path":"vm_insnhelper.h","contentType":"file"},{"name":"vm_method.c","path":"vm_method.c","contentType":"file"},{"name":"vm_opts.h","path":"vm_opts.h","contentType":"file"},{"name":"vm_trace.c","path":"vm_trace.c","contentType":"file"},{"name":"vsnprintf.c","path":"vsnprintf.c","contentType":"file"}],"totalCount":153}},"fileTreeProcessingTime":36.260059999999996,"foldersToFetch":[],"repo":{"id":538746,"defaultBranch":"master","name":"ruby","ownerLogin":"ruby","currentUserCanPush":false,"isFork":false,"isEmpty":false,"createdAt":"2010-02-27T15:55:23.000Z","ownerAvatar":"https://avatars.githubusercontent.com/u/210414?v=4","public":true,"private":false,"isOrgOwned":true},"symbolsExpanded":false,"treeExpanded":true,"refInfo":{"name":"ruby_2_0_0","listCacheKey":"v0:1710777744.0","canEdit":false,"refType":"branch","currentOid":"073cc5e815fcf5178fe4e515fcde74dc3597adeb"},"path":"lib/webrick/httpresponse.rb","currentUser":null,"blob":{"rawLines":["#","# httpresponse.rb -- HTTPResponse Class","#","# Author: IPR -- Internet Programming with Ruby -- writers","# Copyright (c) 2000, 2001 TAKAHASHI Masayoshi, GOTOU Yuuzou","# Copyright (c) 2002 Internet Programming with Ruby writers. All rights","# reserved.","#","# $IPR: httpresponse.rb,v 1.45 2003/07/11 11:02:25 gotoyuzo Exp $","","require 'time'","require 'webrick/httpversion'","require 'webrick/htmlutils'","require 'webrick/httputils'","require 'webrick/httpstatus'","","module WEBrick"," ##"," # An HTTP response. This is filled in by the service or do_* methods of a"," # WEBrick HTTP Servlet.",""," class HTTPResponse",""," ##"," # 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",""," ##"," # Body may be a String or IO subclass.",""," attr_accessor :body",""," ##"," # 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",""," ##"," # 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"," @buffer_size = config[:OutputBufferSize]"," @logger = config[:Logger]"," @header = Hash.new"," @status = HTTPStatus::RC_OK"," @reason_phrase = nil"," @http_version = HTTPVersion::convert(@config[:HTTPVersion])"," @body = ''"," @keep_alive = true"," @cookies = []"," @request_method = nil"," @request_uri = nil"," @request_http_version = @http_version # temporary"," @chunked = false"," @filename = nil"," @sent_size = 0"," end",""," ##"," # The response's HTTP status line",""," def status_line"," \"HTTP/#@http_version #@status #@reason_phrase #{CRLF}\""," end",""," ##"," # Sets the response's status to the +status+ code",""," def status=(status)"," @status = status"," @reason_phrase = HTTPStatus::reason_phrase(status)"," end",""," ##"," # Retrieves the response header +field+",""," def [](field)"," @header[field.downcase]"," end",""," ##"," # Sets the response header +field+ to +value+",""," def []=(field, value)"," @header[field.downcase] = value.to_s"," end",""," ##"," # The content-length header",""," def content_length"," if len = self['content-length']"," return Integer(len)"," end"," end",""," ##"," # Sets the content-length header to +len+",""," def content_length=(len)"," self['content-length'] = len.to_s"," end",""," ##"," # The content-type header",""," def content_type"," self['content-type']"," end",""," ##"," # Sets the content-type header to +type+",""," def content_type=(type)"," self['content-type'] = type"," end",""," ##"," # Iterates over each header in the resopnse",""," def each"," @header.each{|field, value| yield(field, value) }"," end",""," ##"," # Will this response body be returned using chunked transfer-encoding?",""," def chunked?"," @chunked"," end",""," ##"," # Enables chunked transfer encoding.",""," def chunked=(val)"," @chunked = val ? true : false"," end",""," ##"," # Will this response's connection be kept alive?",""," def keep_alive?"," @keep_alive"," end",""," ##"," # Sends the response on +socket+",""," def send_response(socket) # :nodoc:"," begin"," setup_header()"," send_header(socket)"," send_body(socket)"," rescue Errno::EPIPE, Errno::ECONNRESET, Errno::ENOTCONN => ex"," @logger.debug(ex)"," @keep_alive = false"," rescue Exception => ex"," @logger.error(ex)"," @keep_alive = false"," end"," end",""," ##"," # Sets up the headers for sending",""," def setup_header() # :nodoc:"," @reason_phrase ||= HTTPStatus::reason_phrase(@status)"," @header['server'] ||= @config[:ServerSoftware]"," @header['date'] ||= Time.now.httpdate",""," # HTTP/0.9 features"," if @request_http_version < \"1.0\""," @http_version = HTTPVersion.new(\"0.9\")"," @keep_alive = false"," end",""," # HTTP/1.0 features"," if @request_http_version < \"1.1\""," if chunked?"," @chunked = false"," ver = @request_http_version.to_s"," msg = \"chunked is set for an HTTP/#{ver} request. (ignored)\""," @logger.warn(msg)"," end"," end",""," # Determine the message length (RFC2616 -- 4.4 Message Length)"," if @status == 304 || @status == 204 || HTTPStatus::info?(@status)"," @header.delete('content-length')"," @body = \"\""," elsif chunked?"," @header[\"transfer-encoding\"] = \"chunked\""," @header.delete('content-length')"," elsif %r{^multipart/byteranges} =~ @header['content-type']"," @header.delete('content-length')"," elsif @header['content-length'].nil?"," unless @body.is_a?(IO)"," @header['content-length'] = @body ? @body.bytesize : 0"," end"," end",""," # Keep-Alive connection."," if @header['connection'] == \"close\""," @keep_alive = false"," elsif keep_alive?"," if chunked? || @header['content-length'] || @status == 304 || @status == 204 || HTTPStatus.info?(@status)"," @header['connection'] = \"Keep-Alive\""," else"," msg = \"Could not determine content-length of response body. Set content-length of the response or set Response#chunked = true\""," @logger.warn(msg)"," @header['connection'] = \"close\""," @keep_alive = false"," end"," else"," @header['connection'] = \"close\""," end",""," # Location is a single absoluteURI."," if location = @header['location']"," if @request_uri"," @header['location'] = @request_uri.merge(location)"," end"," end"," end",""," ##"," # Sends the headers on +socket+",""," def send_header(socket) # :nodoc:"," if @http_version.major > 0"," data = status_line()"," @header.each{|key, value|"," tmp = key.gsub(/\\bwww|^te$|\\b\\w/){ $&.upcase }"," data << \"#{tmp}: #{value}\" << CRLF"," }"," @cookies.each{|cookie|"," data << \"Set-Cookie: \" << cookie.to_s << CRLF"," }"," data << CRLF"," _write_data(socket, data)"," end"," end",""," ##"," # Sends the body on +socket+",""," def send_body(socket) # :nodoc:"," case @body"," when IO then send_body_io(socket)"," else send_body_string(socket)"," end"," end",""," def to_s # :nodoc:"," ret = \"\""," send_response(ret)"," ret"," end",""," ##"," # Redirects to +url+ with a WEBrick::HTTPStatus::Redirect +status+."," #"," # Example:"," #"," # res.set_redirect WEBrick::HTTPStatus::TemporaryRedirect",""," def set_redirect(status, url)"," @body = \"#{url.to_s}.\\n\""," @header['location'] = url.to_s"," raise status"," end",""," ##"," # Creates an error page for exception +ex+ with an optional +backtrace+",""," def set_error(ex, backtrace=false)"," case ex"," when HTTPStatus::Status"," @keep_alive = false if HTTPStatus::error?(ex.code)"," self.status = ex.code"," else"," @keep_alive = false"," self.status = HTTPStatus::RC_INTERNAL_SERVER_ERROR"," end"," @header['content-type'] = \"text/html; charset=ISO-8859-1\"",""," if respond_to?(:create_error_page)"," create_error_page()"," return"," end",""," if @request_uri"," host, port = @request_uri.host, @request_uri.port"," else"," host, port = @config[:ServerName], @config[:Port]"," end",""," @body = ''"," @body << <<-_end_of_html_","","","
\""," ex.backtrace.each{|line| @body << \"\\t#{line}\\n\"}"," @body << \"