indexing description: "Snoop servlet that outputs request information." note: "Includes debug statements labeled 'snoop' to output to stdout" project: "Project Goanna " library: "examples" date: "$Date$" revision: "$Revision$" author: "Glenn Maughan " copyright: "Copyright (c) 2001 Glenn Maughan and others" license: "Eiffel Forum License v2 (see forum.txt)." class GOA_SNOOP_SERVLET inherit GOA_HTTP_SERVLET redefine do_get, do_post end UT_STRING_FORMATTER export {NONE} all end create init feature -- Basic operations do_get (req: GOA_HTTP_SERVLET_REQUEST; resp: GOA_HTTP_SERVLET_RESPONSE) is -- Process GET request local response: STRING do create response.make (1024) debug ("snoop") print ("Snoop Servlet%R%N") end response.append_string ("Snoop Servlet%R%N") response.append_string ("

Snoop Servlet

") response.append_string (request_html (req, resp)) response.append_string ("%R%N") resp.set_content_length (response.count) resp.send (response) end do_post (req: GOA_HTTP_SERVLET_REQUEST; resp: GOA_HTTP_SERVLET_RESPONSE) is -- Process GET request do do_get (req, resp) end feature {NONE} -- Implementation request_html (req: GOA_HTTP_SERVLET_REQUEST; resp: GOA_HTTP_SERVLET_RESPONSE): STRING is local parameter_names: DS_LINEAR [STRING] header_names: DS_LINEAR [STRING] line: STRING do create Result.make (255) Result.append_string ("
")
			Result.append_string (req.to_string)
			Result.append_string ("
") -- display all headers Result.append_string ("

Headers

") from header_names := req.get_header_names header_names.start until header_names.off loop Result.append_string (header_names.item_for_iteration + " = ") if req.has_header (header_names.item_for_iteration) then Result.append_string (req.get_header (header_names.item_for_iteration)) else Result.append_string ("Void") end Result.append_string ("
") header_names.forth end -- display all content if not req.content.is_empty then debug ("snoop") print ("Content Data:%R%N") print ("%T" + quoted_eiffel_string_out (req.content) + "%R%N") end Result.append_string ("

Content Data

%R%N") Result.append_string (quoted_eiffel_string_out (req.content)) end -- display all parameters Result.append_string ("

Parameters

%R%N") debug ("snoop") print ("Parameters:%R%N") end from parameter_names := req.get_parameter_names parameter_names.start until parameter_names.off loop line := parameter_names.item_for_iteration + " = " + quoted_eiffel_string_out (req.get_parameter (parameter_names.item_for_iteration)) debug ("snoop") print ("%T" + line + "%R%N") end Result.append_string (line + "
%R%N") parameter_names.forth end end end -- class GOA_SNOOP_SERVLET