#!/usr/local/bin/ruby # httprequestview.rb -- HTTP Request viewer # 2000/04/30 by Maki # # usage: # ruby httprequestview.rb [port] require "socket" require "thread" CRLF = "\r\n" port = ARGV.shift || 8080 ### from cgi.rb def escapeHTML(string) str = string.dup str.gsub!(/&/n, '&') str.gsub!(/\"/n, '"') str.gsub!(/>/n, '>') str.gsub!(/") print "sending message...\n" ## send header s.write "HTTP/1.0 200 OK"+CRLF s.write "Date: #{Time.now.gmtime.strftime('%a, %d %b %Y %H:%M:%S GMT')}"+CRLF s.write "Content-Type: text/html"+CRLF s.write "Content-Length: #{mes.length}"+CRLF s.write CRLF ## send body s.write "
"
s.write mes
s.write ""
s.write "