Ruby Script to Test for TRACE method
This article has been superseded by this one.
No further updates will be made to this article.
The previous post provided a powershell example for verifying the trace method. This post provides a similar example using Ruby. Below is the script. Execute ./testSiteForTrace.rb. When prompted for the URL, enter in a site name including the trailing backslash.
#!/usr/bin/ruby
require 'net/http'
puts "Enter the URL for the site you would like to check"
puts "Format should include the protocol and trailing slash"
name = gets
url = URI.parse(name)
req = Net::HTTP::Trace.new(url.path)
resp = Net::HTTP.start(url.host, url.port) {|http|
http.request(req)
}
puts resp
I should figure out how to clean up the output but from my basic testing that's been done, a success looks something like this:
#<Net::HTTPOK:0x39c4840>
TRACE / HTTP/1.1
Accept: */*
Host: www.testedSite.dom
Connection: Keep-Alive
etc.
A failure showing that the iRule works for the time being provides a lovely stack trace:
c:/ruby/lib/ruby/1.8/net/protocol.rb:133:in `sysread': An established connection was aborted by the software in your host machine. (Errno::ECONNABORTED)
from c:/ruby/lib/ruby/1.8/net/protocol.rb:133:in `rbuf_fill'
from c:/ruby/lib/ruby/1.8/timeout.rb:56:in `timeout'
from c:/ruby/lib/ruby/1.8/timeout.rb:76:in `timeout'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:116:in `readuntil'
from c:/ruby/lib/ruby/1.8/net/protocol.rb:126:in `readline'
from c:/ruby/lib/ruby/1.8/net/http.rb:2029:in `read_status_line'
from c:/ruby/lib/ruby/1.8/net/http.rb:2018:in `read_new'
from c:/ruby/lib/ruby/1.8/net/http.rb:1059:in `request'
from testSiteForTrace.rb:12
from c:/ruby/lib/ruby/1.8/net/http.rb:547:in `start'
from c:/ruby/lib/ruby/1.8/net/http.rb:440:in `start'
from testSiteForTrace.rb:11
