Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

socksify/http: documentation

  • Loading branch information...
commit 347753a1d1a74c9821027e904e91d355b57c5686 1 parent ba17e7e
Musy Bite authored February 24, 2011

Showing 1 changed file with 25 additions and 1 deletion. Show diff stats Hide diff stats

  1. 26  doc/index.html
26  doc/index.html
@@ -36,7 +36,9 @@
36 36
       </ul>
37 37
       <p>
38 38
 	Additionally, <code>Socksify::resolve</code> can be used to
39  
-	resolve hostnames to IPv4 addresses via SOCKS.
  39
+	resolve hostnames to IPv4 addresses via SOCKS. There is also
  40
+	<code>socksify/http</code> library enabling Net::HTTP to work
  41
+	via SOCKS.
40 42
       </p>
41 43
 
42 44
       <h2>Installation</h2>
@@ -64,6 +66,28 @@
64 66
 rubyforge_www = TCPSocket.new("rubyforge.org", 80)
65 67
 # => #&lt;TCPSocket:0x...&gt;</pre>
66 68
 
  69
+      <h3>Use Net::HTTP explicitly via SOCKS</h3>
  70
+      <p>
  71
+	Require additional library <code>socksify/http</code>
  72
+	and use <code>Net::HTTP.SOCKSProxy</code> method. It
  73
+	is similar to <code>Net:HTTP.Proxy</code> from Ruby
  74
+	standard library:
  75
+      </p>
  76
+      <pre>
  77
+require 'socksify/http'
  78
+uri = URI.parse('http://rubyforge.org/')
  79
+Net::HTTP.SOCKSProxy('127.0.0.1', 9050).start(uri.host, uri.port) do |http|
  80
+  http.get(uri.path)
  81
+end
  82
+# => #&lt;Net::HTTPOK 200 OK readbody=true&gt;</pre>
  83
+
  84
+      <p>
  85
+	Note that <code>Net::HTTP.SOCKSProxy</code> never rely
  86
+	on <code>TCPSocket::socks_server</code>/<code>socks_port</code>.
  87
+	You should either set <code>SOCKSProxy</code> arguments
  88
+	explicitly or use <code>Net::HTTP</code> directly.
  89
+      </p>
  90
+
67 91
       <h3>Resolve addresses via SOCKS</h3>
68 92
       <pre>Socksify::resolve("spaceboyz.net")
69 93
 # => "87.106.131.203"</pre>

0 notes on commit 347753a

Please sign in to comment.
Something went wrong with that request. Please try again.