94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
|
# File 'lib/httpdoc/rendering.rb', line 94
def format_response(res)
envelope, body = res.split("\n\n")
lines = envelope.split("\n")
first_line, = lines[0], (lines[1..-1] || [])
result = "<div class='response'>"
result << "<strong class='response_first_line'>#{h(first_line)}</strong><br/>"
result << .map { |h|
name, value = h.scan(/(.+):\s*(.+)/)[0]
"<span class='response_header_line'><strong class='response_header_name'>#{escape_html(name)}" <<
"</strong>: <span class='response_header_value'>#{escape_html(value)}</span></span>"
}.join("<br/>")
if body and body != ''
result << "<br/><br/>"
result << "<div class='response_body'>#{escape_html(body)}</div>"
end
result << "</div>"
result
end
|