Welcome to the "trac"-ing site of http-access2!
[soap4r] [httpclient] [openpgp4u] [pkcs1] [logger] [csv] [vtr]

Ticket #6 (closed enhancement: fixed)

Opened 4 years ago

Last modified 1 year ago

Proxy Authentication

Reported by: nahi <nakahiro@gmail.com> Assigned to: nahi
Priority: normal Milestone: 2.0.7
Component: core Version: 2.0
Keywords: Cc: iusgrp, ywej

Change History

09/16/05 19:09:09 changed by nahi

  • type changed from defect to enhancement.

05/30/06 03:38:15 changed by kkkkoaaa

Keep a good job up! http://quick-adult-links.com

06/24/06 04:49:22 changed by test@test.com

  • cc set to iusgrp, ywej.
  • keywords set to iusgrp ywej.
  • summary changed from Proxy Authentication to iusgrp ywej.

laspehbk deswtmzxu nfgw irqjhslpk jipkn bejak omvqzxlbu

07/17/06 10:03:03 changed by anonymous

  • type set to enhancement.
  • summary changed from iusgrp ywej to Proxy Authentication.

10/23/06 02:03:53 changed by nahi

a patch by Sutou-san.

--- http-access2.rb.orig	2006-10-19 00:19:04.000000000 +0900
+++ http-access2.rb	2006-10-19 00:20:10.000000000 +0900
@@ -170,8 +170,7 @@
       else
         @proxy = URI.parse(proxy)
       end
-      if @proxy.scheme == nil or @proxy.scheme.downcase != 'http' or
-	  @proxy.host == nil or @proxy.port == nil
+      if !@proxy.is_a?(URI::HTTP) or @proxy.host == nil or @proxy.port == nil
 	raise ArgumentError.new("unsupported proxy `#{proxy}'")
       end
     end
@@ -745,21 +744,33 @@
   attr_accessor :scheme
   attr_accessor :host
   attr_reader :port
+  attr_accessor :user
+  attr_accessor :password
 
   def initialize(uri = nil)
     if uri
       @scheme = uri.scheme
       @host = uri.host
       @port = uri.port.to_i
+      @user = uri.user
+      @password = uri.password
     else
       @scheme = 'tcp'
       @host = '0.0.0.0'
       @port = 0
+      @user = nil
+      @password = nil
     end
   end
 
   def addr
-    "#{@scheme}://#{@host}:#{@port.to_s}"
+    credential = ""
+    if @user
+      credential << @user
+      credential << ":XXX" if @password
+      credential << "@"
+    end
+    "#{@scheme}://#{credential}#{@host}:#{@port.to_s}"
   end
 
   def port=(port)
@@ -768,7 +779,9 @@
 
   def ==(rhs)
     if rhs.is_a?(Site)
-      ((@scheme == rhs.scheme) and (@host == rhs.host) and (@port == rhs.port))
+      ((@scheme == rhs.scheme) and (@host == rhs.host) and
+       (@port == rhs.port) and (@user == rhs.user) and
+       (@password == rhs.password))
     else
       false
     end
@@ -1402,7 +1415,13 @@
   end
 
   def connect_ssl_proxy(socket)
-    socket << sprintf("CONNECT %s:%s HTTP/1.1\r\n\r\n", @dest.host, @dest.port)
+    socket << sprintf("CONNECT %s:%s HTTP/1.1\r\n", @dest.host, @dest.port)
+    if @proxy.user
+      credential = ["#{@proxy.user}:#{@proxy.password}"].pack('m')
+      credential.delete!("\r\n")
+      socket << sprintf("Proxy-Authorization: Basic %s\r\n", credential)
+    end
+    socket << "\r\n"
     parse_header(socket)
     unless @status == 200
       raise BadResponse.new(

10/23/06 02:04:07 changed by nahi

  • keywords deleted.
  • milestone changed from undefined to 2.0.7.

04/28/07 23:25:12 changed by nahi

  • status changed from new to closed.
  • resolution set to fixed.