Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use absolute URI iif via proxy AND not HTTPS. closes #41.

Thanks tai for reporting this.
  • Loading branch information...
commit 9a079a1ac64683171c1c02a51f8f1366cfa4e276 1 parent d5f0010
@nahi authored
View
4 lib/httpclient.rb
@@ -932,10 +932,6 @@ def no_proxy?(uri)
false
end
- def https?(uri)
- uri.scheme.downcase == 'https'
- end
-
# !! CAUTION !!
# Method 'do_get*' runs under MT conditon. Be careful to change.
def do_get_block(req, proxy, conn, &block)
View
8 lib/httpclient/http.rb
@@ -109,7 +109,7 @@ class Headers
# Request only. Requested query.
attr_accessor :request_query
# Request only. Requested via proxy or not.
- attr_accessor :request_via_proxy
+ attr_accessor :request_absolute_uri
# Response only. HTTP status
attr_reader :status_code
@@ -158,7 +158,7 @@ def initialize
@request_method = nil
@request_uri = nil
@request_query = nil
- @request_via_proxy = nil
+ @request_absolute_uri = nil
@status_code = nil
@reason_phrase = nil
@@ -189,7 +189,7 @@ def init_request(method, uri, query = nil)
@request_method = method
@request_uri = uri || NIL_URI
@request_query = query
- @request_via_proxy = false
+ @request_absolute_uri = false
end
# Initialize this instance as a response.
@@ -316,7 +316,7 @@ def create_query_part()
def request_line
path = create_query_uri()
- if @request_via_proxy
+ if @request_absolute_uri
path = "#{ @request_uri.scheme }://#{ @request_uri.host }:#{ @request_uri.port }#{ path }"
end
"#{ @request_method } #{ path } HTTP/#{ @http_version }#{ CRLF }"
View
6 lib/httpclient/session.rb
@@ -467,6 +467,7 @@ def <<(str)
# Manages a HTTP session with a Site.
class Session
include HTTPClient::Timeout
+ include Util
# Destination site
attr_reader :dest
@@ -528,7 +529,8 @@ def initialize(client, dest, agent_name, from)
# Send a request to the server
def query(req)
connect if @state == :INIT
- req.header.request_via_proxy = !@proxy.nil?
+ # Use absolute URI (not absolute path) iif via proxy AND not HTTPS.
+ req.header.request_absolute_uri = !@proxy.nil? and !https?(@dest)
begin
timeout(@send_timeout, SendTimeoutError) do
set_header(req)
@@ -639,7 +641,7 @@ def connect
begin
timeout(@connect_timeout, ConnectTimeoutError) do
@socket = create_socket(site)
- if @dest.scheme == 'https'
+ if https?(@dest)
if @socket.is_a?(LoopBackSocket)
connect_ssl_proxy(@socket, URI.parse(@dest.to_s)) if @proxy
else
View
5 lib/httpclient/util.rb
@@ -87,6 +87,11 @@ def hash_find_value(hash, &block)
v ? v[1] : nil
end
module_function :hash_find_value
+
+ # Checks if the given URI is https.
+ def https?(uri)
+ uri.scheme.downcase == 'https'
+ end
end
Please sign in to comment.
Something went wrong with that request. Please try again.