cgi.rb: option to omit HTTP header emission

From: Jos Backus <jos@...>
Date: 2004-05-06 17:27:50 UTC
List: ruby-core #2853
I'm trying to use cgi.rb to write HTML-only output. This patch adds a
"noheader" option to CGI.out which forces it to omit the HTTP header. I didn't
see an easy way to do this differently (my current hack uses StringIO).

Index: lib/cgi.rb
===================================================================
RCS file: /src/ruby/lib/cgi.rb,v
retrieving revision 1.74
diff -u -r1.74 cgi.rb
--- lib/cgi.rb  18 Apr 2004 23:19:46 -0000      1.74
+++ lib/cgi.rb  6 May 2004 17:22:08 -0000
@@ -722,7 +722,7 @@
     options["length"] = content.length.to_s
     output = stdoutput
     output.binmode if defined? output.binmode
-    output.print header(options)
+    output.print header(options) unless options.has_key?("noheader")
     output.print content unless "HEAD" == env_table['REQUEST_METHOD']
   end

-- 
Jos Backus                       _/  _/_/_/      Sunnyvale, CA
                                _/  _/   _/
                               _/  _/_/_/
                          _/  _/  _/    _/
jos at catnook.com        _/_/   _/_/_/          require 'std/disclaimer'

In This Thread

Prev Next