-
Notifications
You must be signed in to change notification settings - Fork 80
[DOC] Reorganize doc for proxy server #117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 5 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
1fad1d4
Enhanced RDoc for Net::HTTP
BurdetteLamar b5e25c1
Enhanced RDoc forr Net::HTTP
BurdetteLamar e6a9365
Enhanced RDoc forr Net::HTTP
BurdetteLamar 6f06f98
Enhanced RDoc for Net::HTTP
BurdetteLamar d4c3876
Merge branch 'master' into http_doc
peterzhu2118 c996aae
Enhanced RDoc for Net::HTTP
BurdetteLamar 192bc92
Merge branch 'http_doc' of https://github.com/BurdetteLamar/net-http …
BurdetteLamar File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -332,20 +332,108 @@ class HTTPHeaderSyntaxError < StandardError; end | |
| # uri # => #<URI::HTTPS https://jsonplaceholder.typicode.com/> | ||
| # Net::HTTP.get(uri) | ||
| # | ||
| # == Proxies | ||
| # == Proxy Server | ||
| # | ||
| # An \HTTP object can have | ||
| # a {proxy server}[https://en.wikipedia.org/wiki/Proxy_server]. | ||
| # | ||
| # You can create an \HTTP object with a proxy server | ||
| # using method Net::HTTP.new or method net::HTTP.start. | ||
| # The two methods differ only in that: | ||
| # | ||
| # - Net::HTTP.new has +p_no_proxy+ as its last argument | ||
| # (see {Filtering Proxies}[rdoc-ref:Net::HTTP@Filtering+Proxies] below), | ||
| # and does not take a block (ignored if given). | ||
| # - Net::HTTP.start has +opts+ as its last argument (see Net::HTTP.start), | ||
| # and may take a block. | ||
peterzhu2118 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # | ||
| # The proxy may be defined either by argument +p_addr+ | ||
| # or by an environment variable. | ||
peterzhu2118 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # | ||
| # === Proxy Using Argument +p_addr+ as a \String | ||
| # | ||
| # When argument +p_addr+ is a string hostname, | ||
| # the returned +http+ has the given host as its proxy: | ||
| # | ||
| # http = Net::HTTP.new(hostname, nil, 'proxy.example') | ||
| # http.proxy? # => true | ||
| # http.proxy_from_env? # => false | ||
| # http.proxy_address # => "proxy.example" | ||
| # # These use default values. | ||
| # http.proxy_port # => 80 | ||
| # http.proxy_user # => nil | ||
| # http.proxy_pass # => nil | ||
| # | ||
| # The port, username, and password for the proxy may also be given: | ||
| # | ||
| # http = Net::HTTP.new(hostname, nil, 'proxy.example', 8000, 'pname', 'ppass') | ||
| # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false> | ||
| # http.proxy? # => true | ||
| # http.proxy_from_env? # => false | ||
| # http.proxy_address # => "proxy.example" | ||
| # http.proxy_port # => 8000 | ||
| # http.proxy_user # => "pname" | ||
| # http.proxy_pass # => "ppass" | ||
| # | ||
| # === Proxy Using <tt>ENV['http_proxy']</tt> | ||
| # | ||
| # When environment variable <tt>'http_proxy'</tt> | ||
| # is set to a \URI string, | ||
| # the returned +http+ will have the server at that URI as its proxy; | ||
| # note that the \URI string must have a protocol | ||
| # such as <tt>'http'</tt> or <tt>'https'</tt>: | ||
| # | ||
| # ENV['http_proxy'] = 'http://example.com' | ||
| # http = Net::HTTP.new(hostname) | ||
| # http.proxy? # => true | ||
| # http.proxy_from_env? # => true | ||
| # http.proxy_address # => "example.com" | ||
| # # These use default values. | ||
| # http.proxy_port # => 80 | ||
| # http.proxy_user # => nil | ||
| # http.proxy_pass # => nil | ||
| # | ||
| # The \URI string may include proxy username, password, and port number: | ||
| # | ||
| # ENV['http_proxy'] = 'http://pname:[email protected]:8000' | ||
| # http = Net::HTTP.new(hostname) | ||
| # http.proxy? # => true | ||
| # http.proxy_from_env? # => true | ||
| # http.proxy_address # => "example.com" | ||
| # http.proxy_port # => 8000 | ||
| # http.proxy_user # => "pname" | ||
| # http.proxy_pass # => "ppass" | ||
| # | ||
| # === Filtering Proxies | ||
| # | ||
| # With method Net::HTTP.new (but not Net::HTTP.start), | ||
| # you can use argument +p_no_proxy+ to filter proxies: | ||
| # | ||
| # - Reject a certain address: | ||
| # | ||
| # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example') | ||
| # http.proxy_address # => nil | ||
| # | ||
| # - Reject certain domains or subdomains: | ||
| # | ||
| # http = Net::HTTP.new('example.com', nil, 'my.proxy.example', 8000, 'pname', 'ppass', 'proxy.example') | ||
| # http.proxy_address # => nil | ||
| # | ||
| # - Reject certain addresses and port combinations: | ||
| # | ||
| # \Net::HTTP will automatically create a proxy from the +http_proxy+ | ||
| # environment variable if it is present. To disable use of +http_proxy+, | ||
| # pass +nil+ for the proxy address. | ||
| # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:1234') | ||
| # http.proxy_address # => "proxy.example" | ||
| # | ||
| # You may also create a custom proxy: | ||
| # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:8000') | ||
| # http.proxy_address # => nil | ||
| # | ||
| # proxy_addr = 'your.proxy.host' | ||
| # proxy_port = 8080 | ||
| # - Reject a list of the types above delimited using a comma: | ||
| # | ||
| # Net::HTTP.new('example.com', nil, proxy_addr, proxy_port).start { |http| | ||
| # # always proxy via your.proxy.addr:8080 | ||
| # } | ||
| # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000') | ||
| # http.proxy_address # => nil | ||
| # | ||
| # http = Net::HTTP.new('example.com', nil, 'my.proxy', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000') | ||
| # http.proxy_address # => nil | ||
| # | ||
| # == Compression | ||
| # | ||
|
|
@@ -564,14 +652,11 @@ def HTTP.socket_type #:nodoc: obsolete | |
| # | ||
| # Creates a new \Net::HTTP object, +http+, via \Net::HTTP.new: | ||
| # | ||
| # Net::HTTP.new(address, port, p_addr, p_port, p_user, p_pass) | ||
| # | ||
| # - For arguments +hostname+ through +p_pass+, see Net::HTTP.new. | ||
| # - For arguments +address+ and +port+, see Net::HTTP.new. | ||
| # - For proxy-defining arguments +p_addr+ through +p_pass+, | ||
| # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server]. | ||
| # - For argument +opts+, see below. | ||
| # | ||
| # Note: If +port+ is +nil+ and <tt>opts[:use_ssl]</tt> is a truthy value, | ||
| # the value passed to +new+ is Net::HTTP.https_default_port, not +port+. | ||
| # | ||
| # With no block given: | ||
| # | ||
| # - Calls <tt>http.start</tt> with no block (see #start), | ||
|
|
@@ -644,6 +729,9 @@ def HTTP.socket_type #:nodoc: obsolete | |
| # - #verify_mode | ||
| # - #write_timeout | ||
| # | ||
| # Note: If +port+ is +nil+ and <tt>opts[:use_ssl]</tt> is a truthy value, | ||
| # the value passed to +new+ is Net::HTTP.https_default_port, not +port+. | ||
| # | ||
| def HTTP.start(address, *arg, &block) # :yield: +http+ | ||
| arg.pop if opt = Hash.try_convert(arg[-1]) | ||
| port, p_addr, p_port, p_user, p_pass = *arg | ||
|
|
@@ -673,9 +761,7 @@ class << HTTP | |
| # Returns a new \Net::HTTP object +http+ | ||
| # (but does not open a TCP connection or \HTTP session). | ||
| # | ||
| # <b>No Proxy</b> | ||
| # | ||
| # With only string argument +hostname+ given | ||
| # With only string argument +address+ given | ||
| # (and <tt>ENV['http_proxy']</tt> undefined or +nil+), | ||
| # the returned +http+: | ||
| # | ||
|
|
@@ -698,85 +784,8 @@ class << HTTP | |
| # # => #<Net::HTTP jsonplaceholder.typicode.com:8000 open=false> | ||
| # http.port # => 8000 | ||
| # | ||
| # <b>Proxy Using Argument +p_addr+ as a \String</b> | ||
| # | ||
| # When argument +p_addr+ is a string hostname, | ||
| # the returned +http+ has a proxy: | ||
| # | ||
| # http = Net::HTTP.new(hostname, nil, 'proxy.example') | ||
| # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false> | ||
| # http.proxy? # => true | ||
| # http.proxy_address # => "proxy.example" | ||
| # # These use default values. | ||
| # http.proxy_port # => 80 | ||
| # http.proxy_user # => nil | ||
| # http.proxy_pass # => nil | ||
| # | ||
| # The port, username, and password for the proxy may also be given: | ||
| # | ||
| # http = Net::HTTP.new(hostname, nil, 'proxy.example', 8000, 'pname', 'ppass') | ||
| # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false> | ||
| # http.proxy? # => true | ||
| # http.proxy_address # => "proxy.example" | ||
| # http.proxy_port # => 8000 | ||
| # http.proxy_user # => "pname" | ||
| # http.proxy_pass # => "ppass" | ||
| # | ||
| # <b>Proxy Using <tt>ENV['http_proxy']</tt></b> | ||
| # | ||
| # When environment variable <tt>'http_proxy'</tt> | ||
| # is set to a \URI string, | ||
| # the returned +http+ will have that URI as its proxy; | ||
| # note that the \URI string must have a protocol | ||
| # such as <tt>'http'</tt> or <tt>'https'</tt>: | ||
| # | ||
| # ENV['http_proxy'] = 'http://example.com' | ||
| # # => "http://example.com" | ||
| # http = Net::HTTP.new(hostname) | ||
| # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false> | ||
| # http.proxy? # => true | ||
| # http.address # => "jsonplaceholder.typicode.com" | ||
| # http.proxy_address # => "example.com" | ||
| # | ||
| # The \URI string may include proxy username, password, and port number: | ||
| # | ||
| # ENV['http_proxy'] = 'http://pname:[email protected]:8000' | ||
| # # => "http://pname:[email protected]:8000" | ||
| # http = Net::HTTP.new(hostname) | ||
| # # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false> | ||
| # http.proxy_port # => 8000 | ||
| # http.proxy_user # => "pname" | ||
| # http.proxy_pass # => "ppass" | ||
| # | ||
| # <b>Argument +p_no_proxy+</b> | ||
| # | ||
| # You can use argument +p_no_proxy+ to reject certain proxies: | ||
| # | ||
| # - Reject a certain address: | ||
| # | ||
| # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example') | ||
| # http.proxy_address # => nil | ||
| # | ||
| # - Reject certain domains or subdomains: | ||
| # | ||
| # http = Net::HTTP.new('example.com', nil, 'my.proxy.example', 8000, 'pname', 'ppass', 'proxy.example') | ||
| # http.proxy_address # => nil | ||
| # | ||
| # - Reject certain addresses and port combinations: | ||
| # | ||
| # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:1234') | ||
| # http.proxy_address # => "proxy.example" | ||
| # | ||
| # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:8000') | ||
| # http.proxy_address # => nil | ||
| # | ||
| # - Reject a list of the types above delimited using a comma: | ||
| # | ||
| # http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000') | ||
| # http.proxy_address # => nil | ||
| # | ||
| # http = Net::HTTP.new('example.com', nil, 'my.proxy', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000') | ||
| # http.proxy_address # => nil | ||
| # For proxy-defining arguments +p_addr+ through +p_pass+, | ||
peterzhu2118 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| # see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server]. | ||
| # | ||
| def HTTP.new(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, p_no_proxy = nil) | ||
| http = super address, port | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.