Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
30 changes: 30 additions & 0 deletions doc/net-http/examples.rdoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
Examples here assume that <tt>net/http</tt> has been required
(which also requires +uri+):

require 'net/http'

Many code examples here use these example websites:

- https://jsonplaceholder.typicode.com.
- http://example.com.

Some examples also assume these variables:

uri = URI('https://jsonplaceholder.typicode.com')
uri.freeze # Examples may not modify.
hostname = uri.hostname # => "jsonplaceholder.typicode.com"
port = uri.port # => 443

So that example requests may be written as:

Net::HTTP.get(uri)
Net::HTTP.get(hostname, '/index.html')
Net::HTTP.start(hostname) do |http|
http.get('/todos/1')
http.get('/todos/2')
end

An example that needs a modified URI first duplicates +uri+, then modifies the duplicate:

_uri = uri.dup
_uri.path = '/todos/1'
31 changes: 1 addition & 30 deletions lib/net/http.rb
Original file line number Diff line number Diff line change
Expand Up @@ -98,36 +98,7 @@ class HTTPHeaderSyntaxError < StandardError; end
#
# == About the Examples
#
# Examples here assume that <tt>net/http</tt> has been required
# (which also requires +uri+):
#
# require 'net/http'
#
# Many code examples here use these example websites:
#
# - https://jsonplaceholder.typicode.com.
# - http://example.com.
#
# Some examples also assume these variables:
#
# uri = URI('https://jsonplaceholder.typicode.com')
# uri.freeze # Examples may not modify.
# hostname = uri.hostname # => "jsonplaceholder.typicode.com"
# port = uri.port # => 443
#
# So that example requests may be written as:
#
# Net::HTTP.get(uri)
# Net::HTTP.get(hostname, '/index.html')
# Net::HTTP.start(hostname) do |http|
# http.get('/todos/1')
# http.get('/todos/2')
# end
#
# An example that needs a modified URI first duplicates +uri+, then modifies:
#
# _uri = uri.dup
# _uri.path = '/todos/1'
# :include: doc/net-http/examples.rdoc
#
# == URIs
#
Expand Down
22 changes: 1 addition & 21 deletions lib/net/http/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,7 @@
#
# == About the Examples
#
# Examples here assume that <tt>net/http</tt> has been required
# (which also requires +uri+):
#
# require 'net/http'
#
# Many code examples here use these example websites:
#
# - https://jsonplaceholder.typicode.com.
# - http://example.com.
#
# Some examples also assume these variables:
#
# uri = URI('https://jsonplaceholder.typicode.com')
# uri.freeze # Examples may not modify.
# hostname = uri.hostname # => "jsonplaceholder.typicode.com"
# port = uri.port # => 443
#
# An example that needs a modified URI first duplicates +uri+, then modifies:
#
# _uri = uri.dup
# _uri.path = '/todos/1'
# :include: doc/net-http/examples.rdoc
#
# == Returned Responses
#
Expand Down