 |
Forums |
Admin Discussion Forums: help Start New Thread
| Message: 17204 |
 |
BY: Justin Bailey (m4dc4p) DATE: 2007-01-19 18:31 SUBJECT: RE: Trouble using the gem Thanks for the bug report. I'd like to help you solve this problem, but I'm not sure what's going on. I need some more information.
The script below attempts to access http://www.google.com using RubySSPI. Please install it in the "test" directory under the gem, execute it, and send me the results. It will give a trace of the HTTP request/response sequence between your computer and the proxy.
Make sure you place it in the "tests" directory.
# === cut here ====
# Magic constant will ensure that, if the SSPI patch has been applied, it won't break these tests
DISABLE_RUBY_SSPI_PATCH = true
require 'net/http'
require 'pathname'
$: << (File.dirname(__FILE__) << "/../lib")
require 'rubysspi'
raise "http_proxy environment variable must be set." unless ENV["http_proxy"]
proxy = URI.parse(ENV["http_proxy"])
raise "Could not parse http_proxy (#{ENV["http_proxy"]}). http_proxy should be a URL with a port (e.g. http://proxy.corp.com:8080)." unless proxy.host && proxy.port
conn = Net::HTTP.Proxy(proxy.host, proxy.port).new("www.google.com")
conn.set_debug_output $stdout
conn.start() do |http|
nego_auth = SSPI::NegotiateAuth.new
sr = http.request_get "/", { "Proxy-Authorization" => "Negotiate " + nego_auth.get_initial_token }
resp = http.get "/", { "Proxy-Authorization" => "Negotiate " + nego_auth.complete_authentication(sr["Proxy-Authenticate"].split(" ").last.strip) }
# Google redirects to country of origins domain if not US.
raise "Response code not as expected: #{resp.inspect}" unless resp.code.to_i == 200 || resp.code.to_i == 302
resp = http.get "/foobar.html"
# Some proxy servers don't return 404 but 407.
raise "Response code not as expected: #{resp.inspect}" unless resp.code.to_i == 404 || resp.code.to_i == 407
end
| |
Thread View
Post a followup to this message
|
 |