File tree Expand file tree Collapse file tree 4 files changed +32
-52
lines changed Expand file tree Collapse file tree 4 files changed +32
-52
lines changed Original file line number Diff line number Diff line change 2
2
/.yardoc
3
3
/_yardoc /
4
4
/coverage /
5
- /doc /
6
5
/pkg /
7
6
/spec /reports /
8
7
/tmp /
Original file line number Diff line number Diff line change
1
+ Examples here assume that <tt>net/http</tt> has been required
2
+ (which also requires +uri+):
3
+
4
+ require 'net/http'
5
+
6
+ Many code examples here use these example websites:
7
+
8
+ - https://jsonplaceholder.typicode.com.
9
+ - http://example.com.
10
+
11
+ Some examples also assume these variables:
12
+
13
+ uri = URI('https://jsonplaceholder.typicode.com')
14
+ uri.freeze # Examples may not modify.
15
+ hostname = uri.hostname # => "jsonplaceholder.typicode.com"
16
+ port = uri.port # => 443
17
+
18
+ So that example requests may be written as:
19
+
20
+ Net::HTTP.get(uri)
21
+ Net::HTTP.get(hostname, '/index.html')
22
+ Net::HTTP.start(hostname) do |http|
23
+ http.get('/todos/1')
24
+ http.get('/todos/2')
25
+ end
26
+
27
+ An example that needs a modified URI first duplicates +uri+, then modifies the duplicate:
28
+
29
+ _uri = uri.dup
30
+ _uri.path = '/todos/1'
Original file line number Diff line number Diff line change @@ -98,36 +98,7 @@ class HTTPHeaderSyntaxError < StandardError; end
98
98
#
99
99
# == About the Examples
100
100
#
101
- # Examples here assume that <tt>net/http</tt> has been required
102
- # (which also requires +uri+):
103
- #
104
- # require 'net/http'
105
- #
106
- # Many code examples here use these example websites:
107
- #
108
- # - https://jsonplaceholder.typicode.com.
109
- # - http://example.com.
110
- #
111
- # Some examples also assume these variables:
112
- #
113
- # uri = URI('https://jsonplaceholder.typicode.com')
114
- # uri.freeze # Examples may not modify.
115
- # hostname = uri.hostname # => "jsonplaceholder.typicode.com"
116
- # port = uri.port # => 443
117
- #
118
- # So that example requests may be written as:
119
- #
120
- # Net::HTTP.get(uri)
121
- # Net::HTTP.get(hostname, '/index.html')
122
- # Net::HTTP.start(hostname) do |http|
123
- # http.get('/todos/1')
124
- # http.get('/todos/2')
125
- # end
126
- #
127
- # An example that needs a modified URI first duplicates +uri+, then modifies:
128
- #
129
- # _uri = uri.dup
130
- # _uri.path = '/todos/1'
101
+ # :include: doc/net-http/examples.rdoc
131
102
#
132
103
# == URIs
133
104
#
Original file line number Diff line number Diff line change 4
4
#
5
5
# == About the Examples
6
6
#
7
- # Examples here assume that <tt>net/http</tt> has been required
8
- # (which also requires +uri+):
9
- #
10
- # require 'net/http'
11
- #
12
- # Many code examples here use these example websites:
13
- #
14
- # - https://jsonplaceholder.typicode.com.
15
- # - http://example.com.
16
- #
17
- # Some examples also assume these variables:
18
- #
19
- # uri = URI('https://jsonplaceholder.typicode.com')
20
- # uri.freeze # Examples may not modify.
21
- # hostname = uri.hostname # => "jsonplaceholder.typicode.com"
22
- # port = uri.port # => 443
23
- #
24
- # An example that needs a modified URI first duplicates +uri+, then modifies:
25
- #
26
- # _uri = uri.dup
27
- # _uri.path = '/todos/1'
7
+ # :include: doc/net-http/examples.rdoc
28
8
#
29
9
# == Returned Responses
30
10
#
You can’t perform that action at this time.
0 commit comments