lunchmoney 0.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.DS_Store +0 -0
- data/.github/dependabot.yml +18 -0
- data/.github/workflows/build_and_publish_yard_docs.yml +47 -0
- data/.github/workflows/ci.yml +58 -0
- data/.github/workflows/dependabot-rbi-updater.yml +43 -0
- data/.github/workflows/publish_gem.yml +31 -0
- data/.gitignore +62 -0
- data/.rubocop.yml +45 -0
- data/.ruby-version +1 -0
- data/.toys/.toys.rb +10 -0
- data/.toys/ci.rb +22 -0
- data/.toys/rbi.rb +60 -0
- data/.toys/rubocop.rb +10 -0
- data/.toys/spoom.rb +15 -0
- data/.toys/typecheck.rb +5 -0
- data/.yardopts +2 -0
- data/Appraisals +22 -0
- data/Gemfile +25 -0
- data/Gemfile.lock +174 -0
- data/LICENSE +21 -0
- data/README.md +57 -0
- data/bin/console +16 -0
- data/bin/rubocop +27 -0
- data/bin/setup +8 -0
- data/bin/spoom +27 -0
- data/bin/srb +27 -0
- data/bin/tapioca +27 -0
- data/bin/toys +27 -0
- data/bin/yard +27 -0
- data/lib/lunchmoney/api.rb +147 -0
- data/lib/lunchmoney/api_call.rb +109 -0
- data/lib/lunchmoney/assets/asset.rb +89 -0
- data/lib/lunchmoney/assets/asset_calls.rb +96 -0
- data/lib/lunchmoney/budget/budget.rb +74 -0
- data/lib/lunchmoney/budget/budget_calls.rb +82 -0
- data/lib/lunchmoney/budget/config.rb +38 -0
- data/lib/lunchmoney/budget/data.rb +42 -0
- data/lib/lunchmoney/categories/category/category.rb +52 -0
- data/lib/lunchmoney/categories/category/child_category.rb +42 -0
- data/lib/lunchmoney/categories/category_calls.rb +195 -0
- data/lib/lunchmoney/configuration.rb +26 -0
- data/lib/lunchmoney/crypto/crypto/crypto.rb +43 -0
- data/lib/lunchmoney/crypto/crypto/crypto_base.rb +65 -0
- data/lib/lunchmoney/crypto/crypto_calls.rb +49 -0
- data/lib/lunchmoney/data_object.rb +25 -0
- data/lib/lunchmoney/errors.rb +19 -0
- data/lib/lunchmoney/exceptions.rb +19 -0
- data/lib/lunchmoney/plaid_accounts/plaid_account.rb +73 -0
- data/lib/lunchmoney/plaid_accounts/plaid_account_calls.rb +38 -0
- data/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense.rb +65 -0
- data/lib/lunchmoney/recurring_expenses/recurring_expense/recurring_expense_base.rb +29 -0
- data/lib/lunchmoney/recurring_expenses/recurring_expense_calls.rb +28 -0
- data/lib/lunchmoney/tags/tag/tag.rb +20 -0
- data/lib/lunchmoney/tags/tag/tag_base.rb +21 -0
- data/lib/lunchmoney/tags/tag_calls.rb +20 -0
- data/lib/lunchmoney/transactions/transaction/child_transaction.rb +31 -0
- data/lib/lunchmoney/transactions/transaction/split.rb +24 -0
- data/lib/lunchmoney/transactions/transaction/transaction.rb +156 -0
- data/lib/lunchmoney/transactions/transaction/transaction_base.rb +52 -0
- data/lib/lunchmoney/transactions/transaction/transaction_modification_base.rb +30 -0
- data/lib/lunchmoney/transactions/transaction/update_transaction.rb +43 -0
- data/lib/lunchmoney/transactions/transaction_calls.rb +218 -0
- data/lib/lunchmoney/user/user.rb +36 -0
- data/lib/lunchmoney/user/user_calls.rb +19 -0
- data/lib/lunchmoney/validators.rb +43 -0
- data/lib/lunchmoney/version.rb +7 -0
- data/lib/lunchmoney.rb +54 -0
- data/lunchmoney.gemspec +34 -0
- data/sorbet/config +5 -0
- data/sorbet/rbi/annotations/.gitattributes +1 -0
- data/sorbet/rbi/annotations/activesupport.rbi +410 -0
- data/sorbet/rbi/annotations/faraday.rbi +17 -0
- data/sorbet/rbi/annotations/mocha.rbi +34 -0
- data/sorbet/rbi/annotations/rainbow.rbi +269 -0
- data/sorbet/rbi/annotations/webmock.rbi +9 -0
- data/sorbet/rbi/dsl/.gitattributes +1 -0
- data/sorbet/rbi/dsl/active_support/callbacks.rbi +22 -0
- data/sorbet/rbi/gems/.gitattributes +1 -0
- data/sorbet/rbi/gems/activesupport@7.1.3.rbi +18004 -0
- data/sorbet/rbi/gems/addressable@2.8.6.rbi +1993 -0
- data/sorbet/rbi/gems/appraisal@2.5.0.rbi +621 -0
- data/sorbet/rbi/gems/ast@2.4.2.rbi +584 -0
- data/sorbet/rbi/gems/base64@0.2.0.rbi +508 -0
- data/sorbet/rbi/gems/bigdecimal@3.1.6.rbi +77 -0
- data/sorbet/rbi/gems/coderay@1.1.3.rbi +3426 -0
- data/sorbet/rbi/gems/concurrent-ruby@1.2.3.rbi +11590 -0
- data/sorbet/rbi/gems/connection_pool@2.4.1.rbi +8 -0
- data/sorbet/rbi/gems/crack@0.4.5.rbi +144 -0
- data/sorbet/rbi/gems/dotenv@2.8.1.rbi +234 -0
- data/sorbet/rbi/gems/drb@2.2.0.rbi +1346 -0
- data/sorbet/rbi/gems/erubi@1.12.0.rbi +145 -0
- data/sorbet/rbi/gems/faraday-net_http@3.1.0.rbi +146 -0
- data/sorbet/rbi/gems/faraday@2.9.0.rbi +2911 -0
- data/sorbet/rbi/gems/hashdiff@1.1.0.rbi +352 -0
- data/sorbet/rbi/gems/i18n@1.14.1.rbi +2325 -0
- data/sorbet/rbi/gems/json@2.7.1.rbi +1561 -0
- data/sorbet/rbi/gems/language_server-protocol@3.17.0.3.rbi +14237 -0
- data/sorbet/rbi/gems/method_source@1.0.0.rbi +272 -0
- data/sorbet/rbi/gems/minitest@5.21.2.rbi +2197 -0
- data/sorbet/rbi/gems/mocha@2.1.0.rbi +3934 -0
- data/sorbet/rbi/gems/mutex_m@0.2.0.rbi +93 -0
- data/sorbet/rbi/gems/net-http@0.4.1.rbi +4068 -0
- data/sorbet/rbi/gems/netrc@0.11.0.rbi +158 -0
- data/sorbet/rbi/gems/parallel@1.24.0.rbi +280 -0
- data/sorbet/rbi/gems/parser@3.3.0.5.rbi +5472 -0
- data/sorbet/rbi/gems/prettier_print@1.2.1.rbi +951 -0
- data/sorbet/rbi/gems/prism@0.19.0.rbi +29883 -0
- data/sorbet/rbi/gems/pry-sorbet@0.2.1.rbi +966 -0
- data/sorbet/rbi/gems/pry@0.14.2.rbi +10077 -0
- data/sorbet/rbi/gems/public_suffix@5.0.4.rbi +935 -0
- data/sorbet/rbi/gems/racc@1.7.3.rbi +161 -0
- data/sorbet/rbi/gems/rack@3.0.8.rbi +5183 -0
- data/sorbet/rbi/gems/rainbow@3.1.1.rbi +402 -0
- data/sorbet/rbi/gems/rake@13.1.0.rbi +3027 -0
- data/sorbet/rbi/gems/rbi@0.1.6.rbi +2922 -0
- data/sorbet/rbi/gems/regexp_parser@2.9.0.rbi +3771 -0
- data/sorbet/rbi/gems/rexml@3.2.6.rbi +4781 -0
- data/sorbet/rbi/gems/rubocop-ast@1.30.0.rbi +7117 -0
- data/sorbet/rbi/gems/rubocop-minitest@0.34.5.rbi +2576 -0
- data/sorbet/rbi/gems/rubocop-rails@2.23.1.rbi +9175 -0
- data/sorbet/rbi/gems/rubocop-shopify@2.14.0.rbi +8 -0
- data/sorbet/rbi/gems/rubocop-sorbet@0.7.6.rbi +1510 -0
- data/sorbet/rbi/gems/rubocop@1.60.1.rbi +57356 -0
- data/sorbet/rbi/gems/ruby-progressbar@1.13.0.rbi +1317 -0
- data/sorbet/rbi/gems/ruby2_keywords@0.0.5.rbi +8 -0
- data/sorbet/rbi/gems/spoom@1.2.4.rbi +3777 -0
- data/sorbet/rbi/gems/syntax_tree@6.2.0.rbi +23136 -0
- data/sorbet/rbi/gems/tapioca@0.12.0.rbi +3506 -0
- data/sorbet/rbi/gems/thor@1.3.0.rbi +4312 -0
- data/sorbet/rbi/gems/toys-core@0.15.4.rbi +9462 -0
- data/sorbet/rbi/gems/toys@0.15.4.rbi +243 -0
- data/sorbet/rbi/gems/tzinfo@2.0.6.rbi +5917 -0
- data/sorbet/rbi/gems/unicode-display_width@2.5.0.rbi +65 -0
- data/sorbet/rbi/gems/uri@0.13.0.rbi +2327 -0
- data/sorbet/rbi/gems/vcr@6.2.0.rbi +3036 -0
- data/sorbet/rbi/gems/webmock@3.19.1.rbi +1768 -0
- data/sorbet/rbi/gems/yard-sorbet@0.8.1.rbi +428 -0
- data/sorbet/rbi/gems/yard@0.9.34.rbi +18084 -0
- data/sorbet/shims/module.rbi +6 -0
- data/sorbet/tapioca/require.rb +10 -0
- metadata +228 -0
@@ -0,0 +1,4068 @@
|
|
1
|
+
# typed: false
|
2
|
+
|
3
|
+
# DO NOT EDIT MANUALLY
|
4
|
+
# This is an autogenerated file for types exported from the `net-http` gem.
|
5
|
+
# Please instead update this file by running `bin/tapioca gem net-http`.
|
6
|
+
|
7
|
+
# \Class \Net::HTTP provides a rich library that implements the client
|
8
|
+
# in a client-server model that uses the \HTTP request-response protocol.
|
9
|
+
# For information about \HTTP, see:
|
10
|
+
#
|
11
|
+
# - {Hypertext Transfer Protocol}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol].
|
12
|
+
# - {Technical overview}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Technical_overview].
|
13
|
+
#
|
14
|
+
# == About the Examples
|
15
|
+
#
|
16
|
+
# :include: doc/net-http/examples.rdoc
|
17
|
+
#
|
18
|
+
# == Strategies
|
19
|
+
#
|
20
|
+
# - If you will make only a few GET requests,
|
21
|
+
# consider using {OpenURI}[https://docs.ruby-lang.org/en/master/OpenURI.html].
|
22
|
+
# - If you will make only a few requests of all kinds,
|
23
|
+
# consider using the various singleton convenience methods in this class.
|
24
|
+
# Each of the following methods automatically starts and finishes
|
25
|
+
# a {session}[rdoc-ref:Net::HTTP@Sessions] that sends a single request:
|
26
|
+
#
|
27
|
+
# # Return string response body.
|
28
|
+
# Net::HTTP.get(hostname, path)
|
29
|
+
# Net::HTTP.get(uri)
|
30
|
+
#
|
31
|
+
# # Write string response body to $stdout.
|
32
|
+
# Net::HTTP.get_print(hostname, path)
|
33
|
+
# Net::HTTP.get_print(uri)
|
34
|
+
#
|
35
|
+
# # Return response as Net::HTTPResponse object.
|
36
|
+
# Net::HTTP.get_response(hostname, path)
|
37
|
+
# Net::HTTP.get_response(uri)
|
38
|
+
# data = '{"title": "foo", "body": "bar", "userId": 1}'
|
39
|
+
# Net::HTTP.post(uri, data)
|
40
|
+
# params = {title: 'foo', body: 'bar', userId: 1}
|
41
|
+
# Net::HTTP.post_form(uri, params)
|
42
|
+
#
|
43
|
+
# - If performance is important, consider using sessions, which lower request overhead.
|
44
|
+
# This {session}[rdoc-ref:Net::HTTP@Sessions] has multiple requests for
|
45
|
+
# {HTTP methods}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods]
|
46
|
+
# and {WebDAV methods}[https://en.wikipedia.org/wiki/WebDAV#Implementation]:
|
47
|
+
#
|
48
|
+
# Net::HTTP.start(hostname) do |http|
|
49
|
+
# # Session started automatically before block execution.
|
50
|
+
# http.get(path)
|
51
|
+
# http.head(path)
|
52
|
+
# body = 'Some text'
|
53
|
+
# http.post(path, body) # Can also have a block.
|
54
|
+
# http.put(path, body)
|
55
|
+
# http.delete(path)
|
56
|
+
# http.options(path)
|
57
|
+
# http.trace(path)
|
58
|
+
# http.patch(path, body) # Can also have a block.
|
59
|
+
# http.copy(path)
|
60
|
+
# http.lock(path, body)
|
61
|
+
# http.mkcol(path, body)
|
62
|
+
# http.move(path)
|
63
|
+
# http.propfind(path, body)
|
64
|
+
# http.proppatch(path, body)
|
65
|
+
# http.unlock(path, body)
|
66
|
+
# # Session finished automatically at block exit.
|
67
|
+
# end
|
68
|
+
#
|
69
|
+
# The methods cited above are convenience methods that, via their few arguments,
|
70
|
+
# allow minimal control over the requests.
|
71
|
+
# For greater control, consider using {request objects}[rdoc-ref:Net::HTTPRequest].
|
72
|
+
#
|
73
|
+
# == URIs
|
74
|
+
#
|
75
|
+
# On the internet, a URI
|
76
|
+
# ({Universal Resource Identifier}[https://en.wikipedia.org/wiki/Uniform_Resource_Identifier])
|
77
|
+
# is a string that identifies a particular resource.
|
78
|
+
# It consists of some or all of: scheme, hostname, path, query, and fragment;
|
79
|
+
# see {URI syntax}[https://en.wikipedia.org/wiki/Uniform_Resource_Identifier#Syntax].
|
80
|
+
#
|
81
|
+
# A Ruby {URI::Generic}[https://docs.ruby-lang.org/en/master/URI/Generic.html] object
|
82
|
+
# represents an internet URI.
|
83
|
+
# It provides, among others, methods
|
84
|
+
# +scheme+, +hostname+, +path+, +query+, and +fragment+.
|
85
|
+
#
|
86
|
+
# === Schemes
|
87
|
+
#
|
88
|
+
# An internet \URI has
|
89
|
+
# a {scheme}[https://en.wikipedia.org/wiki/List_of_URI_schemes].
|
90
|
+
#
|
91
|
+
# The two schemes supported in \Net::HTTP are <tt>'https'</tt> and <tt>'http'</tt>:
|
92
|
+
#
|
93
|
+
# uri.scheme # => "https"
|
94
|
+
# URI('http://example.com').scheme # => "http"
|
95
|
+
#
|
96
|
+
# === Hostnames
|
97
|
+
#
|
98
|
+
# A hostname identifies a server (host) to which requests may be sent:
|
99
|
+
#
|
100
|
+
# hostname = uri.hostname # => "jsonplaceholder.typicode.com"
|
101
|
+
# Net::HTTP.start(hostname) do |http|
|
102
|
+
# # Some HTTP stuff.
|
103
|
+
# end
|
104
|
+
#
|
105
|
+
# === Paths
|
106
|
+
#
|
107
|
+
# A host-specific path identifies a resource on the host:
|
108
|
+
#
|
109
|
+
# _uri = uri.dup
|
110
|
+
# _uri.path = '/todos/1'
|
111
|
+
# hostname = _uri.hostname
|
112
|
+
# path = _uri.path
|
113
|
+
# Net::HTTP.get(hostname, path)
|
114
|
+
#
|
115
|
+
# === Queries
|
116
|
+
#
|
117
|
+
# A host-specific query adds name/value pairs to the URI:
|
118
|
+
#
|
119
|
+
# _uri = uri.dup
|
120
|
+
# params = {userId: 1, completed: false}
|
121
|
+
# _uri.query = URI.encode_www_form(params)
|
122
|
+
# _uri # => #<URI::HTTPS https://jsonplaceholder.typicode.com?userId=1&completed=false>
|
123
|
+
# Net::HTTP.get(_uri)
|
124
|
+
#
|
125
|
+
# === Fragments
|
126
|
+
#
|
127
|
+
# A {URI fragment}[https://en.wikipedia.org/wiki/URI_fragment] has no effect
|
128
|
+
# in \Net::HTTP;
|
129
|
+
# the same data is returned, regardless of whether a fragment is included.
|
130
|
+
#
|
131
|
+
# == Request Headers
|
132
|
+
#
|
133
|
+
# Request headers may be used to pass additional information to the host,
|
134
|
+
# similar to arguments passed in a method call;
|
135
|
+
# each header is a name/value pair.
|
136
|
+
#
|
137
|
+
# Each of the \Net::HTTP methods that sends a request to the host
|
138
|
+
# has optional argument +headers+,
|
139
|
+
# where the headers are expressed as a hash of field-name/value pairs:
|
140
|
+
#
|
141
|
+
# headers = {Accept: 'application/json', Connection: 'Keep-Alive'}
|
142
|
+
# Net::HTTP.get(uri, headers)
|
143
|
+
#
|
144
|
+
# See lists of both standard request fields and common request fields at
|
145
|
+
# {Request Fields}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields].
|
146
|
+
# A host may also accept other custom fields.
|
147
|
+
#
|
148
|
+
# == \HTTP Sessions
|
149
|
+
#
|
150
|
+
# A _session_ is a connection between a server (host) and a client that:
|
151
|
+
#
|
152
|
+
# - Is begun by instance method Net::HTTP#start.
|
153
|
+
# - May contain any number of requests.
|
154
|
+
# - Is ended by instance method Net::HTTP#finish.
|
155
|
+
#
|
156
|
+
# See example sessions at {Strategies}[rdoc-ref:Net::HTTP@Strategies].
|
157
|
+
#
|
158
|
+
# === Session Using \Net::HTTP.start
|
159
|
+
#
|
160
|
+
# If you have many requests to make to a single host (and port),
|
161
|
+
# consider using singleton method Net::HTTP.start with a block;
|
162
|
+
# the method handles the session automatically by:
|
163
|
+
#
|
164
|
+
# - Calling #start before block execution.
|
165
|
+
# - Executing the block.
|
166
|
+
# - Calling #finish after block execution.
|
167
|
+
#
|
168
|
+
# In the block, you can use these instance methods,
|
169
|
+
# each of which that sends a single request:
|
170
|
+
#
|
171
|
+
# - {HTTP methods}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods]:
|
172
|
+
#
|
173
|
+
# - #get, #request_get: GET.
|
174
|
+
# - #head, #request_head: HEAD.
|
175
|
+
# - #post, #request_post: POST.
|
176
|
+
# - #delete: DELETE.
|
177
|
+
# - #options: OPTIONS.
|
178
|
+
# - #trace: TRACE.
|
179
|
+
# - #patch: PATCH.
|
180
|
+
#
|
181
|
+
# - {WebDAV methods}[https://en.wikipedia.org/wiki/WebDAV#Implementation]:
|
182
|
+
#
|
183
|
+
# - #copy: COPY.
|
184
|
+
# - #lock: LOCK.
|
185
|
+
# - #mkcol: MKCOL.
|
186
|
+
# - #move: MOVE.
|
187
|
+
# - #propfind: PROPFIND.
|
188
|
+
# - #proppatch: PROPPATCH.
|
189
|
+
# - #unlock: UNLOCK.
|
190
|
+
#
|
191
|
+
# === Session Using \Net::HTTP.start and \Net::HTTP.finish
|
192
|
+
#
|
193
|
+
# You can manage a session manually using methods #start and #finish:
|
194
|
+
#
|
195
|
+
# http = Net::HTTP.new(hostname)
|
196
|
+
# http.start
|
197
|
+
# http.get('/todos/1')
|
198
|
+
# http.get('/todos/2')
|
199
|
+
# http.delete('/posts/1')
|
200
|
+
# http.finish # Needed to free resources.
|
201
|
+
#
|
202
|
+
# === Single-Request Session
|
203
|
+
#
|
204
|
+
# Certain convenience methods automatically handle a session by:
|
205
|
+
#
|
206
|
+
# - Creating an \HTTP object
|
207
|
+
# - Starting a session.
|
208
|
+
# - Sending a single request.
|
209
|
+
# - Finishing the session.
|
210
|
+
# - Destroying the object.
|
211
|
+
#
|
212
|
+
# Such methods that send GET requests:
|
213
|
+
#
|
214
|
+
# - ::get: Returns the string response body.
|
215
|
+
# - ::get_print: Writes the string response body to $stdout.
|
216
|
+
# - ::get_response: Returns a Net::HTTPResponse object.
|
217
|
+
#
|
218
|
+
# Such methods that send POST requests:
|
219
|
+
#
|
220
|
+
# - ::post: Posts data to the host.
|
221
|
+
# - ::post_form: Posts form data to the host.
|
222
|
+
#
|
223
|
+
# == \HTTP Requests and Responses
|
224
|
+
#
|
225
|
+
# Many of the methods above are convenience methods,
|
226
|
+
# each of which sends a request and returns a string
|
227
|
+
# without directly using \Net::HTTPRequest and \Net::HTTPResponse objects.
|
228
|
+
#
|
229
|
+
# You can, however, directly create a request object, send the request,
|
230
|
+
# and retrieve the response object; see:
|
231
|
+
#
|
232
|
+
# - Net::HTTPRequest.
|
233
|
+
# - Net::HTTPResponse.
|
234
|
+
#
|
235
|
+
# == Following Redirection
|
236
|
+
#
|
237
|
+
# Each returned response is an instance of a subclass of Net::HTTPResponse.
|
238
|
+
# See the {response class hierarchy}[rdoc-ref:Net::HTTPResponse@Response+Subclasses].
|
239
|
+
#
|
240
|
+
# In particular, class Net::HTTPRedirection is the parent
|
241
|
+
# of all redirection classes.
|
242
|
+
# This allows you to craft a case statement to handle redirections properly:
|
243
|
+
#
|
244
|
+
# def fetch(uri, limit = 10)
|
245
|
+
# # You should choose a better exception.
|
246
|
+
# raise ArgumentError, 'Too many HTTP redirects' if limit == 0
|
247
|
+
#
|
248
|
+
# res = Net::HTTP.get_response(URI(uri))
|
249
|
+
# case res
|
250
|
+
# when Net::HTTPSuccess # Any success class.
|
251
|
+
# res
|
252
|
+
# when Net::HTTPRedirection # Any redirection class.
|
253
|
+
# location = res['Location']
|
254
|
+
# warn "Redirected to #{location}"
|
255
|
+
# fetch(location, limit - 1)
|
256
|
+
# else # Any other class.
|
257
|
+
# res.value
|
258
|
+
# end
|
259
|
+
# end
|
260
|
+
#
|
261
|
+
# fetch(uri)
|
262
|
+
#
|
263
|
+
# == Basic Authentication
|
264
|
+
#
|
265
|
+
# Basic authentication is performed according to
|
266
|
+
# {RFC2617}[http://www.ietf.org/rfc/rfc2617.txt]:
|
267
|
+
#
|
268
|
+
# req = Net::HTTP::Get.new(uri)
|
269
|
+
# req.basic_auth('user', 'pass')
|
270
|
+
# res = Net::HTTP.start(hostname) do |http|
|
271
|
+
# http.request(req)
|
272
|
+
# end
|
273
|
+
#
|
274
|
+
# == Streaming Response Bodies
|
275
|
+
#
|
276
|
+
# By default \Net::HTTP reads an entire response into memory. If you are
|
277
|
+
# handling large files or wish to implement a progress bar you can instead
|
278
|
+
# stream the body directly to an IO.
|
279
|
+
#
|
280
|
+
# Net::HTTP.start(hostname) do |http|
|
281
|
+
# req = Net::HTTP::Get.new(uri)
|
282
|
+
# http.request(req) do |res|
|
283
|
+
# open('t.tmp', 'w') do |f|
|
284
|
+
# res.read_body do |chunk|
|
285
|
+
# f.write chunk
|
286
|
+
# end
|
287
|
+
# end
|
288
|
+
# end
|
289
|
+
# end
|
290
|
+
#
|
291
|
+
# == HTTPS
|
292
|
+
#
|
293
|
+
# HTTPS is enabled for an \HTTP connection by Net::HTTP#use_ssl=:
|
294
|
+
#
|
295
|
+
# Net::HTTP.start(hostname, :use_ssl => true) do |http|
|
296
|
+
# req = Net::HTTP::Get.new(uri)
|
297
|
+
# res = http.request(req)
|
298
|
+
# end
|
299
|
+
#
|
300
|
+
# Or if you simply want to make a GET request, you may pass in a URI
|
301
|
+
# object that has an \HTTPS URL. \Net::HTTP automatically turns on TLS
|
302
|
+
# verification if the URI object has a 'https' URI scheme:
|
303
|
+
#
|
304
|
+
# uri # => #<URI::HTTPS https://jsonplaceholder.typicode.com/>
|
305
|
+
# Net::HTTP.get(uri)
|
306
|
+
#
|
307
|
+
# == Proxy Server
|
308
|
+
#
|
309
|
+
# An \HTTP object can have
|
310
|
+
# a {proxy server}[https://en.wikipedia.org/wiki/Proxy_server].
|
311
|
+
#
|
312
|
+
# You can create an \HTTP object with a proxy server
|
313
|
+
# using method Net::HTTP.new or method Net::HTTP.start.
|
314
|
+
#
|
315
|
+
# The proxy may be defined either by argument +p_addr+
|
316
|
+
# or by environment variable <tt>'http_proxy'</tt>.
|
317
|
+
#
|
318
|
+
# === Proxy Using Argument +p_addr+ as a \String
|
319
|
+
#
|
320
|
+
# When argument +p_addr+ is a string hostname,
|
321
|
+
# the returned +http+ has the given host as its proxy:
|
322
|
+
#
|
323
|
+
# http = Net::HTTP.new(hostname, nil, 'proxy.example')
|
324
|
+
# http.proxy? # => true
|
325
|
+
# http.proxy_from_env? # => false
|
326
|
+
# http.proxy_address # => "proxy.example"
|
327
|
+
# # These use default values.
|
328
|
+
# http.proxy_port # => 80
|
329
|
+
# http.proxy_user # => nil
|
330
|
+
# http.proxy_pass # => nil
|
331
|
+
#
|
332
|
+
# The port, username, and password for the proxy may also be given:
|
333
|
+
#
|
334
|
+
# http = Net::HTTP.new(hostname, nil, 'proxy.example', 8000, 'pname', 'ppass')
|
335
|
+
# # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
|
336
|
+
# http.proxy? # => true
|
337
|
+
# http.proxy_from_env? # => false
|
338
|
+
# http.proxy_address # => "proxy.example"
|
339
|
+
# http.proxy_port # => 8000
|
340
|
+
# http.proxy_user # => "pname"
|
341
|
+
# http.proxy_pass # => "ppass"
|
342
|
+
#
|
343
|
+
# === Proxy Using '<tt>ENV['http_proxy']</tt>'
|
344
|
+
#
|
345
|
+
# When environment variable <tt>'http_proxy'</tt>
|
346
|
+
# is set to a \URI string,
|
347
|
+
# the returned +http+ will have the server at that URI as its proxy;
|
348
|
+
# note that the \URI string must have a protocol
|
349
|
+
# such as <tt>'http'</tt> or <tt>'https'</tt>:
|
350
|
+
#
|
351
|
+
# ENV['http_proxy'] = 'http://example.com'
|
352
|
+
# http = Net::HTTP.new(hostname)
|
353
|
+
# http.proxy? # => true
|
354
|
+
# http.proxy_from_env? # => true
|
355
|
+
# http.proxy_address # => "example.com"
|
356
|
+
# # These use default values.
|
357
|
+
# http.proxy_port # => 80
|
358
|
+
# http.proxy_user # => nil
|
359
|
+
# http.proxy_pass # => nil
|
360
|
+
#
|
361
|
+
# The \URI string may include proxy username, password, and port number:
|
362
|
+
#
|
363
|
+
# ENV['http_proxy'] = 'http://pname:ppass@example.com:8000'
|
364
|
+
# http = Net::HTTP.new(hostname)
|
365
|
+
# http.proxy? # => true
|
366
|
+
# http.proxy_from_env? # => true
|
367
|
+
# http.proxy_address # => "example.com"
|
368
|
+
# http.proxy_port # => 8000
|
369
|
+
# http.proxy_user # => "pname"
|
370
|
+
# http.proxy_pass # => "ppass"
|
371
|
+
#
|
372
|
+
# === Filtering Proxies
|
373
|
+
#
|
374
|
+
# With method Net::HTTP.new (but not Net::HTTP.start),
|
375
|
+
# you can use argument +p_no_proxy+ to filter proxies:
|
376
|
+
#
|
377
|
+
# - Reject a certain address:
|
378
|
+
#
|
379
|
+
# http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example')
|
380
|
+
# http.proxy_address # => nil
|
381
|
+
#
|
382
|
+
# - Reject certain domains or subdomains:
|
383
|
+
#
|
384
|
+
# http = Net::HTTP.new('example.com', nil, 'my.proxy.example', 8000, 'pname', 'ppass', 'proxy.example')
|
385
|
+
# http.proxy_address # => nil
|
386
|
+
#
|
387
|
+
# - Reject certain addresses and port combinations:
|
388
|
+
#
|
389
|
+
# http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:1234')
|
390
|
+
# http.proxy_address # => "proxy.example"
|
391
|
+
#
|
392
|
+
# http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'proxy.example:8000')
|
393
|
+
# http.proxy_address # => nil
|
394
|
+
#
|
395
|
+
# - Reject a list of the types above delimited using a comma:
|
396
|
+
#
|
397
|
+
# http = Net::HTTP.new('example.com', nil, 'proxy.example', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000')
|
398
|
+
# http.proxy_address # => nil
|
399
|
+
#
|
400
|
+
# http = Net::HTTP.new('example.com', nil, 'my.proxy', 8000, 'pname', 'ppass', 'my.proxy,proxy.example:8000')
|
401
|
+
# http.proxy_address # => nil
|
402
|
+
#
|
403
|
+
# == Compression and Decompression
|
404
|
+
#
|
405
|
+
# \Net::HTTP does not compress the body of a request before sending.
|
406
|
+
#
|
407
|
+
# By default, \Net::HTTP adds header <tt>'Accept-Encoding'</tt>
|
408
|
+
# to a new {request object}[rdoc-ref:Net::HTTPRequest]:
|
409
|
+
#
|
410
|
+
# Net::HTTP::Get.new(uri)['Accept-Encoding']
|
411
|
+
# # => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
|
412
|
+
#
|
413
|
+
# This requests the server to zip-encode the response body if there is one;
|
414
|
+
# the server is not required to do so.
|
415
|
+
#
|
416
|
+
# \Net::HTTP does not automatically decompress a response body
|
417
|
+
# if the response has header <tt>'Content-Range'</tt>.
|
418
|
+
#
|
419
|
+
# Otherwise decompression (or not) depends on the value of header
|
420
|
+
# {Content-Encoding}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-encoding-response-header]:
|
421
|
+
#
|
422
|
+
# - <tt>'deflate'</tt>, <tt>'gzip'</tt>, or <tt>'x-gzip'</tt>:
|
423
|
+
# decompresses the body and deletes the header.
|
424
|
+
# - <tt>'none'</tt> or <tt>'identity'</tt>:
|
425
|
+
# does not decompress the body, but deletes the header.
|
426
|
+
# - Any other value:
|
427
|
+
# leaves the body and header unchanged.
|
428
|
+
#
|
429
|
+
# == What's Here
|
430
|
+
#
|
431
|
+
# This is a categorized summary of methods and attributes.
|
432
|
+
#
|
433
|
+
# === \Net::HTTP Objects
|
434
|
+
#
|
435
|
+
# - {::new}[rdoc-ref:Net::HTTP.new]:
|
436
|
+
# Creates a new instance.
|
437
|
+
# - {#inspect}[rdoc-ref:Net::HTTP#inspect]:
|
438
|
+
# Returns a string representation of +self+.
|
439
|
+
#
|
440
|
+
# === Sessions
|
441
|
+
#
|
442
|
+
# - {::start}[rdoc-ref:Net::HTTP.start]:
|
443
|
+
# Begins a new session in a new \Net::HTTP object.
|
444
|
+
# - {#started?}[rdoc-ref:Net::HTTP#started?]
|
445
|
+
# (aliased as {#active?}[rdoc-ref:Net::HTTP#active?]):
|
446
|
+
# Returns whether in a session.
|
447
|
+
# - {#finish}[rdoc-ref:Net::HTTP#finish]:
|
448
|
+
# Ends an active session.
|
449
|
+
# - {#start}[rdoc-ref:Net::HTTP#start]:
|
450
|
+
# Begins a new session in an existing \Net::HTTP object (+self+).
|
451
|
+
#
|
452
|
+
# === Connections
|
453
|
+
#
|
454
|
+
# - {:continue_timeout}[rdoc-ref:Net::HTTP#continue_timeout]:
|
455
|
+
# Returns the continue timeout.
|
456
|
+
# - {#continue_timeout=}[rdoc-ref:Net::HTTP#continue_timeout=]:
|
457
|
+
# Sets the continue timeout seconds.
|
458
|
+
# - {:keep_alive_timeout}[rdoc-ref:Net::HTTP#keep_alive_timeout]:
|
459
|
+
# Returns the keep-alive timeout.
|
460
|
+
# - {:keep_alive_timeout=}[rdoc-ref:Net::HTTP#keep_alive_timeout=]:
|
461
|
+
# Sets the keep-alive timeout.
|
462
|
+
# - {:max_retries}[rdoc-ref:Net::HTTP#max_retries]:
|
463
|
+
# Returns the maximum retries.
|
464
|
+
# - {#max_retries=}[rdoc-ref:Net::HTTP#max_retries=]:
|
465
|
+
# Sets the maximum retries.
|
466
|
+
# - {:open_timeout}[rdoc-ref:Net::HTTP#open_timeout]:
|
467
|
+
# Returns the open timeout.
|
468
|
+
# - {:open_timeout=}[rdoc-ref:Net::HTTP#open_timeout=]:
|
469
|
+
# Sets the open timeout.
|
470
|
+
# - {:read_timeout}[rdoc-ref:Net::HTTP#read_timeout]:
|
471
|
+
# Returns the open timeout.
|
472
|
+
# - {:read_timeout=}[rdoc-ref:Net::HTTP#read_timeout=]:
|
473
|
+
# Sets the read timeout.
|
474
|
+
# - {:ssl_timeout}[rdoc-ref:Net::HTTP#ssl_timeout]:
|
475
|
+
# Returns the ssl timeout.
|
476
|
+
# - {:ssl_timeout=}[rdoc-ref:Net::HTTP#ssl_timeout=]:
|
477
|
+
# Sets the ssl timeout.
|
478
|
+
# - {:write_timeout}[rdoc-ref:Net::HTTP#write_timeout]:
|
479
|
+
# Returns the write timeout.
|
480
|
+
# - {write_timeout=}[rdoc-ref:Net::HTTP#write_timeout=]:
|
481
|
+
# Sets the write timeout.
|
482
|
+
#
|
483
|
+
# === Requests
|
484
|
+
#
|
485
|
+
# - {::get}[rdoc-ref:Net::HTTP.get]:
|
486
|
+
# Sends a GET request and returns the string response body.
|
487
|
+
# - {::get_print}[rdoc-ref:Net::HTTP.get_print]:
|
488
|
+
# Sends a GET request and write the string response body to $stdout.
|
489
|
+
# - {::get_response}[rdoc-ref:Net::HTTP.get_response]:
|
490
|
+
# Sends a GET request and returns a response object.
|
491
|
+
# - {::post_form}[rdoc-ref:Net::HTTP.post_form]:
|
492
|
+
# Sends a POST request with form data and returns a response object.
|
493
|
+
# - {::post}[rdoc-ref:Net::HTTP.post]:
|
494
|
+
# Sends a POST request with data and returns a response object.
|
495
|
+
# - {#copy}[rdoc-ref:Net::HTTP#copy]:
|
496
|
+
# Sends a COPY request and returns a response object.
|
497
|
+
# - {#delete}[rdoc-ref:Net::HTTP#delete]:
|
498
|
+
# Sends a DELETE request and returns a response object.
|
499
|
+
# - {#get}[rdoc-ref:Net::HTTP#get]:
|
500
|
+
# Sends a GET request and returns a response object.
|
501
|
+
# - {#head}[rdoc-ref:Net::HTTP#head]:
|
502
|
+
# Sends a HEAD request and returns a response object.
|
503
|
+
# - {#lock}[rdoc-ref:Net::HTTP#lock]:
|
504
|
+
# Sends a LOCK request and returns a response object.
|
505
|
+
# - {#mkcol}[rdoc-ref:Net::HTTP#mkcol]:
|
506
|
+
# Sends a MKCOL request and returns a response object.
|
507
|
+
# - {#move}[rdoc-ref:Net::HTTP#move]:
|
508
|
+
# Sends a MOVE request and returns a response object.
|
509
|
+
# - {#options}[rdoc-ref:Net::HTTP#options]:
|
510
|
+
# Sends a OPTIONS request and returns a response object.
|
511
|
+
# - {#patch}[rdoc-ref:Net::HTTP#patch]:
|
512
|
+
# Sends a PATCH request and returns a response object.
|
513
|
+
# - {#post}[rdoc-ref:Net::HTTP#post]:
|
514
|
+
# Sends a POST request and returns a response object.
|
515
|
+
# - {#propfind}[rdoc-ref:Net::HTTP#propfind]:
|
516
|
+
# Sends a PROPFIND request and returns a response object.
|
517
|
+
# - {#proppatch}[rdoc-ref:Net::HTTP#proppatch]:
|
518
|
+
# Sends a PROPPATCH request and returns a response object.
|
519
|
+
# - {#put}[rdoc-ref:Net::HTTP#put]:
|
520
|
+
# Sends a PUT request and returns a response object.
|
521
|
+
# - {#request}[rdoc-ref:Net::HTTP#request]:
|
522
|
+
# Sends a request and returns a response object.
|
523
|
+
# - {#request_get}[rdoc-ref:Net::HTTP#request_get]
|
524
|
+
# (aliased as {#get2}[rdoc-ref:Net::HTTP#get2]):
|
525
|
+
# Sends a GET request and forms a response object;
|
526
|
+
# if a block given, calls the block with the object,
|
527
|
+
# otherwise returns the object.
|
528
|
+
# - {#request_head}[rdoc-ref:Net::HTTP#request_head]
|
529
|
+
# (aliased as {#head2}[rdoc-ref:Net::HTTP#head2]):
|
530
|
+
# Sends a HEAD request and forms a response object;
|
531
|
+
# if a block given, calls the block with the object,
|
532
|
+
# otherwise returns the object.
|
533
|
+
# - {#request_post}[rdoc-ref:Net::HTTP#request_post]
|
534
|
+
# (aliased as {#post2}[rdoc-ref:Net::HTTP#post2]):
|
535
|
+
# Sends a POST request and forms a response object;
|
536
|
+
# if a block given, calls the block with the object,
|
537
|
+
# otherwise returns the object.
|
538
|
+
# - {#send_request}[rdoc-ref:Net::HTTP#send_request]:
|
539
|
+
# Sends a request and returns a response object.
|
540
|
+
# - {#trace}[rdoc-ref:Net::HTTP#trace]:
|
541
|
+
# Sends a TRACE request and returns a response object.
|
542
|
+
# - {#unlock}[rdoc-ref:Net::HTTP#unlock]:
|
543
|
+
# Sends an UNLOCK request and returns a response object.
|
544
|
+
#
|
545
|
+
# === Responses
|
546
|
+
#
|
547
|
+
# - {:close_on_empty_response}[rdoc-ref:Net::HTTP#close_on_empty_response]:
|
548
|
+
# Returns whether to close connection on empty response.
|
549
|
+
# - {:close_on_empty_response=}[rdoc-ref:Net::HTTP#close_on_empty_response=]:
|
550
|
+
# Sets whether to close connection on empty response.
|
551
|
+
# - {:ignore_eof}[rdoc-ref:Net::HTTP#ignore_eof]:
|
552
|
+
# Returns whether to ignore end-of-file when reading a response body
|
553
|
+
# with <tt>Content-Length</tt> headers.
|
554
|
+
# - {:ignore_eof=}[rdoc-ref:Net::HTTP#ignore_eof=]:
|
555
|
+
# Sets whether to ignore end-of-file when reading a response body
|
556
|
+
# with <tt>Content-Length</tt> headers.
|
557
|
+
# - {:response_body_encoding}[rdoc-ref:Net::HTTP#response_body_encoding]:
|
558
|
+
# Returns the encoding to use for the response body.
|
559
|
+
# - {#response_body_encoding=}[rdoc-ref:Net::HTTP#response_body_encoding=]:
|
560
|
+
# Sets the response body encoding.
|
561
|
+
#
|
562
|
+
# === Proxies
|
563
|
+
#
|
564
|
+
# - {:proxy_address}[rdoc-ref:Net::HTTP#proxy_address]:
|
565
|
+
# Returns the proxy address.
|
566
|
+
# - {:proxy_address=}[rdoc-ref:Net::HTTP#proxy_address=]:
|
567
|
+
# Sets the proxy address.
|
568
|
+
# - {::proxy_class?}[rdoc-ref:Net::HTTP.proxy_class?]:
|
569
|
+
# Returns whether +self+ is a proxy class.
|
570
|
+
# - {#proxy?}[rdoc-ref:Net::HTTP#proxy?]:
|
571
|
+
# Returns whether +self+ has a proxy.
|
572
|
+
# - {#proxy_address}[rdoc-ref:Net::HTTP#proxy_address]
|
573
|
+
# (aliased as {#proxyaddr}[rdoc-ref:Net::HTTP#proxyaddr]):
|
574
|
+
# Returns the proxy address.
|
575
|
+
# - {#proxy_from_env?}[rdoc-ref:Net::HTTP#proxy_from_env?]:
|
576
|
+
# Returns whether the proxy is taken from an environment variable.
|
577
|
+
# - {:proxy_from_env=}[rdoc-ref:Net::HTTP#proxy_from_env=]:
|
578
|
+
# Sets whether the proxy is to be taken from an environment variable.
|
579
|
+
# - {:proxy_pass}[rdoc-ref:Net::HTTP#proxy_pass]:
|
580
|
+
# Returns the proxy password.
|
581
|
+
# - {:proxy_pass=}[rdoc-ref:Net::HTTP#proxy_pass=]:
|
582
|
+
# Sets the proxy password.
|
583
|
+
# - {:proxy_port}[rdoc-ref:Net::HTTP#proxy_port]:
|
584
|
+
# Returns the proxy port.
|
585
|
+
# - {:proxy_port=}[rdoc-ref:Net::HTTP#proxy_port=]:
|
586
|
+
# Sets the proxy port.
|
587
|
+
# - {#proxy_user}[rdoc-ref:Net::HTTP#proxy_user]:
|
588
|
+
# Returns the proxy user name.
|
589
|
+
# - {:proxy_user=}[rdoc-ref:Net::HTTP#proxy_user=]:
|
590
|
+
# Sets the proxy user.
|
591
|
+
#
|
592
|
+
# === Security
|
593
|
+
#
|
594
|
+
# - {:ca_file}[rdoc-ref:Net::HTTP#ca_file]:
|
595
|
+
# Returns the path to a CA certification file.
|
596
|
+
# - {:ca_file=}[rdoc-ref:Net::HTTP#ca_file=]:
|
597
|
+
# Sets the path to a CA certification file.
|
598
|
+
# - {:ca_path}[rdoc-ref:Net::HTTP#ca_path]:
|
599
|
+
# Returns the path of to CA directory containing certification files.
|
600
|
+
# - {:ca_path=}[rdoc-ref:Net::HTTP#ca_path=]:
|
601
|
+
# Sets the path of to CA directory containing certification files.
|
602
|
+
# - {:cert}[rdoc-ref:Net::HTTP#cert]:
|
603
|
+
# Returns the OpenSSL::X509::Certificate object to be used for client certification.
|
604
|
+
# - {:cert=}[rdoc-ref:Net::HTTP#cert=]:
|
605
|
+
# Sets the OpenSSL::X509::Certificate object to be used for client certification.
|
606
|
+
# - {:cert_store}[rdoc-ref:Net::HTTP#cert_store]:
|
607
|
+
# Returns the X509::Store to be used for verifying peer certificate.
|
608
|
+
# - {:cert_store=}[rdoc-ref:Net::HTTP#cert_store=]:
|
609
|
+
# Sets the X509::Store to be used for verifying peer certificate.
|
610
|
+
# - {:ciphers}[rdoc-ref:Net::HTTP#ciphers]:
|
611
|
+
# Returns the available SSL ciphers.
|
612
|
+
# - {:ciphers=}[rdoc-ref:Net::HTTP#ciphers=]:
|
613
|
+
# Sets the available SSL ciphers.
|
614
|
+
# - {:extra_chain_cert}[rdoc-ref:Net::HTTP#extra_chain_cert]:
|
615
|
+
# Returns the extra X509 certificates to be added to the certificate chain.
|
616
|
+
# - {:extra_chain_cert=}[rdoc-ref:Net::HTTP#extra_chain_cert=]:
|
617
|
+
# Sets the extra X509 certificates to be added to the certificate chain.
|
618
|
+
# - {:key}[rdoc-ref:Net::HTTP#key]:
|
619
|
+
# Returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
|
620
|
+
# - {:key=}[rdoc-ref:Net::HTTP#key=]:
|
621
|
+
# Sets the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
|
622
|
+
# - {:max_version}[rdoc-ref:Net::HTTP#max_version]:
|
623
|
+
# Returns the maximum SSL version.
|
624
|
+
# - {:max_version=}[rdoc-ref:Net::HTTP#max_version=]:
|
625
|
+
# Sets the maximum SSL version.
|
626
|
+
# - {:min_version}[rdoc-ref:Net::HTTP#min_version]:
|
627
|
+
# Returns the minimum SSL version.
|
628
|
+
# - {:min_version=}[rdoc-ref:Net::HTTP#min_version=]:
|
629
|
+
# Sets the minimum SSL version.
|
630
|
+
# - {#peer_cert}[rdoc-ref:Net::HTTP#peer_cert]:
|
631
|
+
# Returns the X509 certificate chain for the session's socket peer.
|
632
|
+
# - {:ssl_version}[rdoc-ref:Net::HTTP#ssl_version]:
|
633
|
+
# Returns the SSL version.
|
634
|
+
# - {:ssl_version=}[rdoc-ref:Net::HTTP#ssl_version=]:
|
635
|
+
# Sets the SSL version.
|
636
|
+
# - {#use_ssl=}[rdoc-ref:Net::HTTP#use_ssl=]:
|
637
|
+
# Sets whether a new session is to use Transport Layer Security.
|
638
|
+
# - {#use_ssl?}[rdoc-ref:Net::HTTP#use_ssl?]:
|
639
|
+
# Returns whether +self+ uses SSL.
|
640
|
+
# - {:verify_callback}[rdoc-ref:Net::HTTP#verify_callback]:
|
641
|
+
# Returns the callback for the server certification verification.
|
642
|
+
# - {:verify_callback=}[rdoc-ref:Net::HTTP#verify_callback=]:
|
643
|
+
# Sets the callback for the server certification verification.
|
644
|
+
# - {:verify_depth}[rdoc-ref:Net::HTTP#verify_depth]:
|
645
|
+
# Returns the maximum depth for the certificate chain verification.
|
646
|
+
# - {:verify_depth=}[rdoc-ref:Net::HTTP#verify_depth=]:
|
647
|
+
# Sets the maximum depth for the certificate chain verification.
|
648
|
+
# - {:verify_hostname}[rdoc-ref:Net::HTTP#verify_hostname]:
|
649
|
+
# Returns the flags for server the certification verification at the beginning of the SSL/TLS session.
|
650
|
+
# - {:verify_hostname=}[rdoc-ref:Net::HTTP#verify_hostname=]:
|
651
|
+
# Sets he flags for server the certification verification at the beginning of the SSL/TLS session.
|
652
|
+
# - {:verify_mode}[rdoc-ref:Net::HTTP#verify_mode]:
|
653
|
+
# Returns the flags for server the certification verification at the beginning of the SSL/TLS session.
|
654
|
+
# - {:verify_mode=}[rdoc-ref:Net::HTTP#verify_mode=]:
|
655
|
+
# Sets the flags for server the certification verification at the beginning of the SSL/TLS session.
|
656
|
+
#
|
657
|
+
# === Addresses and Ports
|
658
|
+
#
|
659
|
+
# - {:address}[rdoc-ref:Net::HTTP#address]:
|
660
|
+
# Returns the string host name or host IP.
|
661
|
+
# - {::default_port}[rdoc-ref:Net::HTTP.default_port]:
|
662
|
+
# Returns integer 80, the default port to use for HTTP requests.
|
663
|
+
# - {::http_default_port}[rdoc-ref:Net::HTTP.http_default_port]:
|
664
|
+
# Returns integer 80, the default port to use for HTTP requests.
|
665
|
+
# - {::https_default_port}[rdoc-ref:Net::HTTP.https_default_port]:
|
666
|
+
# Returns integer 443, the default port to use for HTTPS requests.
|
667
|
+
# - {#ipaddr}[rdoc-ref:Net::HTTP#ipaddr]:
|
668
|
+
# Returns the IP address for the connection.
|
669
|
+
# - {#ipaddr=}[rdoc-ref:Net::HTTP#ipaddr=]:
|
670
|
+
# Sets the IP address for the connection.
|
671
|
+
# - {:local_host}[rdoc-ref:Net::HTTP#local_host]:
|
672
|
+
# Returns the string local host used to establish the connection.
|
673
|
+
# - {:local_host=}[rdoc-ref:Net::HTTP#local_host=]:
|
674
|
+
# Sets the string local host used to establish the connection.
|
675
|
+
# - {:local_port}[rdoc-ref:Net::HTTP#local_port]:
|
676
|
+
# Returns the integer local port used to establish the connection.
|
677
|
+
# - {:local_port=}[rdoc-ref:Net::HTTP#local_port=]:
|
678
|
+
# Sets the integer local port used to establish the connection.
|
679
|
+
# - {:port}[rdoc-ref:Net::HTTP#port]:
|
680
|
+
# Returns the integer port number.
|
681
|
+
#
|
682
|
+
# === \HTTP Version
|
683
|
+
#
|
684
|
+
# - {::version_1_2?}[rdoc-ref:Net::HTTP.version_1_2?]
|
685
|
+
# (aliased as {::is_version_1_2?}[rdoc-ref:Net::HTTP.is_version_1_2?]
|
686
|
+
# and {::version_1_2}[rdoc-ref:Net::HTTP.version_1_2]):
|
687
|
+
# Returns true; retained for compatibility.
|
688
|
+
#
|
689
|
+
# === Debugging
|
690
|
+
#
|
691
|
+
# - {#set_debug_output}[rdoc-ref:Net::HTTP#set_debug_output]:
|
692
|
+
# Sets the output stream for debugging.
|
693
|
+
#
|
694
|
+
# source://net-http//lib/net/http.rb#722
|
695
|
+
class Net::HTTP < ::Net::Protocol
|
696
|
+
# Creates a new \Net::HTTP object for the specified server address,
|
697
|
+
# without opening the TCP connection or initializing the \HTTP session.
|
698
|
+
# The +address+ should be a DNS hostname or IP address.
|
699
|
+
#
|
700
|
+
# @return [HTTP] a new instance of HTTP
|
701
|
+
#
|
702
|
+
# source://net-http//lib/net/http.rb#1093
|
703
|
+
def initialize(address, port = T.unsafe(nil)); end
|
704
|
+
|
705
|
+
# Returns +true+ if the \HTTP session has been started:
|
706
|
+
#
|
707
|
+
# http = Net::HTTP.new(hostname)
|
708
|
+
# http.started? # => false
|
709
|
+
# http.start
|
710
|
+
# http.started? # => true
|
711
|
+
# http.finish # => nil
|
712
|
+
# http.started? # => false
|
713
|
+
#
|
714
|
+
# Net::HTTP.start(hostname) do |http|
|
715
|
+
# http.started?
|
716
|
+
# end # => true
|
717
|
+
# http.started? # => false
|
718
|
+
#
|
719
|
+
# @return [Boolean]
|
720
|
+
#
|
721
|
+
# source://net-http//lib/net/http.rb#1413
|
722
|
+
def active?; end
|
723
|
+
|
724
|
+
# Returns the string host name or host IP given as argument +address+ in ::new.
|
725
|
+
#
|
726
|
+
# source://net-http//lib/net/http.rb#1194
|
727
|
+
def address; end
|
728
|
+
|
729
|
+
# Sets or returns the path to a CA certification file in PEM format.
|
730
|
+
#
|
731
|
+
# source://net-http//lib/net/http.rb#1479
|
732
|
+
def ca_file; end
|
733
|
+
|
734
|
+
# Sets or returns the path to a CA certification file in PEM format.
|
735
|
+
#
|
736
|
+
# source://net-http//lib/net/http.rb#1479
|
737
|
+
def ca_file=(_arg0); end
|
738
|
+
|
739
|
+
# Sets or returns the path of to CA directory
|
740
|
+
# containing certification files in PEM format.
|
741
|
+
#
|
742
|
+
# source://net-http//lib/net/http.rb#1483
|
743
|
+
def ca_path; end
|
744
|
+
|
745
|
+
# Sets or returns the path of to CA directory
|
746
|
+
# containing certification files in PEM format.
|
747
|
+
#
|
748
|
+
# source://net-http//lib/net/http.rb#1483
|
749
|
+
def ca_path=(_arg0); end
|
750
|
+
|
751
|
+
# Sets or returns the OpenSSL::X509::Certificate object
|
752
|
+
# to be used for client certification.
|
753
|
+
#
|
754
|
+
# source://net-http//lib/net/http.rb#1487
|
755
|
+
def cert; end
|
756
|
+
|
757
|
+
# Sets or returns the OpenSSL::X509::Certificate object
|
758
|
+
# to be used for client certification.
|
759
|
+
#
|
760
|
+
# source://net-http//lib/net/http.rb#1487
|
761
|
+
def cert=(_arg0); end
|
762
|
+
|
763
|
+
# Sets or returns the X509::Store to be used for verifying peer certificate.
|
764
|
+
#
|
765
|
+
# source://net-http//lib/net/http.rb#1490
|
766
|
+
def cert_store; end
|
767
|
+
|
768
|
+
# Sets or returns the X509::Store to be used for verifying peer certificate.
|
769
|
+
#
|
770
|
+
# source://net-http//lib/net/http.rb#1490
|
771
|
+
def cert_store=(_arg0); end
|
772
|
+
|
773
|
+
# Sets or returns the available SSL ciphers.
|
774
|
+
# See {OpenSSL::SSL::SSLContext#ciphers=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-ciphers-3D].
|
775
|
+
#
|
776
|
+
# source://net-http//lib/net/http.rb#1494
|
777
|
+
def ciphers; end
|
778
|
+
|
779
|
+
# Sets or returns the available SSL ciphers.
|
780
|
+
# See {OpenSSL::SSL::SSLContext#ciphers=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-ciphers-3D].
|
781
|
+
#
|
782
|
+
# source://net-http//lib/net/http.rb#1494
|
783
|
+
def ciphers=(_arg0); end
|
784
|
+
|
785
|
+
# Sets or returns whether to close the connection when the response is empty;
|
786
|
+
# initially +false+.
|
787
|
+
#
|
788
|
+
# source://net-http//lib/net/http.rb#1421
|
789
|
+
def close_on_empty_response; end
|
790
|
+
|
791
|
+
# Sets or returns whether to close the connection when the response is empty;
|
792
|
+
# initially +false+.
|
793
|
+
#
|
794
|
+
# source://net-http//lib/net/http.rb#1421
|
795
|
+
def close_on_empty_response=(_arg0); end
|
796
|
+
|
797
|
+
# Returns the continue timeout value;
|
798
|
+
# see continue_timeout=.
|
799
|
+
#
|
800
|
+
# source://net-http//lib/net/http.rb#1374
|
801
|
+
def continue_timeout; end
|
802
|
+
|
803
|
+
# Sets the continue timeout value,
|
804
|
+
# which is the number of seconds to wait for an expected 100 Continue response.
|
805
|
+
# If the \HTTP object does not receive a response in this many seconds
|
806
|
+
# it sends the request body.
|
807
|
+
#
|
808
|
+
# source://net-http//lib/net/http.rb#1380
|
809
|
+
def continue_timeout=(sec); end
|
810
|
+
|
811
|
+
# Sends a COPY request to the server;
|
812
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
813
|
+
#
|
814
|
+
# The request is based on the Net::HTTP::Copy object
|
815
|
+
# created from string +path+ and initial headers hash +initheader+.
|
816
|
+
#
|
817
|
+
# http = Net::HTTP.new(hostname)
|
818
|
+
# http.copy('/todos/1')
|
819
|
+
#
|
820
|
+
# source://net-http//lib/net/http.rb#2123
|
821
|
+
def copy(path, initheader = T.unsafe(nil)); end
|
822
|
+
|
823
|
+
# Sends a DELETE request to the server;
|
824
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
825
|
+
#
|
826
|
+
# The request is based on the Net::HTTP::Delete object
|
827
|
+
# created from string +path+ and initial headers hash +initheader+.
|
828
|
+
#
|
829
|
+
# http = Net::HTTP.new(hostname)
|
830
|
+
# http.delete('/todos/1')
|
831
|
+
#
|
832
|
+
# source://net-http//lib/net/http.rb#2097
|
833
|
+
def delete(path, initheader = T.unsafe(nil)); end
|
834
|
+
|
835
|
+
# Sets or returns the extra X509 certificates to be added to the certificate chain.
|
836
|
+
# See {OpenSSL::SSL::SSLContext#add_certificate}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-add_certificate].
|
837
|
+
#
|
838
|
+
# source://net-http//lib/net/http.rb#1498
|
839
|
+
def extra_chain_cert; end
|
840
|
+
|
841
|
+
# Sets or returns the extra X509 certificates to be added to the certificate chain.
|
842
|
+
# See {OpenSSL::SSL::SSLContext#add_certificate}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-add_certificate].
|
843
|
+
#
|
844
|
+
# source://net-http//lib/net/http.rb#1498
|
845
|
+
def extra_chain_cert=(_arg0); end
|
846
|
+
|
847
|
+
# Finishes the \HTTP session:
|
848
|
+
#
|
849
|
+
# http = Net::HTTP.new(hostname)
|
850
|
+
# http.start
|
851
|
+
# http.started? # => true
|
852
|
+
# http.finish # => nil
|
853
|
+
# http.started? # => false
|
854
|
+
#
|
855
|
+
# Raises IOError if not in a session.
|
856
|
+
#
|
857
|
+
# @raise [IOError]
|
858
|
+
#
|
859
|
+
# source://net-http//lib/net/http.rb#1708
|
860
|
+
def finish; end
|
861
|
+
|
862
|
+
# :call-seq:
|
863
|
+
# get(path, initheader = nil) {|res| ... }
|
864
|
+
#
|
865
|
+
# Sends a GET request to the server;
|
866
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
867
|
+
#
|
868
|
+
# The request is based on the Net::HTTP::Get object
|
869
|
+
# created from string +path+ and initial headers hash +initheader+.
|
870
|
+
#
|
871
|
+
# With a block given, calls the block with the response body:
|
872
|
+
#
|
873
|
+
# http = Net::HTTP.new(hostname)
|
874
|
+
# http.get('/todos/1') do |res|
|
875
|
+
# p res
|
876
|
+
# end # => #<Net::HTTPOK 200 OK readbody=true>
|
877
|
+
#
|
878
|
+
# Output:
|
879
|
+
#
|
880
|
+
# "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}"
|
881
|
+
#
|
882
|
+
# With no block given, simply returns the response object:
|
883
|
+
#
|
884
|
+
# http.get('/') # => #<Net::HTTPOK 200 OK readbody=true>
|
885
|
+
#
|
886
|
+
# Related:
|
887
|
+
#
|
888
|
+
# - Net::HTTP::Get: request class for \HTTP method GET.
|
889
|
+
# - Net::HTTP.get: sends GET request, returns response body.
|
890
|
+
#
|
891
|
+
# source://net-http//lib/net/http.rb#1914
|
892
|
+
def get(path, initheader = T.unsafe(nil), dest = T.unsafe(nil), &block); end
|
893
|
+
|
894
|
+
# Sends a GET request to the server;
|
895
|
+
# forms the response into a Net::HTTPResponse object.
|
896
|
+
#
|
897
|
+
# The request is based on the Net::HTTP::Get object
|
898
|
+
# created from string +path+ and initial headers hash +initheader+.
|
899
|
+
#
|
900
|
+
# With no block given, returns the response object:
|
901
|
+
#
|
902
|
+
# http = Net::HTTP.new(hostname)
|
903
|
+
# http.request_get('/todos') # => #<Net::HTTPOK 200 OK readbody=true>
|
904
|
+
#
|
905
|
+
# With a block given, calls the block with the response object
|
906
|
+
# and returns the response object:
|
907
|
+
#
|
908
|
+
# http.request_get('/todos') do |res|
|
909
|
+
# p res
|
910
|
+
# end # => #<Net::HTTPOK 200 OK readbody=true>
|
911
|
+
#
|
912
|
+
# Output:
|
913
|
+
#
|
914
|
+
# #<Net::HTTPOK 200 OK readbody=false>
|
915
|
+
#
|
916
|
+
# source://net-http//lib/net/http.rb#2176
|
917
|
+
def get2(path, initheader = T.unsafe(nil), &block); end
|
918
|
+
|
919
|
+
# Sends a HEAD request to the server;
|
920
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
921
|
+
#
|
922
|
+
# The request is based on the Net::HTTP::Head object
|
923
|
+
# created from string +path+ and initial headers hash +initheader+:
|
924
|
+
#
|
925
|
+
# res = http.head('/todos/1') # => #<Net::HTTPOK 200 OK readbody=true>
|
926
|
+
# res.body # => nil
|
927
|
+
# res.to_hash.take(3)
|
928
|
+
# # =>
|
929
|
+
# [["date", ["Wed, 15 Feb 2023 15:25:42 GMT"]],
|
930
|
+
# ["content-type", ["application/json; charset=utf-8"]],
|
931
|
+
# ["connection", ["close"]]]
|
932
|
+
#
|
933
|
+
# source://net-http//lib/net/http.rb#1938
|
934
|
+
def head(path, initheader = T.unsafe(nil)); end
|
935
|
+
|
936
|
+
# Sends a HEAD request to the server;
|
937
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
938
|
+
#
|
939
|
+
# The request is based on the Net::HTTP::Head object
|
940
|
+
# created from string +path+ and initial headers hash +initheader+.
|
941
|
+
#
|
942
|
+
# http = Net::HTTP.new(hostname)
|
943
|
+
# http.head('/todos/1') # => #<Net::HTTPOK 200 OK readbody=true>
|
944
|
+
#
|
945
|
+
# source://net-http//lib/net/http.rb#2189
|
946
|
+
def head2(path, initheader = T.unsafe(nil), &block); end
|
947
|
+
|
948
|
+
# Sets or returns whether to ignore end-of-file when reading a response body
|
949
|
+
# with <tt>Content-Length</tt> headers;
|
950
|
+
# initially +true+.
|
951
|
+
#
|
952
|
+
# source://net-http//lib/net/http.rb#1397
|
953
|
+
def ignore_eof; end
|
954
|
+
|
955
|
+
# Sets or returns whether to ignore end-of-file when reading a response body
|
956
|
+
# with <tt>Content-Length</tt> headers;
|
957
|
+
# initially +true+.
|
958
|
+
#
|
959
|
+
# source://net-http//lib/net/http.rb#1397
|
960
|
+
def ignore_eof=(_arg0); end
|
961
|
+
|
962
|
+
# Returns a string representation of +self+:
|
963
|
+
#
|
964
|
+
# Net::HTTP.new(hostname).inspect
|
965
|
+
# # => "#<Net::HTTP jsonplaceholder.typicode.com:80 open=false>"
|
966
|
+
#
|
967
|
+
# source://net-http//lib/net/http.rb#1135
|
968
|
+
def inspect; end
|
969
|
+
|
970
|
+
# Returns the IP address for the connection.
|
971
|
+
#
|
972
|
+
# If the session has not been started,
|
973
|
+
# returns the value set by #ipaddr=,
|
974
|
+
# or +nil+ if it has not been set:
|
975
|
+
#
|
976
|
+
# http = Net::HTTP.new(hostname)
|
977
|
+
# http.ipaddr # => nil
|
978
|
+
# http.ipaddr = '172.67.155.76'
|
979
|
+
# http.ipaddr # => "172.67.155.76"
|
980
|
+
#
|
981
|
+
# If the session has been started,
|
982
|
+
# returns the IP address from the socket:
|
983
|
+
#
|
984
|
+
# http = Net::HTTP.new(hostname)
|
985
|
+
# http.start
|
986
|
+
# http.ipaddr # => "172.67.155.76"
|
987
|
+
# http.finish
|
988
|
+
#
|
989
|
+
# source://net-http//lib/net/http.rb#1274
|
990
|
+
def ipaddr; end
|
991
|
+
|
992
|
+
# Sets the IP address for the connection:
|
993
|
+
#
|
994
|
+
# http = Net::HTTP.new(hostname)
|
995
|
+
# http.ipaddr # => nil
|
996
|
+
# http.ipaddr = '172.67.155.76'
|
997
|
+
# http.ipaddr # => "172.67.155.76"
|
998
|
+
#
|
999
|
+
# The IP address may not be set if the session has been started.
|
1000
|
+
#
|
1001
|
+
# @raise [IOError]
|
1002
|
+
#
|
1003
|
+
# source://net-http//lib/net/http.rb#1286
|
1004
|
+
def ipaddr=(addr); end
|
1005
|
+
|
1006
|
+
# Sets or returns the numeric (\Integer or \Float) number of seconds
|
1007
|
+
# to keep the connection open after a request is sent;
|
1008
|
+
# initially 2.
|
1009
|
+
# If a new request is made during the given interval,
|
1010
|
+
# the still-open connection is used;
|
1011
|
+
# otherwise the connection will have been closed
|
1012
|
+
# and a new connection is opened.
|
1013
|
+
#
|
1014
|
+
# source://net-http//lib/net/http.rb#1392
|
1015
|
+
def keep_alive_timeout; end
|
1016
|
+
|
1017
|
+
# Sets or returns the numeric (\Integer or \Float) number of seconds
|
1018
|
+
# to keep the connection open after a request is sent;
|
1019
|
+
# initially 2.
|
1020
|
+
# If a new request is made during the given interval,
|
1021
|
+
# the still-open connection is used;
|
1022
|
+
# otherwise the connection will have been closed
|
1023
|
+
# and a new connection is opened.
|
1024
|
+
#
|
1025
|
+
# source://net-http//lib/net/http.rb#1392
|
1026
|
+
def keep_alive_timeout=(_arg0); end
|
1027
|
+
|
1028
|
+
# Sets or returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
|
1029
|
+
#
|
1030
|
+
# source://net-http//lib/net/http.rb#1501
|
1031
|
+
def key; end
|
1032
|
+
|
1033
|
+
# Sets or returns the OpenSSL::PKey::RSA or OpenSSL::PKey::DSA object.
|
1034
|
+
#
|
1035
|
+
# source://net-http//lib/net/http.rb#1501
|
1036
|
+
def key=(_arg0); end
|
1037
|
+
|
1038
|
+
# Sets or returns the string local host used to establish the connection;
|
1039
|
+
# initially +nil+.
|
1040
|
+
#
|
1041
|
+
# source://net-http//lib/net/http.rb#1201
|
1042
|
+
def local_host; end
|
1043
|
+
|
1044
|
+
# Sets or returns the string local host used to establish the connection;
|
1045
|
+
# initially +nil+.
|
1046
|
+
#
|
1047
|
+
# source://net-http//lib/net/http.rb#1201
|
1048
|
+
def local_host=(_arg0); end
|
1049
|
+
|
1050
|
+
# Sets or returns the integer local port used to establish the connection;
|
1051
|
+
# initially +nil+.
|
1052
|
+
#
|
1053
|
+
# source://net-http//lib/net/http.rb#1205
|
1054
|
+
def local_port; end
|
1055
|
+
|
1056
|
+
# Sets or returns the integer local port used to establish the connection;
|
1057
|
+
# initially +nil+.
|
1058
|
+
#
|
1059
|
+
# source://net-http//lib/net/http.rb#1205
|
1060
|
+
def local_port=(_arg0); end
|
1061
|
+
|
1062
|
+
# Sends a LOCK request to the server;
|
1063
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1064
|
+
#
|
1065
|
+
# The request is based on the Net::HTTP::Lock object
|
1066
|
+
# created from string +path+, string +body+, and initial headers hash +initheader+.
|
1067
|
+
#
|
1068
|
+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
|
1069
|
+
# http = Net::HTTP.new(hostname)
|
1070
|
+
# http.lock('/todos/1', data)
|
1071
|
+
#
|
1072
|
+
# source://net-http//lib/net/http.rb#2043
|
1073
|
+
def lock(path, body, initheader = T.unsafe(nil)); end
|
1074
|
+
|
1075
|
+
# Returns the maximum number of times to retry an idempotent request;
|
1076
|
+
# see #max_retries=.
|
1077
|
+
#
|
1078
|
+
# source://net-http//lib/net/http.rb#1330
|
1079
|
+
def max_retries; end
|
1080
|
+
|
1081
|
+
# Sets the maximum number of times to retry an idempotent request in case of
|
1082
|
+
# \Net::ReadTimeout, IOError, EOFError, Errno::ECONNRESET,
|
1083
|
+
# Errno::ECONNABORTED, Errno::EPIPE, OpenSSL::SSL::SSLError,
|
1084
|
+
# Timeout::Error.
|
1085
|
+
# The initial value is 1.
|
1086
|
+
#
|
1087
|
+
# Argument +retries+ must be a non-negative numeric value:
|
1088
|
+
#
|
1089
|
+
# http = Net::HTTP.new(hostname)
|
1090
|
+
# http.max_retries = 2 # => 2
|
1091
|
+
# http.max_retries # => 2
|
1092
|
+
#
|
1093
|
+
# source://net-http//lib/net/http.rb#1320
|
1094
|
+
def max_retries=(retries); end
|
1095
|
+
|
1096
|
+
# Sets or returns the maximum SSL version.
|
1097
|
+
# See {OpenSSL::SSL::SSLContext#max_version=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-max_version-3D].
|
1098
|
+
#
|
1099
|
+
# source://net-http//lib/net/http.rb#1516
|
1100
|
+
def max_version; end
|
1101
|
+
|
1102
|
+
# Sets or returns the maximum SSL version.
|
1103
|
+
# See {OpenSSL::SSL::SSLContext#max_version=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-max_version-3D].
|
1104
|
+
#
|
1105
|
+
# source://net-http//lib/net/http.rb#1516
|
1106
|
+
def max_version=(_arg0); end
|
1107
|
+
|
1108
|
+
# Sets or returns the minimum SSL version.
|
1109
|
+
# See {OpenSSL::SSL::SSLContext#min_version=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-min_version-3D].
|
1110
|
+
#
|
1111
|
+
# source://net-http//lib/net/http.rb#1512
|
1112
|
+
def min_version; end
|
1113
|
+
|
1114
|
+
# Sets or returns the minimum SSL version.
|
1115
|
+
# See {OpenSSL::SSL::SSLContext#min_version=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-min_version-3D].
|
1116
|
+
#
|
1117
|
+
# source://net-http//lib/net/http.rb#1512
|
1118
|
+
def min_version=(_arg0); end
|
1119
|
+
|
1120
|
+
# Sends a MKCOL request to the server;
|
1121
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1122
|
+
#
|
1123
|
+
# The request is based on the Net::HTTP::Mkcol object
|
1124
|
+
# created from string +path+, string +body+, and initial headers hash +initheader+.
|
1125
|
+
#
|
1126
|
+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
|
1127
|
+
# http.mkcol('/todos/1', data)
|
1128
|
+
# http = Net::HTTP.new(hostname)
|
1129
|
+
#
|
1130
|
+
# source://net-http//lib/net/http.rb#2137
|
1131
|
+
def mkcol(path, body = T.unsafe(nil), initheader = T.unsafe(nil)); end
|
1132
|
+
|
1133
|
+
# Sends a MOVE request to the server;
|
1134
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1135
|
+
#
|
1136
|
+
# The request is based on the Net::HTTP::Move object
|
1137
|
+
# created from string +path+ and initial headers hash +initheader+.
|
1138
|
+
#
|
1139
|
+
# http = Net::HTTP.new(hostname)
|
1140
|
+
# http.move('/todos/1')
|
1141
|
+
#
|
1142
|
+
# source://net-http//lib/net/http.rb#2110
|
1143
|
+
def move(path, initheader = T.unsafe(nil)); end
|
1144
|
+
|
1145
|
+
# Sets or returns the numeric (\Integer or \Float) number of seconds
|
1146
|
+
# to wait for a connection to open;
|
1147
|
+
# initially 60.
|
1148
|
+
# If the connection is not made in the given interval,
|
1149
|
+
# an exception is raised.
|
1150
|
+
#
|
1151
|
+
# source://net-http//lib/net/http.rb#1296
|
1152
|
+
def open_timeout; end
|
1153
|
+
|
1154
|
+
# Sets or returns the numeric (\Integer or \Float) number of seconds
|
1155
|
+
# to wait for a connection to open;
|
1156
|
+
# initially 60.
|
1157
|
+
# If the connection is not made in the given interval,
|
1158
|
+
# an exception is raised.
|
1159
|
+
#
|
1160
|
+
# source://net-http//lib/net/http.rb#1296
|
1161
|
+
def open_timeout=(_arg0); end
|
1162
|
+
|
1163
|
+
# Sends an Options request to the server;
|
1164
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1165
|
+
#
|
1166
|
+
# The request is based on the Net::HTTP::Options object
|
1167
|
+
# created from string +path+ and initial headers hash +initheader+.
|
1168
|
+
#
|
1169
|
+
# http = Net::HTTP.new(hostname)
|
1170
|
+
# http.options('/')
|
1171
|
+
#
|
1172
|
+
# source://net-http//lib/net/http.rb#2070
|
1173
|
+
def options(path, initheader = T.unsafe(nil)); end
|
1174
|
+
|
1175
|
+
# :call-seq:
|
1176
|
+
# patch(path, data, initheader = nil) {|res| ... }
|
1177
|
+
#
|
1178
|
+
# Sends a PATCH request to the server;
|
1179
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1180
|
+
#
|
1181
|
+
# The request is based on the Net::HTTP::Patch object
|
1182
|
+
# created from string +path+, string +data+, and initial headers hash +initheader+.
|
1183
|
+
#
|
1184
|
+
# With a block given, calls the block with the response body:
|
1185
|
+
#
|
1186
|
+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
|
1187
|
+
# http = Net::HTTP.new(hostname)
|
1188
|
+
# http.patch('/todos/1', data) do |res|
|
1189
|
+
# p res
|
1190
|
+
# end # => #<Net::HTTPOK 200 OK readbody=true>
|
1191
|
+
#
|
1192
|
+
# Output:
|
1193
|
+
#
|
1194
|
+
# "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false,\n \"{\\\"userId\\\": 1, \\\"id\\\": 1, \\\"title\\\": \\\"delectus aut autem\\\", \\\"completed\\\": false}\": \"\"\n}"
|
1195
|
+
#
|
1196
|
+
# With no block given, simply returns the response object:
|
1197
|
+
#
|
1198
|
+
# http.patch('/todos/1', data) # => #<Net::HTTPCreated 201 Created readbody=true>
|
1199
|
+
#
|
1200
|
+
# source://net-http//lib/net/http.rb#2001
|
1201
|
+
def patch(path, data, initheader = T.unsafe(nil), dest = T.unsafe(nil), &block); end
|
1202
|
+
|
1203
|
+
# Returns the X509 certificate chain (an array of strings)
|
1204
|
+
# for the session's socket peer,
|
1205
|
+
# or +nil+ if none.
|
1206
|
+
#
|
1207
|
+
# source://net-http//lib/net/http.rb#1537
|
1208
|
+
def peer_cert; end
|
1209
|
+
|
1210
|
+
# Returns the integer port number given as argument +port+ in ::new.
|
1211
|
+
#
|
1212
|
+
# source://net-http//lib/net/http.rb#1197
|
1213
|
+
def port; end
|
1214
|
+
|
1215
|
+
# :call-seq:
|
1216
|
+
# post(path, data, initheader = nil) {|res| ... }
|
1217
|
+
#
|
1218
|
+
# Sends a POST request to the server;
|
1219
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1220
|
+
#
|
1221
|
+
# The request is based on the Net::HTTP::Post object
|
1222
|
+
# created from string +path+, string +data+, and initial headers hash +initheader+.
|
1223
|
+
#
|
1224
|
+
# With a block given, calls the block with the response body:
|
1225
|
+
#
|
1226
|
+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
|
1227
|
+
# http = Net::HTTP.new(hostname)
|
1228
|
+
# http.post('/todos', data) do |res|
|
1229
|
+
# p res
|
1230
|
+
# end # => #<Net::HTTPCreated 201 Created readbody=true>
|
1231
|
+
#
|
1232
|
+
# Output:
|
1233
|
+
#
|
1234
|
+
# "{\n \"{\\\"userId\\\": 1, \\\"id\\\": 1, \\\"title\\\": \\\"delectus aut autem\\\", \\\"completed\\\": false}\": \"\",\n \"id\": 201\n}"
|
1235
|
+
#
|
1236
|
+
# With no block given, simply returns the response object:
|
1237
|
+
#
|
1238
|
+
# http.post('/todos', data) # => #<Net::HTTPCreated 201 Created readbody=true>
|
1239
|
+
#
|
1240
|
+
# Related:
|
1241
|
+
#
|
1242
|
+
# - Net::HTTP::Post: request class for \HTTP method POST.
|
1243
|
+
# - Net::HTTP.post: sends POST request, returns response body.
|
1244
|
+
#
|
1245
|
+
# source://net-http//lib/net/http.rb#1972
|
1246
|
+
def post(path, data, initheader = T.unsafe(nil), dest = T.unsafe(nil), &block); end
|
1247
|
+
|
1248
|
+
# Sends a POST request to the server;
|
1249
|
+
# forms the response into a Net::HTTPResponse object.
|
1250
|
+
#
|
1251
|
+
# The request is based on the Net::HTTP::Post object
|
1252
|
+
# created from string +path+, string +data+, and initial headers hash +initheader+.
|
1253
|
+
#
|
1254
|
+
# With no block given, returns the response object:
|
1255
|
+
#
|
1256
|
+
# http = Net::HTTP.new(hostname)
|
1257
|
+
# http.post('/todos', 'xyzzy')
|
1258
|
+
# # => #<Net::HTTPCreated 201 Created readbody=true>
|
1259
|
+
#
|
1260
|
+
# With a block given, calls the block with the response body
|
1261
|
+
# and returns the response object:
|
1262
|
+
#
|
1263
|
+
# http.post('/todos', 'xyzzy') do |res|
|
1264
|
+
# p res
|
1265
|
+
# end # => #<Net::HTTPCreated 201 Created readbody=true>
|
1266
|
+
#
|
1267
|
+
# Output:
|
1268
|
+
#
|
1269
|
+
# "{\n \"xyzzy\": \"\",\n \"id\": 201\n}"
|
1270
|
+
#
|
1271
|
+
# source://net-http//lib/net/http.rb#2216
|
1272
|
+
def post2(path, data, initheader = T.unsafe(nil), &block); end
|
1273
|
+
|
1274
|
+
# Sends a PROPFIND request to the server;
|
1275
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1276
|
+
#
|
1277
|
+
# The request is based on the Net::HTTP::Propfind object
|
1278
|
+
# created from string +path+, string +body+, and initial headers hash +initheader+.
|
1279
|
+
#
|
1280
|
+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
|
1281
|
+
# http = Net::HTTP.new(hostname)
|
1282
|
+
# http.propfind('/todos/1', data)
|
1283
|
+
#
|
1284
|
+
# source://net-http//lib/net/http.rb#2084
|
1285
|
+
def propfind(path, body = T.unsafe(nil), initheader = T.unsafe(nil)); end
|
1286
|
+
|
1287
|
+
# Sends a PROPPATCH request to the server;
|
1288
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1289
|
+
#
|
1290
|
+
# The request is based on the Net::HTTP::Proppatch object
|
1291
|
+
# created from string +path+, string +body+, and initial headers hash +initheader+.
|
1292
|
+
#
|
1293
|
+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
|
1294
|
+
# http = Net::HTTP.new(hostname)
|
1295
|
+
# http.proppatch('/todos/1', data)
|
1296
|
+
#
|
1297
|
+
# source://net-http//lib/net/http.rb#2029
|
1298
|
+
def proppatch(path, body, initheader = T.unsafe(nil)); end
|
1299
|
+
|
1300
|
+
# Returns +true+ if a proxy server is defined, +false+ otherwise;
|
1301
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
1302
|
+
#
|
1303
|
+
# @return [Boolean]
|
1304
|
+
#
|
1305
|
+
# source://net-http//lib/net/http.rb#1785
|
1306
|
+
def proxy?; end
|
1307
|
+
|
1308
|
+
# Returns the address of the proxy server, if defined, +nil+ otherwise;
|
1309
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
1310
|
+
#
|
1311
|
+
# source://net-http//lib/net/http.rb#1807
|
1312
|
+
def proxy_address; end
|
1313
|
+
|
1314
|
+
# Sets the proxy address;
|
1315
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
1316
|
+
#
|
1317
|
+
# source://net-http//lib/net/http.rb#1241
|
1318
|
+
def proxy_address=(_arg0); end
|
1319
|
+
|
1320
|
+
# Sets whether to determine the proxy from environment variable
|
1321
|
+
# '<tt>ENV['http_proxy']</tt>';
|
1322
|
+
# see {Proxy Using ENV['http_proxy']}[rdoc-ref:Net::HTTP@Proxy+Using+-27ENV-5B-27http_proxy-27-5D-27].
|
1323
|
+
#
|
1324
|
+
# source://net-http//lib/net/http.rb#1237
|
1325
|
+
def proxy_from_env=(_arg0); end
|
1326
|
+
|
1327
|
+
# Returns +true+ if the proxy server is defined in the environment,
|
1328
|
+
# +false+ otherwise;
|
1329
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
1330
|
+
#
|
1331
|
+
# @return [Boolean]
|
1332
|
+
#
|
1333
|
+
# source://net-http//lib/net/http.rb#1792
|
1334
|
+
def proxy_from_env?; end
|
1335
|
+
|
1336
|
+
# Returns the password of the proxy server, if defined, +nil+ otherwise;
|
1337
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
1338
|
+
#
|
1339
|
+
# source://net-http//lib/net/http.rb#1838
|
1340
|
+
def proxy_pass; end
|
1341
|
+
|
1342
|
+
# Sets the proxy password;
|
1343
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
1344
|
+
#
|
1345
|
+
# source://net-http//lib/net/http.rb#1253
|
1346
|
+
def proxy_pass=(_arg0); end
|
1347
|
+
|
1348
|
+
# Returns the port number of the proxy server, if defined, +nil+ otherwise;
|
1349
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
1350
|
+
#
|
1351
|
+
# source://net-http//lib/net/http.rb#1817
|
1352
|
+
def proxy_port; end
|
1353
|
+
|
1354
|
+
# Sets the proxy port;
|
1355
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
1356
|
+
#
|
1357
|
+
# source://net-http//lib/net/http.rb#1245
|
1358
|
+
def proxy_port=(_arg0); end
|
1359
|
+
|
1360
|
+
# The proxy URI determined from the environment for this connection.
|
1361
|
+
#
|
1362
|
+
# source://net-http//lib/net/http.rb#1797
|
1363
|
+
def proxy_uri; end
|
1364
|
+
|
1365
|
+
# Returns the user name of the proxy server, if defined, +nil+ otherwise;
|
1366
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
1367
|
+
#
|
1368
|
+
# source://net-http//lib/net/http.rb#1827
|
1369
|
+
def proxy_user; end
|
1370
|
+
|
1371
|
+
# Sets the proxy user;
|
1372
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
1373
|
+
#
|
1374
|
+
# source://net-http//lib/net/http.rb#1249
|
1375
|
+
def proxy_user=(_arg0); end
|
1376
|
+
|
1377
|
+
# Returns the address of the proxy server, if defined, +nil+ otherwise;
|
1378
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
1379
|
+
#
|
1380
|
+
# source://net-http//lib/net/http.rb#1807
|
1381
|
+
def proxyaddr; end
|
1382
|
+
|
1383
|
+
# Returns the port number of the proxy server, if defined, +nil+ otherwise;
|
1384
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
1385
|
+
#
|
1386
|
+
# source://net-http//lib/net/http.rb#1817
|
1387
|
+
def proxyport; end
|
1388
|
+
|
1389
|
+
# Sends a PUT request to the server;
|
1390
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1391
|
+
#
|
1392
|
+
# The request is based on the Net::HTTP::Put object
|
1393
|
+
# created from string +path+, string +data+, and initial headers hash +initheader+.
|
1394
|
+
#
|
1395
|
+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
|
1396
|
+
# http = Net::HTTP.new(hostname)
|
1397
|
+
# http.put('/todos/1', data) # => #<Net::HTTPOK 200 OK readbody=true>
|
1398
|
+
#
|
1399
|
+
# source://net-http//lib/net/http.rb#2015
|
1400
|
+
def put(path, data, initheader = T.unsafe(nil)); end
|
1401
|
+
|
1402
|
+
# Sends a PUT request to the server;
|
1403
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1404
|
+
#
|
1405
|
+
# The request is based on the Net::HTTP::Put object
|
1406
|
+
# created from string +path+, string +data+, and initial headers hash +initheader+.
|
1407
|
+
#
|
1408
|
+
# http = Net::HTTP.new(hostname)
|
1409
|
+
# http.put('/todos/1', 'xyzzy')
|
1410
|
+
# # => #<Net::HTTPOK 200 OK readbody=true>
|
1411
|
+
#
|
1412
|
+
# source://net-http//lib/net/http.rb#2230
|
1413
|
+
def put2(path, data, initheader = T.unsafe(nil), &block); end
|
1414
|
+
|
1415
|
+
# Returns the numeric (\Integer or \Float) number of seconds
|
1416
|
+
# to wait for one block to be read (via one read(2) call);
|
1417
|
+
# see #read_timeout=.
|
1418
|
+
#
|
1419
|
+
# source://net-http//lib/net/http.rb#1301
|
1420
|
+
def read_timeout; end
|
1421
|
+
|
1422
|
+
# Sets the read timeout, in seconds, for +self+ to integer +sec+;
|
1423
|
+
# the initial value is 60.
|
1424
|
+
#
|
1425
|
+
# Argument +sec+ must be a non-negative numeric value:
|
1426
|
+
#
|
1427
|
+
# http = Net::HTTP.new(hostname)
|
1428
|
+
# http.read_timeout # => 60
|
1429
|
+
# http.get('/todos/1') # => #<Net::HTTPOK 200 OK readbody=true>
|
1430
|
+
# http.read_timeout = 0
|
1431
|
+
# http.get('/todos/1') # Raises Net::ReadTimeout.
|
1432
|
+
#
|
1433
|
+
# source://net-http//lib/net/http.rb#1343
|
1434
|
+
def read_timeout=(sec); end
|
1435
|
+
|
1436
|
+
# Sends the given request +req+ to the server;
|
1437
|
+
# forms the response into a Net::HTTPResponse object.
|
1438
|
+
#
|
1439
|
+
# The given +req+ must be an instance of a
|
1440
|
+
# {subclass of Net::HTTPRequest}[rdoc-ref:Net::HTTPRequest@Request+Subclasses].
|
1441
|
+
# Argument +body+ should be given only if needed for the request.
|
1442
|
+
#
|
1443
|
+
# With no block given, returns the response object:
|
1444
|
+
#
|
1445
|
+
# http = Net::HTTP.new(hostname)
|
1446
|
+
#
|
1447
|
+
# req = Net::HTTP::Get.new('/todos/1')
|
1448
|
+
# http.request(req)
|
1449
|
+
# # => #<Net::HTTPOK 200 OK readbody=true>
|
1450
|
+
#
|
1451
|
+
# req = Net::HTTP::Post.new('/todos')
|
1452
|
+
# http.request(req, 'xyzzy')
|
1453
|
+
# # => #<Net::HTTPCreated 201 Created readbody=true>
|
1454
|
+
#
|
1455
|
+
# With a block given, calls the block with the response and returns the response:
|
1456
|
+
#
|
1457
|
+
# req = Net::HTTP::Get.new('/todos/1')
|
1458
|
+
# http.request(req) do |res|
|
1459
|
+
# p res
|
1460
|
+
# end # => #<Net::HTTPOK 200 OK readbody=true>
|
1461
|
+
#
|
1462
|
+
# Output:
|
1463
|
+
#
|
1464
|
+
# #<Net::HTTPOK 200 OK readbody=false>
|
1465
|
+
#
|
1466
|
+
# source://net-http//lib/net/http.rb#2295
|
1467
|
+
def request(req, body = T.unsafe(nil), &block); end
|
1468
|
+
|
1469
|
+
# Sends a GET request to the server;
|
1470
|
+
# forms the response into a Net::HTTPResponse object.
|
1471
|
+
#
|
1472
|
+
# The request is based on the Net::HTTP::Get object
|
1473
|
+
# created from string +path+ and initial headers hash +initheader+.
|
1474
|
+
#
|
1475
|
+
# With no block given, returns the response object:
|
1476
|
+
#
|
1477
|
+
# http = Net::HTTP.new(hostname)
|
1478
|
+
# http.request_get('/todos') # => #<Net::HTTPOK 200 OK readbody=true>
|
1479
|
+
#
|
1480
|
+
# With a block given, calls the block with the response object
|
1481
|
+
# and returns the response object:
|
1482
|
+
#
|
1483
|
+
# http.request_get('/todos') do |res|
|
1484
|
+
# p res
|
1485
|
+
# end # => #<Net::HTTPOK 200 OK readbody=true>
|
1486
|
+
#
|
1487
|
+
# Output:
|
1488
|
+
#
|
1489
|
+
# #<Net::HTTPOK 200 OK readbody=false>
|
1490
|
+
#
|
1491
|
+
# source://net-http//lib/net/http.rb#2176
|
1492
|
+
def request_get(path, initheader = T.unsafe(nil), &block); end
|
1493
|
+
|
1494
|
+
# Sends a HEAD request to the server;
|
1495
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1496
|
+
#
|
1497
|
+
# The request is based on the Net::HTTP::Head object
|
1498
|
+
# created from string +path+ and initial headers hash +initheader+.
|
1499
|
+
#
|
1500
|
+
# http = Net::HTTP.new(hostname)
|
1501
|
+
# http.head('/todos/1') # => #<Net::HTTPOK 200 OK readbody=true>
|
1502
|
+
#
|
1503
|
+
# source://net-http//lib/net/http.rb#2189
|
1504
|
+
def request_head(path, initheader = T.unsafe(nil), &block); end
|
1505
|
+
|
1506
|
+
# Sends a POST request to the server;
|
1507
|
+
# forms the response into a Net::HTTPResponse object.
|
1508
|
+
#
|
1509
|
+
# The request is based on the Net::HTTP::Post object
|
1510
|
+
# created from string +path+, string +data+, and initial headers hash +initheader+.
|
1511
|
+
#
|
1512
|
+
# With no block given, returns the response object:
|
1513
|
+
#
|
1514
|
+
# http = Net::HTTP.new(hostname)
|
1515
|
+
# http.post('/todos', 'xyzzy')
|
1516
|
+
# # => #<Net::HTTPCreated 201 Created readbody=true>
|
1517
|
+
#
|
1518
|
+
# With a block given, calls the block with the response body
|
1519
|
+
# and returns the response object:
|
1520
|
+
#
|
1521
|
+
# http.post('/todos', 'xyzzy') do |res|
|
1522
|
+
# p res
|
1523
|
+
# end # => #<Net::HTTPCreated 201 Created readbody=true>
|
1524
|
+
#
|
1525
|
+
# Output:
|
1526
|
+
#
|
1527
|
+
# "{\n \"xyzzy\": \"\",\n \"id\": 201\n}"
|
1528
|
+
#
|
1529
|
+
# source://net-http//lib/net/http.rb#2216
|
1530
|
+
def request_post(path, data, initheader = T.unsafe(nil), &block); end
|
1531
|
+
|
1532
|
+
# Sends a PUT request to the server;
|
1533
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1534
|
+
#
|
1535
|
+
# The request is based on the Net::HTTP::Put object
|
1536
|
+
# created from string +path+, string +data+, and initial headers hash +initheader+.
|
1537
|
+
#
|
1538
|
+
# http = Net::HTTP.new(hostname)
|
1539
|
+
# http.put('/todos/1', 'xyzzy')
|
1540
|
+
# # => #<Net::HTTPOK 200 OK readbody=true>
|
1541
|
+
#
|
1542
|
+
# source://net-http//lib/net/http.rb#2230
|
1543
|
+
def request_put(path, data, initheader = T.unsafe(nil), &block); end
|
1544
|
+
|
1545
|
+
# Returns the encoding to use for the response body;
|
1546
|
+
# see #response_body_encoding=.
|
1547
|
+
#
|
1548
|
+
# source://net-http//lib/net/http.rb#1209
|
1549
|
+
def response_body_encoding; end
|
1550
|
+
|
1551
|
+
# Sets the encoding to be used for the response body;
|
1552
|
+
# returns the encoding.
|
1553
|
+
#
|
1554
|
+
# The given +value+ may be:
|
1555
|
+
#
|
1556
|
+
# - An Encoding object.
|
1557
|
+
# - The name of an encoding.
|
1558
|
+
# - An alias for an encoding name.
|
1559
|
+
#
|
1560
|
+
# See {Encoding}[https://docs.ruby-lang.org/en/master/Encoding.html].
|
1561
|
+
#
|
1562
|
+
# Examples:
|
1563
|
+
#
|
1564
|
+
# http = Net::HTTP.new(hostname)
|
1565
|
+
# http.response_body_encoding = Encoding::US_ASCII # => #<Encoding:US-ASCII>
|
1566
|
+
# http.response_body_encoding = 'US-ASCII' # => "US-ASCII"
|
1567
|
+
# http.response_body_encoding = 'ASCII' # => "ASCII"
|
1568
|
+
#
|
1569
|
+
# source://net-http//lib/net/http.rb#1229
|
1570
|
+
def response_body_encoding=(value); end
|
1571
|
+
|
1572
|
+
# Sends an \HTTP request to the server;
|
1573
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1574
|
+
#
|
1575
|
+
# The request is based on the Net::HTTPRequest object
|
1576
|
+
# created from string +path+, string +data+, and initial headers hash +header+.
|
1577
|
+
# That object is an instance of the
|
1578
|
+
# {subclass of Net::HTTPRequest}[rdoc-ref:Net::HTTPRequest@Request+Subclasses],
|
1579
|
+
# that corresponds to the given uppercase string +name+,
|
1580
|
+
# which must be
|
1581
|
+
# an {HTTP request method}[https://en.wikipedia.org/wiki/HTTP#Request_methods]
|
1582
|
+
# or a {WebDAV request method}[https://en.wikipedia.org/wiki/WebDAV#Implementation].
|
1583
|
+
#
|
1584
|
+
# Examples:
|
1585
|
+
#
|
1586
|
+
# http = Net::HTTP.new(hostname)
|
1587
|
+
# http.send_request('GET', '/todos/1')
|
1588
|
+
# # => #<Net::HTTPOK 200 OK readbody=true>
|
1589
|
+
# http.send_request('POST', '/todos', 'xyzzy')
|
1590
|
+
# # => #<Net::HTTPCreated 201 Created readbody=true>
|
1591
|
+
#
|
1592
|
+
# source://net-http//lib/net/http.rb#2259
|
1593
|
+
def send_request(name, path, data = T.unsafe(nil), header = T.unsafe(nil)); end
|
1594
|
+
|
1595
|
+
# *WARNING* This method opens a serious security hole.
|
1596
|
+
# Never use this method in production code.
|
1597
|
+
#
|
1598
|
+
# Sets the output stream for debugging:
|
1599
|
+
#
|
1600
|
+
# http = Net::HTTP.new(hostname)
|
1601
|
+
# File.open('t.tmp', 'w') do |file|
|
1602
|
+
# http.set_debug_output(file)
|
1603
|
+
# http.start
|
1604
|
+
# http.get('/nosuch/1')
|
1605
|
+
# http.finish
|
1606
|
+
# end
|
1607
|
+
# puts File.read('t.tmp')
|
1608
|
+
#
|
1609
|
+
# Output:
|
1610
|
+
#
|
1611
|
+
# opening connection to jsonplaceholder.typicode.com:80...
|
1612
|
+
# opened
|
1613
|
+
# <- "GET /nosuch/1 HTTP/1.1\r\nAccept-Encoding: gzip;q=1.0,deflate;q=0.6,identity;q=0.3\r\nAccept: */*\r\nUser-Agent: Ruby\r\nHost: jsonplaceholder.typicode.com\r\n\r\n"
|
1614
|
+
# -> "HTTP/1.1 404 Not Found\r\n"
|
1615
|
+
# -> "Date: Mon, 12 Dec 2022 21:14:11 GMT\r\n"
|
1616
|
+
# -> "Content-Type: application/json; charset=utf-8\r\n"
|
1617
|
+
# -> "Content-Length: 2\r\n"
|
1618
|
+
# -> "Connection: keep-alive\r\n"
|
1619
|
+
# -> "X-Powered-By: Express\r\n"
|
1620
|
+
# -> "X-Ratelimit-Limit: 1000\r\n"
|
1621
|
+
# -> "X-Ratelimit-Remaining: 999\r\n"
|
1622
|
+
# -> "X-Ratelimit-Reset: 1670879660\r\n"
|
1623
|
+
# -> "Vary: Origin, Accept-Encoding\r\n"
|
1624
|
+
# -> "Access-Control-Allow-Credentials: true\r\n"
|
1625
|
+
# -> "Cache-Control: max-age=43200\r\n"
|
1626
|
+
# -> "Pragma: no-cache\r\n"
|
1627
|
+
# -> "Expires: -1\r\n"
|
1628
|
+
# -> "X-Content-Type-Options: nosniff\r\n"
|
1629
|
+
# -> "Etag: W/\"2-vyGp6PvFo4RvsFtPoIWeCReyIC8\"\r\n"
|
1630
|
+
# -> "Via: 1.1 vegur\r\n"
|
1631
|
+
# -> "CF-Cache-Status: MISS\r\n"
|
1632
|
+
# -> "Server-Timing: cf-q-config;dur=1.3000000762986e-05\r\n"
|
1633
|
+
# -> "Report-To: {\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=yOr40jo%2BwS1KHzhTlVpl54beJ5Wx2FcG4gGV0XVrh3X9OlR5q4drUn2dkt5DGO4GDcE%2BVXT7CNgJvGs%2BZleIyMu8CLieFiDIvOviOY3EhHg94m0ZNZgrEdpKD0S85S507l1vsEwEHkoTm%2Ff19SiO\"}],\"group\":\"cf-nel\",\"max_age\":604800}\r\n"
|
1634
|
+
# -> "NEL: {\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}\r\n"
|
1635
|
+
# -> "Server: cloudflare\r\n"
|
1636
|
+
# -> "CF-RAY: 778977dc484ce591-DFW\r\n"
|
1637
|
+
# -> "alt-svc: h3=\":443\"; ma=86400, h3-29=\":443\"; ma=86400\r\n"
|
1638
|
+
# -> "\r\n"
|
1639
|
+
# reading 2 bytes...
|
1640
|
+
# -> "{}"
|
1641
|
+
# read 2 bytes
|
1642
|
+
# Conn keep-alive
|
1643
|
+
#
|
1644
|
+
# source://net-http//lib/net/http.rb#1188
|
1645
|
+
def set_debug_output(output); end
|
1646
|
+
|
1647
|
+
# Sets or returns the SSL timeout seconds.
|
1648
|
+
#
|
1649
|
+
# source://net-http//lib/net/http.rb#1504
|
1650
|
+
def ssl_timeout; end
|
1651
|
+
|
1652
|
+
# Sets or returns the SSL timeout seconds.
|
1653
|
+
#
|
1654
|
+
# source://net-http//lib/net/http.rb#1504
|
1655
|
+
def ssl_timeout=(_arg0); end
|
1656
|
+
|
1657
|
+
# Sets or returns the SSL version.
|
1658
|
+
# See {OpenSSL::SSL::SSLContext#ssl_version=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-ssl_version-3D].
|
1659
|
+
#
|
1660
|
+
# source://net-http//lib/net/http.rb#1508
|
1661
|
+
def ssl_version; end
|
1662
|
+
|
1663
|
+
# Sets or returns the SSL version.
|
1664
|
+
# See {OpenSSL::SSL::SSLContext#ssl_version=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#method-i-ssl_version-3D].
|
1665
|
+
#
|
1666
|
+
# source://net-http//lib/net/http.rb#1508
|
1667
|
+
def ssl_version=(_arg0); end
|
1668
|
+
|
1669
|
+
# Starts an \HTTP session.
|
1670
|
+
#
|
1671
|
+
# Without a block, returns +self+:
|
1672
|
+
#
|
1673
|
+
# http = Net::HTTP.new(hostname)
|
1674
|
+
# # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
|
1675
|
+
# http.start
|
1676
|
+
# # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=true>
|
1677
|
+
# http.started? # => true
|
1678
|
+
# http.finish
|
1679
|
+
#
|
1680
|
+
# With a block, calls the block with +self+,
|
1681
|
+
# finishes the session when the block exits,
|
1682
|
+
# and returns the block's value:
|
1683
|
+
#
|
1684
|
+
# http.start do |http|
|
1685
|
+
# http
|
1686
|
+
# end
|
1687
|
+
# # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
|
1688
|
+
# http.started? # => false
|
1689
|
+
#
|
1690
|
+
# @raise [IOError]
|
1691
|
+
#
|
1692
|
+
# source://net-http//lib/net/http.rb#1565
|
1693
|
+
def start; end
|
1694
|
+
|
1695
|
+
# Returns +true+ if the \HTTP session has been started:
|
1696
|
+
#
|
1697
|
+
# http = Net::HTTP.new(hostname)
|
1698
|
+
# http.started? # => false
|
1699
|
+
# http.start
|
1700
|
+
# http.started? # => true
|
1701
|
+
# http.finish # => nil
|
1702
|
+
# http.started? # => false
|
1703
|
+
#
|
1704
|
+
# Net::HTTP.start(hostname) do |http|
|
1705
|
+
# http.started?
|
1706
|
+
# end # => true
|
1707
|
+
# http.started? # => false
|
1708
|
+
#
|
1709
|
+
# @return [Boolean]
|
1710
|
+
#
|
1711
|
+
# source://net-http//lib/net/http.rb#1413
|
1712
|
+
def started?; end
|
1713
|
+
|
1714
|
+
# Sends a TRACE request to the server;
|
1715
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1716
|
+
#
|
1717
|
+
# The request is based on the Net::HTTP::Trace object
|
1718
|
+
# created from string +path+ and initial headers hash +initheader+.
|
1719
|
+
#
|
1720
|
+
# http = Net::HTTP.new(hostname)
|
1721
|
+
# http.trace('/todos/1')
|
1722
|
+
#
|
1723
|
+
# source://net-http//lib/net/http.rb#2150
|
1724
|
+
def trace(path, initheader = T.unsafe(nil)); end
|
1725
|
+
|
1726
|
+
# Sends an UNLOCK request to the server;
|
1727
|
+
# returns an instance of a subclass of Net::HTTPResponse.
|
1728
|
+
#
|
1729
|
+
# The request is based on the Net::HTTP::Unlock object
|
1730
|
+
# created from string +path+, string +body+, and initial headers hash +initheader+.
|
1731
|
+
#
|
1732
|
+
# data = '{"userId": 1, "id": 1, "title": "delectus aut autem", "completed": false}'
|
1733
|
+
# http = Net::HTTP.new(hostname)
|
1734
|
+
# http.unlock('/todos/1', data)
|
1735
|
+
#
|
1736
|
+
# source://net-http//lib/net/http.rb#2057
|
1737
|
+
def unlock(path, body, initheader = T.unsafe(nil)); end
|
1738
|
+
|
1739
|
+
# Sets whether a new session is to use
|
1740
|
+
# {Transport Layer Security}[https://en.wikipedia.org/wiki/Transport_Layer_Security]:
|
1741
|
+
#
|
1742
|
+
# Raises IOError if attempting to change during a session.
|
1743
|
+
#
|
1744
|
+
# Raises OpenSSL::SSL::SSLError if the port is not an HTTPS port.
|
1745
|
+
#
|
1746
|
+
# source://net-http//lib/net/http.rb#1435
|
1747
|
+
def use_ssl=(flag); end
|
1748
|
+
|
1749
|
+
# Returns +true+ if +self+ uses SSL, +false+ otherwise.
|
1750
|
+
# See Net::HTTP#use_ssl=.
|
1751
|
+
#
|
1752
|
+
# @return [Boolean]
|
1753
|
+
#
|
1754
|
+
# source://net-http//lib/net/http.rb#1425
|
1755
|
+
def use_ssl?; end
|
1756
|
+
|
1757
|
+
# Sets or returns the callback for the server certification verification.
|
1758
|
+
#
|
1759
|
+
# source://net-http//lib/net/http.rb#1519
|
1760
|
+
def verify_callback; end
|
1761
|
+
|
1762
|
+
# Sets or returns the callback for the server certification verification.
|
1763
|
+
#
|
1764
|
+
# source://net-http//lib/net/http.rb#1519
|
1765
|
+
def verify_callback=(_arg0); end
|
1766
|
+
|
1767
|
+
# Sets or returns the maximum depth for the certificate chain verification.
|
1768
|
+
#
|
1769
|
+
# source://net-http//lib/net/http.rb#1522
|
1770
|
+
def verify_depth; end
|
1771
|
+
|
1772
|
+
# Sets or returns the maximum depth for the certificate chain verification.
|
1773
|
+
#
|
1774
|
+
# source://net-http//lib/net/http.rb#1522
|
1775
|
+
def verify_depth=(_arg0); end
|
1776
|
+
|
1777
|
+
# Sets or returns whether to verify that the server certificate is valid
|
1778
|
+
# for the hostname.
|
1779
|
+
# See {OpenSSL::SSL::SSLContext#verify_hostname=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#attribute-i-verify_mode].
|
1780
|
+
#
|
1781
|
+
# source://net-http//lib/net/http.rb#1532
|
1782
|
+
def verify_hostname; end
|
1783
|
+
|
1784
|
+
# Sets or returns whether to verify that the server certificate is valid
|
1785
|
+
# for the hostname.
|
1786
|
+
# See {OpenSSL::SSL::SSLContext#verify_hostname=}[https://docs.ruby-lang.org/en/master/OpenSSL/SSL/SSLContext.html#attribute-i-verify_mode].
|
1787
|
+
#
|
1788
|
+
# source://net-http//lib/net/http.rb#1532
|
1789
|
+
def verify_hostname=(_arg0); end
|
1790
|
+
|
1791
|
+
# Sets or returns the flags for server the certification verification
|
1792
|
+
# at the beginning of the SSL/TLS session.
|
1793
|
+
# OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER are acceptable.
|
1794
|
+
#
|
1795
|
+
# source://net-http//lib/net/http.rb#1527
|
1796
|
+
def verify_mode; end
|
1797
|
+
|
1798
|
+
# Sets or returns the flags for server the certification verification
|
1799
|
+
# at the beginning of the SSL/TLS session.
|
1800
|
+
# OpenSSL::SSL::VERIFY_NONE or OpenSSL::SSL::VERIFY_PEER are acceptable.
|
1801
|
+
#
|
1802
|
+
# source://net-http//lib/net/http.rb#1527
|
1803
|
+
def verify_mode=(_arg0); end
|
1804
|
+
|
1805
|
+
# Returns the numeric (\Integer or \Float) number of seconds
|
1806
|
+
# to wait for one block to be written (via one write(2) call);
|
1807
|
+
# see #write_timeout=.
|
1808
|
+
#
|
1809
|
+
# source://net-http//lib/net/http.rb#1306
|
1810
|
+
def write_timeout; end
|
1811
|
+
|
1812
|
+
# Sets the write timeout, in seconds, for +self+ to integer +sec+;
|
1813
|
+
# the initial value is 60.
|
1814
|
+
#
|
1815
|
+
# Argument +sec+ must be a non-negative numeric value:
|
1816
|
+
#
|
1817
|
+
# _uri = uri.dup
|
1818
|
+
# _uri.path = '/posts'
|
1819
|
+
# body = 'bar' * 200000
|
1820
|
+
# data = <<EOF
|
1821
|
+
# {"title": "foo", "body": "#{body}", "userId": "1"}
|
1822
|
+
# EOF
|
1823
|
+
# headers = {'content-type': 'application/json'}
|
1824
|
+
# http = Net::HTTP.new(hostname)
|
1825
|
+
# http.write_timeout # => 60
|
1826
|
+
# http.post(_uri.path, data, headers)
|
1827
|
+
# # => #<Net::HTTPCreated 201 Created readbody=true>
|
1828
|
+
# http.write_timeout = 0
|
1829
|
+
# http.post(_uri.path, data, headers) # Raises Net::WriteTimeout.
|
1830
|
+
#
|
1831
|
+
# source://net-http//lib/net/http.rb#1367
|
1832
|
+
def write_timeout=(sec); end
|
1833
|
+
|
1834
|
+
private
|
1835
|
+
|
1836
|
+
# Adds a message to debugging output
|
1837
|
+
#
|
1838
|
+
# source://net-http//lib/net/http.rb#2472
|
1839
|
+
def D(msg); end
|
1840
|
+
|
1841
|
+
# source://net-http//lib/net/http.rb#2464
|
1842
|
+
def addr_port; end
|
1843
|
+
|
1844
|
+
# source://net-http//lib/net/http.rb#2381
|
1845
|
+
def begin_transport(req); end
|
1846
|
+
|
1847
|
+
# without proxy, obsolete
|
1848
|
+
#
|
1849
|
+
# source://net-http//lib/net/http.rb#1859
|
1850
|
+
def conn_address; end
|
1851
|
+
|
1852
|
+
# source://net-http//lib/net/http.rb#1863
|
1853
|
+
def conn_port; end
|
1854
|
+
|
1855
|
+
# source://net-http//lib/net/http.rb#1585
|
1856
|
+
def connect; end
|
1857
|
+
|
1858
|
+
# Adds a message to debugging output
|
1859
|
+
#
|
1860
|
+
# source://net-http//lib/net/http.rb#2472
|
1861
|
+
def debug(msg); end
|
1862
|
+
|
1863
|
+
# source://net-http//lib/net/http.rb#1713
|
1864
|
+
def do_finish; end
|
1865
|
+
|
1866
|
+
# source://net-http//lib/net/http.rb#1579
|
1867
|
+
def do_start; end
|
1868
|
+
|
1869
|
+
# source://net-http//lib/net/http.rb#1867
|
1870
|
+
def edit_path(path); end
|
1871
|
+
|
1872
|
+
# source://net-http//lib/net/http.rb#2404
|
1873
|
+
def end_transport(req, res); end
|
1874
|
+
|
1875
|
+
# @return [Boolean]
|
1876
|
+
#
|
1877
|
+
# source://net-http//lib/net/http.rb#2421
|
1878
|
+
def keep_alive?(req, res); end
|
1879
|
+
|
1880
|
+
# source://net-http//lib/net/http.rb#1695
|
1881
|
+
def on_connect; end
|
1882
|
+
|
1883
|
+
# Executes a request which uses a representation
|
1884
|
+
# and returns its body.
|
1885
|
+
#
|
1886
|
+
# source://net-http//lib/net/http.rb#2318
|
1887
|
+
def send_entity(path, data, initheader, dest, type, &block); end
|
1888
|
+
|
1889
|
+
# source://net-http//lib/net/http.rb#2445
|
1890
|
+
def sspi_auth(req); end
|
1891
|
+
|
1892
|
+
# @return [Boolean]
|
1893
|
+
#
|
1894
|
+
# source://net-http//lib/net/http.rb#2430
|
1895
|
+
def sspi_auth?(res); end
|
1896
|
+
|
1897
|
+
# source://net-http//lib/net/http.rb#2329
|
1898
|
+
def transport_request(req); end
|
1899
|
+
|
1900
|
+
# source://net-http//lib/net/http.rb#1852
|
1901
|
+
def unescape(value); end
|
1902
|
+
|
1903
|
+
class << self
|
1904
|
+
# Creates an \HTTP proxy class which behaves like \Net::HTTP, but
|
1905
|
+
# performs all access via the specified proxy.
|
1906
|
+
#
|
1907
|
+
# This class is obsolete. You may pass these same parameters directly to
|
1908
|
+
# \Net::HTTP.new. See Net::HTTP.new for details of the arguments.
|
1909
|
+
#
|
1910
|
+
# source://net-http//lib/net/http.rb#1739
|
1911
|
+
def Proxy(p_addr = T.unsafe(nil), p_port = T.unsafe(nil), p_user = T.unsafe(nil), p_pass = T.unsafe(nil)); end
|
1912
|
+
|
1913
|
+
# Returns integer +80+, the default port to use for \HTTP requests:
|
1914
|
+
#
|
1915
|
+
# Net::HTTP.default_port # => 80
|
1916
|
+
#
|
1917
|
+
# source://net-http//lib/net/http.rb#900
|
1918
|
+
def default_port; end
|
1919
|
+
|
1920
|
+
# :call-seq:
|
1921
|
+
# Net::HTTP.get(hostname, path, port = 80) -> body
|
1922
|
+
# Net::HTTP:get(uri, headers = {}, port = uri.port) -> body
|
1923
|
+
#
|
1924
|
+
# Sends a GET request and returns the \HTTP response body as a string.
|
1925
|
+
#
|
1926
|
+
# With string arguments +hostname+ and +path+:
|
1927
|
+
#
|
1928
|
+
# hostname = 'jsonplaceholder.typicode.com'
|
1929
|
+
# path = '/todos/1'
|
1930
|
+
# puts Net::HTTP.get(hostname, path)
|
1931
|
+
#
|
1932
|
+
# Output:
|
1933
|
+
#
|
1934
|
+
# {
|
1935
|
+
# "userId": 1,
|
1936
|
+
# "id": 1,
|
1937
|
+
# "title": "delectus aut autem",
|
1938
|
+
# "completed": false
|
1939
|
+
# }
|
1940
|
+
#
|
1941
|
+
# With URI object +uri+ and optional hash argument +headers+:
|
1942
|
+
#
|
1943
|
+
# uri = URI('https://jsonplaceholder.typicode.com/todos/1')
|
1944
|
+
# headers = {'Content-type' => 'application/json; charset=UTF-8'}
|
1945
|
+
# Net::HTTP.get(uri, headers)
|
1946
|
+
#
|
1947
|
+
# Related:
|
1948
|
+
#
|
1949
|
+
# - Net::HTTP::Get: request class for \HTTP method +GET+.
|
1950
|
+
# - Net::HTTP#get: convenience method for \HTTP method +GET+.
|
1951
|
+
#
|
1952
|
+
# source://net-http//lib/net/http.rb#802
|
1953
|
+
def get(uri_or_host, path_or_headers = T.unsafe(nil), port = T.unsafe(nil)); end
|
1954
|
+
|
1955
|
+
# :call-seq:
|
1956
|
+
# Net::HTTP.get_print(hostname, path, port = 80) -> nil
|
1957
|
+
# Net::HTTP:get_print(uri, headers = {}, port = uri.port) -> nil
|
1958
|
+
#
|
1959
|
+
# Like Net::HTTP.get, but writes the returned body to $stdout;
|
1960
|
+
# returns +nil+.
|
1961
|
+
#
|
1962
|
+
# source://net-http//lib/net/http.rb#761
|
1963
|
+
def get_print(uri_or_host, path_or_headers = T.unsafe(nil), port = T.unsafe(nil)); end
|
1964
|
+
|
1965
|
+
# :call-seq:
|
1966
|
+
# Net::HTTP.get_response(hostname, path, port = 80) -> http_response
|
1967
|
+
# Net::HTTP:get_response(uri, headers = {}, port = uri.port) -> http_response
|
1968
|
+
#
|
1969
|
+
# Like Net::HTTP.get, but returns a Net::HTTPResponse object
|
1970
|
+
# instead of the body string.
|
1971
|
+
#
|
1972
|
+
# source://net-http//lib/net/http.rb#812
|
1973
|
+
def get_response(uri_or_host, path_or_headers = T.unsafe(nil), port = T.unsafe(nil), &block); end
|
1974
|
+
|
1975
|
+
# Returns integer +80+, the default port to use for \HTTP requests:
|
1976
|
+
#
|
1977
|
+
# Net::HTTP.http_default_port # => 80
|
1978
|
+
#
|
1979
|
+
# source://net-http//lib/net/http.rb#908
|
1980
|
+
def http_default_port; end
|
1981
|
+
|
1982
|
+
# Returns integer +443+, the default port to use for HTTPS requests:
|
1983
|
+
#
|
1984
|
+
# Net::HTTP.https_default_port # => 443
|
1985
|
+
#
|
1986
|
+
# source://net-http//lib/net/http.rb#916
|
1987
|
+
def https_default_port; end
|
1988
|
+
|
1989
|
+
# Returns +false+; retained for compatibility.
|
1990
|
+
#
|
1991
|
+
# @return [Boolean]
|
1992
|
+
#
|
1993
|
+
# source://net-http//lib/net/http.rb#746
|
1994
|
+
def is_version_1_1?; end
|
1995
|
+
|
1996
|
+
# Returns +true+; retained for compatibility.
|
1997
|
+
#
|
1998
|
+
# @return [Boolean]
|
1999
|
+
#
|
2000
|
+
# source://net-http//lib/net/http.rb#741
|
2001
|
+
def is_version_1_2?; end
|
2002
|
+
|
2003
|
+
# Returns a new \Net::HTTP object +http+
|
2004
|
+
# (but does not open a TCP connection or \HTTP session).
|
2005
|
+
#
|
2006
|
+
# With only string argument +address+ given
|
2007
|
+
# (and <tt>ENV['http_proxy']</tt> undefined or +nil+),
|
2008
|
+
# the returned +http+:
|
2009
|
+
#
|
2010
|
+
# - Has the given address.
|
2011
|
+
# - Has the default port number, Net::HTTP.default_port (80).
|
2012
|
+
# - Has no proxy.
|
2013
|
+
#
|
2014
|
+
# Example:
|
2015
|
+
#
|
2016
|
+
# http = Net::HTTP.new(hostname)
|
2017
|
+
# # => #<Net::HTTP jsonplaceholder.typicode.com:80 open=false>
|
2018
|
+
# http.address # => "jsonplaceholder.typicode.com"
|
2019
|
+
# http.port # => 80
|
2020
|
+
# http.proxy? # => false
|
2021
|
+
#
|
2022
|
+
# With integer argument +port+ also given,
|
2023
|
+
# the returned +http+ has the given port:
|
2024
|
+
#
|
2025
|
+
# http = Net::HTTP.new(hostname, 8000)
|
2026
|
+
# # => #<Net::HTTP jsonplaceholder.typicode.com:8000 open=false>
|
2027
|
+
# http.port # => 8000
|
2028
|
+
#
|
2029
|
+
# For proxy-defining arguments +p_addr+ through +p_no_proxy+,
|
2030
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
2031
|
+
#
|
2032
|
+
# source://net-http//lib/net/http.rb#1065
|
2033
|
+
def new(address, port = T.unsafe(nil), p_addr = T.unsafe(nil), p_port = T.unsafe(nil), p_user = T.unsafe(nil), p_pass = T.unsafe(nil), p_no_proxy = T.unsafe(nil)); end
|
2034
|
+
|
2035
|
+
# Posts data to a host; returns a Net::HTTPResponse object.
|
2036
|
+
#
|
2037
|
+
# Argument +url+ must be a URL;
|
2038
|
+
# argument +data+ must be a string:
|
2039
|
+
#
|
2040
|
+
# _uri = uri.dup
|
2041
|
+
# _uri.path = '/posts'
|
2042
|
+
# data = '{"title": "foo", "body": "bar", "userId": 1}'
|
2043
|
+
# headers = {'content-type': 'application/json'}
|
2044
|
+
# res = Net::HTTP.post(_uri, data, headers) # => #<Net::HTTPCreated 201 Created readbody=true>
|
2045
|
+
# puts res.body
|
2046
|
+
#
|
2047
|
+
# Output:
|
2048
|
+
#
|
2049
|
+
# {
|
2050
|
+
# "title": "foo",
|
2051
|
+
# "body": "bar",
|
2052
|
+
# "userId": 1,
|
2053
|
+
# "id": 101
|
2054
|
+
# }
|
2055
|
+
#
|
2056
|
+
# Related:
|
2057
|
+
#
|
2058
|
+
# - Net::HTTP::Post: request class for \HTTP method +POST+.
|
2059
|
+
# - Net::HTTP#post: convenience method for \HTTP method +POST+.
|
2060
|
+
#
|
2061
|
+
# source://net-http//lib/net/http.rb#855
|
2062
|
+
def post(url, data, header = T.unsafe(nil)); end
|
2063
|
+
|
2064
|
+
# Posts data to a host; returns a Net::HTTPResponse object.
|
2065
|
+
#
|
2066
|
+
# Argument +url+ must be a URI;
|
2067
|
+
# argument +data+ must be a hash:
|
2068
|
+
#
|
2069
|
+
# _uri = uri.dup
|
2070
|
+
# _uri.path = '/posts'
|
2071
|
+
# data = {title: 'foo', body: 'bar', userId: 1}
|
2072
|
+
# res = Net::HTTP.post_form(_uri, data) # => #<Net::HTTPCreated 201 Created readbody=true>
|
2073
|
+
# puts res.body
|
2074
|
+
#
|
2075
|
+
# Output:
|
2076
|
+
#
|
2077
|
+
# {
|
2078
|
+
# "title": "foo",
|
2079
|
+
# "body": "bar",
|
2080
|
+
# "userId": "1",
|
2081
|
+
# "id": 101
|
2082
|
+
# }
|
2083
|
+
#
|
2084
|
+
# source://net-http//lib/net/http.rb#882
|
2085
|
+
def post_form(url, params); end
|
2086
|
+
|
2087
|
+
# Returns the address of the proxy host, or +nil+ if none;
|
2088
|
+
# see Net::HTTP@Proxy+Server.
|
2089
|
+
#
|
2090
|
+
# source://net-http//lib/net/http.rb#1768
|
2091
|
+
def proxy_address; end
|
2092
|
+
|
2093
|
+
# Returns true if self is a class which was created by HTTP::Proxy.
|
2094
|
+
#
|
2095
|
+
# @return [Boolean]
|
2096
|
+
#
|
2097
|
+
# source://net-http//lib/net/http.rb#1762
|
2098
|
+
def proxy_class?; end
|
2099
|
+
|
2100
|
+
# Returns the password for accessing the proxy, or +nil+ if none;
|
2101
|
+
# see Net::HTTP@Proxy+Server.
|
2102
|
+
#
|
2103
|
+
# source://net-http//lib/net/http.rb#1780
|
2104
|
+
def proxy_pass; end
|
2105
|
+
|
2106
|
+
# Returns the port number of the proxy host, or +nil+ if none;
|
2107
|
+
# see Net::HTTP@Proxy+Server.
|
2108
|
+
#
|
2109
|
+
# source://net-http//lib/net/http.rb#1772
|
2110
|
+
def proxy_port; end
|
2111
|
+
|
2112
|
+
# Returns the user name for accessing the proxy, or +nil+ if none;
|
2113
|
+
# see Net::HTTP@Proxy+Server.
|
2114
|
+
#
|
2115
|
+
# source://net-http//lib/net/http.rb#1776
|
2116
|
+
def proxy_user; end
|
2117
|
+
|
2118
|
+
# source://net-http//lib/net/http.rb#920
|
2119
|
+
def socket_type; end
|
2120
|
+
|
2121
|
+
# :call-seq:
|
2122
|
+
# HTTP.start(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, opts) -> http
|
2123
|
+
# HTTP.start(address, port = nil, p_addr = :ENV, p_port = nil, p_user = nil, p_pass = nil, opts) {|http| ... } -> object
|
2124
|
+
#
|
2125
|
+
# Creates a new \Net::HTTP object, +http+, via \Net::HTTP.new:
|
2126
|
+
#
|
2127
|
+
# - For arguments +address+ and +port+, see Net::HTTP.new.
|
2128
|
+
# - For proxy-defining arguments +p_addr+ through +p_pass+,
|
2129
|
+
# see {Proxy Server}[rdoc-ref:Net::HTTP@Proxy+Server].
|
2130
|
+
# - For argument +opts+, see below.
|
2131
|
+
#
|
2132
|
+
# With no block given:
|
2133
|
+
#
|
2134
|
+
# - Calls <tt>http.start</tt> with no block (see #start),
|
2135
|
+
# which opens a TCP connection and \HTTP session.
|
2136
|
+
# - Returns +http+.
|
2137
|
+
# - The caller should call #finish to close the session:
|
2138
|
+
#
|
2139
|
+
# http = Net::HTTP.start(hostname)
|
2140
|
+
# http.started? # => true
|
2141
|
+
# http.finish
|
2142
|
+
# http.started? # => false
|
2143
|
+
#
|
2144
|
+
# With a block given:
|
2145
|
+
#
|
2146
|
+
# - Calls <tt>http.start</tt> with the block (see #start), which:
|
2147
|
+
#
|
2148
|
+
# - Opens a TCP connection and \HTTP session.
|
2149
|
+
# - Calls the block,
|
2150
|
+
# which may make any number of requests to the host.
|
2151
|
+
# - Closes the \HTTP session and TCP connection on block exit.
|
2152
|
+
# - Returns the block's value +object+.
|
2153
|
+
#
|
2154
|
+
# - Returns +object+.
|
2155
|
+
#
|
2156
|
+
# Example:
|
2157
|
+
#
|
2158
|
+
# hostname = 'jsonplaceholder.typicode.com'
|
2159
|
+
# Net::HTTP.start(hostname) do |http|
|
2160
|
+
# puts http.get('/todos/1').body
|
2161
|
+
# puts http.get('/todos/2').body
|
2162
|
+
# end
|
2163
|
+
#
|
2164
|
+
# Output:
|
2165
|
+
#
|
2166
|
+
# {
|
2167
|
+
# "userId": 1,
|
2168
|
+
# "id": 1,
|
2169
|
+
# "title": "delectus aut autem",
|
2170
|
+
# "completed": false
|
2171
|
+
# }
|
2172
|
+
# {
|
2173
|
+
# "userId": 1,
|
2174
|
+
# "id": 2,
|
2175
|
+
# "title": "quis ut nam facilis et officia qui",
|
2176
|
+
# "completed": false
|
2177
|
+
# }
|
2178
|
+
#
|
2179
|
+
# If the last argument given is a hash, it is the +opts+ hash,
|
2180
|
+
# where each key is a method or accessor to be called,
|
2181
|
+
# and its value is the value to be set.
|
2182
|
+
#
|
2183
|
+
# The keys may include:
|
2184
|
+
#
|
2185
|
+
# - #ca_file
|
2186
|
+
# - #ca_path
|
2187
|
+
# - #cert
|
2188
|
+
# - #cert_store
|
2189
|
+
# - #ciphers
|
2190
|
+
# - #close_on_empty_response
|
2191
|
+
# - +ipaddr+ (calls #ipaddr=)
|
2192
|
+
# - #keep_alive_timeout
|
2193
|
+
# - #key
|
2194
|
+
# - #open_timeout
|
2195
|
+
# - #read_timeout
|
2196
|
+
# - #ssl_timeout
|
2197
|
+
# - #ssl_version
|
2198
|
+
# - +use_ssl+ (calls #use_ssl=)
|
2199
|
+
# - #verify_callback
|
2200
|
+
# - #verify_depth
|
2201
|
+
# - #verify_mode
|
2202
|
+
# - #write_timeout
|
2203
|
+
#
|
2204
|
+
# Note: If +port+ is +nil+ and <tt>opts[:use_ssl]</tt> is a truthy value,
|
2205
|
+
# the value passed to +new+ is Net::HTTP.https_default_port, not +port+.
|
2206
|
+
#
|
2207
|
+
# source://net-http//lib/net/http.rb#1010
|
2208
|
+
def start(address, *arg, &block); end
|
2209
|
+
|
2210
|
+
# Returns +false+; retained for compatibility.
|
2211
|
+
#
|
2212
|
+
# @return [Boolean]
|
2213
|
+
#
|
2214
|
+
# source://net-http//lib/net/http.rb#746
|
2215
|
+
def version_1_1?; end
|
2216
|
+
|
2217
|
+
# Returns +true+; retained for compatibility.
|
2218
|
+
#
|
2219
|
+
# source://net-http//lib/net/http.rb#736
|
2220
|
+
def version_1_2; end
|
2221
|
+
|
2222
|
+
# Returns +true+; retained for compatibility.
|
2223
|
+
#
|
2224
|
+
# @return [Boolean]
|
2225
|
+
#
|
2226
|
+
# source://net-http//lib/net/http.rb#741
|
2227
|
+
def version_1_2?; end
|
2228
|
+
end
|
2229
|
+
end
|
2230
|
+
|
2231
|
+
# source://net-http//lib/net/http/proxy_delta.rb#2
|
2232
|
+
module Net::HTTP::ProxyDelta
|
2233
|
+
private
|
2234
|
+
|
2235
|
+
# source://net-http//lib/net/http/proxy_delta.rb#5
|
2236
|
+
def conn_address; end
|
2237
|
+
|
2238
|
+
# source://net-http//lib/net/http/proxy_delta.rb#9
|
2239
|
+
def conn_port; end
|
2240
|
+
|
2241
|
+
# source://net-http//lib/net/http/proxy_delta.rb#13
|
2242
|
+
def edit_path(path); end
|
2243
|
+
end
|
2244
|
+
|
2245
|
+
# source://net-http//lib/net/http/backward.rb#7
|
2246
|
+
Net::HTTP::ProxyMod = Net::HTTP::ProxyDelta
|
2247
|
+
|
2248
|
+
# :stopdoc:
|
2249
|
+
#
|
2250
|
+
# source://net-http//lib/net/http.rb#725
|
2251
|
+
Net::HTTP::VERSION = T.let(T.unsafe(nil), String)
|
2252
|
+
|
2253
|
+
# Response class for <tt>Already Reported (WebDAV)</tt> responses (status code 208).
|
2254
|
+
#
|
2255
|
+
# The <tt>Already Reported (WebDAV)</tt> response indicates that the server
|
2256
|
+
# has received the request,
|
2257
|
+
# and that the members of a DAV binding have already been enumerated
|
2258
|
+
# in a preceding part of the (multi-status) response,
|
2259
|
+
# and are not being included again.
|
2260
|
+
#
|
2261
|
+
# :include: doc/net-http/included_getters.rdoc
|
2262
|
+
#
|
2263
|
+
# References:
|
2264
|
+
#
|
2265
|
+
# - {RFC 5842}[https://www.rfc-editor.org/rfc/rfc5842.html#section-7.1].
|
2266
|
+
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#208].
|
2267
|
+
#
|
2268
|
+
# source://net-http//lib/net/http/responses.rb#306
|
2269
|
+
class Net::HTTPAlreadyReported < ::Net::HTTPSuccess; end
|
2270
|
+
|
2271
|
+
# source://net-http//lib/net/http/responses.rb#307
|
2272
|
+
Net::HTTPAlreadyReported::HAS_BODY = T.let(T.unsafe(nil), TrueClass)
|
2273
|
+
|
2274
|
+
# source://net-http//lib/net/http/responses.rb#67
|
2275
|
+
Net::HTTPClientError::EXCEPTION_TYPE = Net::HTTPClientException
|
2276
|
+
|
2277
|
+
# source://net-http//lib/net/http/backward.rb#23
|
2278
|
+
Net::HTTPClientErrorCode = Net::HTTPClientError
|
2279
|
+
|
2280
|
+
# Response class for <tt>Early Hints</tt> responses (status code 103).
|
2281
|
+
#
|
2282
|
+
# The <tt>Early Hints</tt> indicates that the server has received
|
2283
|
+
# and is processing the request, and contains certain headers;
|
2284
|
+
# the final response is not available yet.
|
2285
|
+
#
|
2286
|
+
# :include: doc/net-http/included_getters.rdoc
|
2287
|
+
#
|
2288
|
+
# References:
|
2289
|
+
#
|
2290
|
+
# - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/103].
|
2291
|
+
# - {RFC 8297}[https://www.rfc-editor.org/rfc/rfc8297.html#section-2].
|
2292
|
+
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#103].
|
2293
|
+
#
|
2294
|
+
# source://net-http//lib/net/http/responses.rb#147
|
2295
|
+
class Net::HTTPEarlyHints < ::Net::HTTPInformation; end
|
2296
|
+
|
2297
|
+
# source://net-http//lib/net/http/responses.rb#148
|
2298
|
+
Net::HTTPEarlyHints::HAS_BODY = T.let(T.unsafe(nil), FalseClass)
|
2299
|
+
|
2300
|
+
# source://net-http//lib/net/http/backward.rb#24
|
2301
|
+
Net::HTTPFatalErrorCode = Net::HTTPClientError
|
2302
|
+
|
2303
|
+
# \HTTPGenericRequest is the parent of the Net::HTTPRequest class.
|
2304
|
+
#
|
2305
|
+
# Do not use this directly; instead, use a subclass of Net::HTTPRequest.
|
2306
|
+
#
|
2307
|
+
# == About the Examples
|
2308
|
+
#
|
2309
|
+
# :include: doc/net-http/examples.rdoc
|
2310
|
+
#
|
2311
|
+
# source://net-http//lib/net/http/generic_request.rb#11
|
2312
|
+
class Net::HTTPGenericRequest
|
2313
|
+
include ::Net::HTTPHeader
|
2314
|
+
|
2315
|
+
# @return [HTTPGenericRequest] a new instance of HTTPGenericRequest
|
2316
|
+
#
|
2317
|
+
# source://net-http//lib/net/http/generic_request.rb#15
|
2318
|
+
def initialize(m, reqbody, resbody, uri_or_path, initheader = T.unsafe(nil)); end
|
2319
|
+
|
2320
|
+
# Don't automatically decode response content-encoding if the user indicates
|
2321
|
+
# they want to handle it.
|
2322
|
+
#
|
2323
|
+
# source://net-http//lib/net/http/generic_request.rb#109
|
2324
|
+
def []=(key, val); end
|
2325
|
+
|
2326
|
+
# Returns the string body for the request, or +nil+ if there is none:
|
2327
|
+
#
|
2328
|
+
# req = Net::HTTP::Post.new(uri)
|
2329
|
+
# req.body # => nil
|
2330
|
+
# req.body = '{"title": "foo","body": "bar","userId": 1}'
|
2331
|
+
# req.body # => "{\"title\": \"foo\",\"body\": \"bar\",\"userId\": 1}"
|
2332
|
+
#
|
2333
|
+
# source://net-http//lib/net/http/generic_request.rb#145
|
2334
|
+
def body; end
|
2335
|
+
|
2336
|
+
# Sets the body for the request:
|
2337
|
+
#
|
2338
|
+
# req = Net::HTTP::Post.new(uri)
|
2339
|
+
# req.body # => nil
|
2340
|
+
# req.body = '{"title": "foo","body": "bar","userId": 1}'
|
2341
|
+
# req.body # => "{\"title\": \"foo\",\"body\": \"bar\",\"userId\": 1}"
|
2342
|
+
#
|
2343
|
+
# source://net-http//lib/net/http/generic_request.rb#154
|
2344
|
+
def body=(str); end
|
2345
|
+
|
2346
|
+
# @return [Boolean]
|
2347
|
+
#
|
2348
|
+
# source://net-http//lib/net/http/generic_request.rb#133
|
2349
|
+
def body_exist?; end
|
2350
|
+
|
2351
|
+
# Returns the body stream object for the request, or +nil+ if there is none:
|
2352
|
+
#
|
2353
|
+
# req = Net::HTTP::Post.new(uri) # => #<Net::HTTP::Post POST>
|
2354
|
+
# req.body_stream # => nil
|
2355
|
+
# require 'stringio'
|
2356
|
+
# req.body_stream = StringIO.new('xyzzy') # => #<StringIO:0x0000027d1e5affa8>
|
2357
|
+
# req.body_stream # => #<StringIO:0x0000027d1e5affa8>
|
2358
|
+
#
|
2359
|
+
# source://net-http//lib/net/http/generic_request.rb#169
|
2360
|
+
def body_stream; end
|
2361
|
+
|
2362
|
+
# Sets the body stream for the request:
|
2363
|
+
#
|
2364
|
+
# req = Net::HTTP::Post.new(uri) # => #<Net::HTTP::Post POST>
|
2365
|
+
# req.body_stream # => nil
|
2366
|
+
# require 'stringio'
|
2367
|
+
# req.body_stream = StringIO.new('xyzzy') # => #<StringIO:0x0000027d1e5affa8>
|
2368
|
+
# req.body_stream # => #<StringIO:0x0000027d1e5affa8>
|
2369
|
+
#
|
2370
|
+
# source://net-http//lib/net/http/generic_request.rb#179
|
2371
|
+
def body_stream=(input); end
|
2372
|
+
|
2373
|
+
# Returns +false+ if the request's header <tt>'Accept-Encoding'</tt>
|
2374
|
+
# has been set manually or deleted
|
2375
|
+
# (indicating that the user intends to handle encoding in the response),
|
2376
|
+
# +true+ otherwise:
|
2377
|
+
#
|
2378
|
+
# req = Net::HTTP::Get.new(uri) # => #<Net::HTTP::Get GET>
|
2379
|
+
# req['Accept-Encoding'] # => "gzip;q=1.0,deflate;q=0.6,identity;q=0.3"
|
2380
|
+
# req.decode_content # => true
|
2381
|
+
# req['Accept-Encoding'] = 'foo'
|
2382
|
+
# req.decode_content # => false
|
2383
|
+
# req.delete('Accept-Encoding')
|
2384
|
+
# req.decode_content # => false
|
2385
|
+
#
|
2386
|
+
# source://net-http//lib/net/http/generic_request.rb#95
|
2387
|
+
def decode_content; end
|
2388
|
+
|
2389
|
+
# write
|
2390
|
+
#
|
2391
|
+
# source://net-http//lib/net/http/generic_request.rb#198
|
2392
|
+
def exec(sock, ver, path); end
|
2393
|
+
|
2394
|
+
# Returns a string representation of the request:
|
2395
|
+
#
|
2396
|
+
# Net::HTTP::Post.new(uri).inspect # => "#<Net::HTTP::Post POST>"
|
2397
|
+
#
|
2398
|
+
# source://net-http//lib/net/http/generic_request.rb#101
|
2399
|
+
def inspect; end
|
2400
|
+
|
2401
|
+
# Returns the string method name for the request:
|
2402
|
+
#
|
2403
|
+
# Net::HTTP::Get.new(uri).method # => "GET"
|
2404
|
+
# Net::HTTP::Post.new(uri).method # => "POST"
|
2405
|
+
#
|
2406
|
+
# source://net-http//lib/net/http/generic_request.rb#65
|
2407
|
+
def method; end
|
2408
|
+
|
2409
|
+
# Returns the string path for the request:
|
2410
|
+
#
|
2411
|
+
# Net::HTTP::Get.new(uri).path # => "/"
|
2412
|
+
# Net::HTTP::Post.new('example.com').path # => "example.com"
|
2413
|
+
#
|
2414
|
+
# source://net-http//lib/net/http/generic_request.rb#72
|
2415
|
+
def path; end
|
2416
|
+
|
2417
|
+
# Returns whether the request may have a body:
|
2418
|
+
#
|
2419
|
+
# Net::HTTP::Post.new(uri).request_body_permitted? # => true
|
2420
|
+
# Net::HTTP::Get.new(uri).request_body_permitted? # => false
|
2421
|
+
#
|
2422
|
+
# @return [Boolean]
|
2423
|
+
#
|
2424
|
+
# source://net-http//lib/net/http/generic_request.rb#120
|
2425
|
+
def request_body_permitted?; end
|
2426
|
+
|
2427
|
+
# Returns whether the response may have a body:
|
2428
|
+
#
|
2429
|
+
# Net::HTTP::Post.new(uri).response_body_permitted? # => true
|
2430
|
+
# Net::HTTP::Head.new(uri).response_body_permitted? # => false
|
2431
|
+
#
|
2432
|
+
# @return [Boolean]
|
2433
|
+
#
|
2434
|
+
# source://net-http//lib/net/http/generic_request.rb#129
|
2435
|
+
def response_body_permitted?; end
|
2436
|
+
|
2437
|
+
# @raise [ArgumentError]
|
2438
|
+
#
|
2439
|
+
# source://net-http//lib/net/http/generic_request.rb#186
|
2440
|
+
def set_body_internal(str); end
|
2441
|
+
|
2442
|
+
# source://net-http//lib/net/http/generic_request.rb#210
|
2443
|
+
def update_uri(addr, port, ssl); end
|
2444
|
+
|
2445
|
+
# Returns the URI object for the request, or +nil+ if none:
|
2446
|
+
#
|
2447
|
+
# Net::HTTP::Get.new(uri).uri
|
2448
|
+
# # => #<URI::HTTPS https://jsonplaceholder.typicode.com/>
|
2449
|
+
# Net::HTTP::Get.new('example.com').uri # => nil
|
2450
|
+
#
|
2451
|
+
# source://net-http//lib/net/http/generic_request.rb#80
|
2452
|
+
def uri; end
|
2453
|
+
|
2454
|
+
private
|
2455
|
+
|
2456
|
+
# source://net-http//lib/net/http/generic_request.rb#312
|
2457
|
+
def encode_multipart_form_data(out, params, opt); end
|
2458
|
+
|
2459
|
+
# source://net-http//lib/net/http/generic_request.rb#368
|
2460
|
+
def flush_buffer(out, buf, chunked_p); end
|
2461
|
+
|
2462
|
+
# source://net-http//lib/net/http/generic_request.rb#363
|
2463
|
+
def quote_string(str, charset); end
|
2464
|
+
|
2465
|
+
# source://net-http//lib/net/http/generic_request.rb#260
|
2466
|
+
def send_request_with_body(sock, ver, path, body); end
|
2467
|
+
|
2468
|
+
# source://net-http//lib/net/http/generic_request.rb#286
|
2469
|
+
def send_request_with_body_data(sock, ver, path, params); end
|
2470
|
+
|
2471
|
+
# source://net-http//lib/net/http/generic_request.rb#269
|
2472
|
+
def send_request_with_body_stream(sock, ver, path, f); end
|
2473
|
+
|
2474
|
+
# source://net-http//lib/net/http/generic_request.rb#376
|
2475
|
+
def supply_default_content_type; end
|
2476
|
+
|
2477
|
+
# Waits up to the continue timeout for a response from the server provided
|
2478
|
+
# we're speaking HTTP 1.1 and are expecting a 100-continue response.
|
2479
|
+
#
|
2480
|
+
# source://net-http//lib/net/http/generic_request.rb#386
|
2481
|
+
def wait_for_continue(sock, ver); end
|
2482
|
+
|
2483
|
+
# source://net-http//lib/net/http/generic_request.rb#399
|
2484
|
+
def write_header(sock, ver, path); end
|
2485
|
+
end
|
2486
|
+
|
2487
|
+
# source://net-http//lib/net/http/generic_request.rb#242
|
2488
|
+
class Net::HTTPGenericRequest::Chunker
|
2489
|
+
# @return [Chunker] a new instance of Chunker
|
2490
|
+
#
|
2491
|
+
# source://net-http//lib/net/http/generic_request.rb#243
|
2492
|
+
def initialize(sock); end
|
2493
|
+
|
2494
|
+
# source://net-http//lib/net/http/generic_request.rb#255
|
2495
|
+
def finish; end
|
2496
|
+
|
2497
|
+
# source://net-http//lib/net/http/generic_request.rb#248
|
2498
|
+
def write(buf); end
|
2499
|
+
end
|
2500
|
+
|
2501
|
+
# The \HTTPHeader module provides access to \HTTP headers.
|
2502
|
+
#
|
2503
|
+
# The module is included in:
|
2504
|
+
#
|
2505
|
+
# - Net::HTTPGenericRequest (and therefore Net::HTTPRequest).
|
2506
|
+
# - Net::HTTPResponse.
|
2507
|
+
#
|
2508
|
+
# The headers are a hash-like collection of key/value pairs called _fields_.
|
2509
|
+
#
|
2510
|
+
# == Request and Response Fields
|
2511
|
+
#
|
2512
|
+
# Headers may be included in:
|
2513
|
+
#
|
2514
|
+
# - A Net::HTTPRequest object:
|
2515
|
+
# the object's headers will be sent with the request.
|
2516
|
+
# Any fields may be defined in the request;
|
2517
|
+
# see {Setters}[rdoc-ref:Net::HTTPHeader@Setters].
|
2518
|
+
# - A Net::HTTPResponse object:
|
2519
|
+
# the objects headers are usually those returned from the host.
|
2520
|
+
# Fields may be retrieved from the object;
|
2521
|
+
# see {Getters}[rdoc-ref:Net::HTTPHeader@Getters]
|
2522
|
+
# and {Iterators}[rdoc-ref:Net::HTTPHeader@Iterators].
|
2523
|
+
#
|
2524
|
+
# Exactly which fields should be sent or expected depends on the host;
|
2525
|
+
# see:
|
2526
|
+
#
|
2527
|
+
# - {Request fields}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Request_fields].
|
2528
|
+
# - {Response fields}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#Response_fields].
|
2529
|
+
#
|
2530
|
+
# == About the Examples
|
2531
|
+
#
|
2532
|
+
# :include: doc/net-http/examples.rdoc
|
2533
|
+
#
|
2534
|
+
# == Fields
|
2535
|
+
#
|
2536
|
+
# A header field is a key/value pair.
|
2537
|
+
#
|
2538
|
+
# === Field Keys
|
2539
|
+
#
|
2540
|
+
# A field key may be:
|
2541
|
+
#
|
2542
|
+
# - A string: Key <tt>'Accept'</tt> is treated as if it were
|
2543
|
+
# <tt>'Accept'.downcase</tt>; i.e., <tt>'accept'</tt>.
|
2544
|
+
# - A symbol: Key <tt>:Accept</tt> is treated as if it were
|
2545
|
+
# <tt>:Accept.to_s.downcase</tt>; i.e., <tt>'accept'</tt>.
|
2546
|
+
#
|
2547
|
+
# Examples:
|
2548
|
+
#
|
2549
|
+
# req = Net::HTTP::Get.new(uri)
|
2550
|
+
# req[:accept] # => "*/*"
|
2551
|
+
# req['Accept'] # => "*/*"
|
2552
|
+
# req['ACCEPT'] # => "*/*"
|
2553
|
+
#
|
2554
|
+
# req['accept'] = 'text/html'
|
2555
|
+
# req[:accept] = 'text/html'
|
2556
|
+
# req['ACCEPT'] = 'text/html'
|
2557
|
+
#
|
2558
|
+
# === Field Values
|
2559
|
+
#
|
2560
|
+
# A field value may be returned as an array of strings or as a string:
|
2561
|
+
#
|
2562
|
+
# - These methods return field values as arrays:
|
2563
|
+
#
|
2564
|
+
# - #get_fields: Returns the array value for the given key,
|
2565
|
+
# or +nil+ if it does not exist.
|
2566
|
+
# - #to_hash: Returns a hash of all header fields:
|
2567
|
+
# each key is a field name; its value is the array value for the field.
|
2568
|
+
#
|
2569
|
+
# - These methods return field values as string;
|
2570
|
+
# the string value for a field is equivalent to
|
2571
|
+
# <tt>self[key.downcase.to_s].join(', '))</tt>:
|
2572
|
+
#
|
2573
|
+
# - #[]: Returns the string value for the given key,
|
2574
|
+
# or +nil+ if it does not exist.
|
2575
|
+
# - #fetch: Like #[], but accepts a default value
|
2576
|
+
# to be returned if the key does not exist.
|
2577
|
+
#
|
2578
|
+
# The field value may be set:
|
2579
|
+
#
|
2580
|
+
# - #[]=: Sets the value for the given key;
|
2581
|
+
# the given value may be a string, a symbol, an array, or a hash.
|
2582
|
+
# - #add_field: Adds a given value to a value for the given key
|
2583
|
+
# (not overwriting the existing value).
|
2584
|
+
# - #delete: Deletes the field for the given key.
|
2585
|
+
#
|
2586
|
+
# Example field values:
|
2587
|
+
#
|
2588
|
+
# - \String:
|
2589
|
+
#
|
2590
|
+
# req['Accept'] = 'text/html' # => "text/html"
|
2591
|
+
# req['Accept'] # => "text/html"
|
2592
|
+
# req.get_fields('Accept') # => ["text/html"]
|
2593
|
+
#
|
2594
|
+
# - \Symbol:
|
2595
|
+
#
|
2596
|
+
# req['Accept'] = :text # => :text
|
2597
|
+
# req['Accept'] # => "text"
|
2598
|
+
# req.get_fields('Accept') # => ["text"]
|
2599
|
+
#
|
2600
|
+
# - Simple array:
|
2601
|
+
#
|
2602
|
+
# req[:foo] = %w[bar baz bat]
|
2603
|
+
# req[:foo] # => "bar, baz, bat"
|
2604
|
+
# req.get_fields(:foo) # => ["bar", "baz", "bat"]
|
2605
|
+
#
|
2606
|
+
# - Simple hash:
|
2607
|
+
#
|
2608
|
+
# req[:foo] = {bar: 0, baz: 1, bat: 2}
|
2609
|
+
# req[:foo] # => "bar, 0, baz, 1, bat, 2"
|
2610
|
+
# req.get_fields(:foo) # => ["bar", "0", "baz", "1", "bat", "2"]
|
2611
|
+
#
|
2612
|
+
# - Nested:
|
2613
|
+
#
|
2614
|
+
# req[:foo] = [%w[bar baz], {bat: 0, bam: 1}]
|
2615
|
+
# req[:foo] # => "bar, baz, bat, 0, bam, 1"
|
2616
|
+
# req.get_fields(:foo) # => ["bar", "baz", "bat", "0", "bam", "1"]
|
2617
|
+
#
|
2618
|
+
# req[:foo] = {bar: %w[baz bat], bam: {bah: 0, bad: 1}}
|
2619
|
+
# req[:foo] # => "bar, baz, bat, bam, bah, 0, bad, 1"
|
2620
|
+
# req.get_fields(:foo) # => ["bar", "baz", "bat", "bam", "bah", "0", "bad", "1"]
|
2621
|
+
#
|
2622
|
+
# == Convenience Methods
|
2623
|
+
#
|
2624
|
+
# Various convenience methods retrieve values, set values, query values,
|
2625
|
+
# set form values, or iterate over fields.
|
2626
|
+
#
|
2627
|
+
# === Setters
|
2628
|
+
#
|
2629
|
+
# \Method #[]= can set any field, but does little to validate the new value;
|
2630
|
+
# some of the other setter methods provide some validation:
|
2631
|
+
#
|
2632
|
+
# - #[]=: Sets the string or array value for the given key.
|
2633
|
+
# - #add_field: Creates or adds to the array value for the given key.
|
2634
|
+
# - #basic_auth: Sets the string authorization header for <tt>'Authorization'</tt>.
|
2635
|
+
# - #content_length=: Sets the integer length for field <tt>'Content-Length</tt>.
|
2636
|
+
# - #content_type=: Sets the string value for field <tt>'Content-Type'</tt>.
|
2637
|
+
# - #proxy_basic_auth: Sets the string authorization header for <tt>'Proxy-Authorization'</tt>.
|
2638
|
+
# - #set_range: Sets the value for field <tt>'Range'</tt>.
|
2639
|
+
#
|
2640
|
+
# === Form Setters
|
2641
|
+
#
|
2642
|
+
# - #set_form: Sets an HTML form data set.
|
2643
|
+
# - #set_form_data: Sets header fields and a body from HTML form data.
|
2644
|
+
#
|
2645
|
+
# === Getters
|
2646
|
+
#
|
2647
|
+
# \Method #[] can retrieve the value of any field that exists,
|
2648
|
+
# but always as a string;
|
2649
|
+
# some of the other getter methods return something different
|
2650
|
+
# from the simple string value:
|
2651
|
+
#
|
2652
|
+
# - #[]: Returns the string field value for the given key.
|
2653
|
+
# - #content_length: Returns the integer value of field <tt>'Content-Length'</tt>.
|
2654
|
+
# - #content_range: Returns the Range value of field <tt>'Content-Range'</tt>.
|
2655
|
+
# - #content_type: Returns the string value of field <tt>'Content-Type'</tt>.
|
2656
|
+
# - #fetch: Returns the string field value for the given key.
|
2657
|
+
# - #get_fields: Returns the array field value for the given +key+.
|
2658
|
+
# - #main_type: Returns first part of the string value of field <tt>'Content-Type'</tt>.
|
2659
|
+
# - #sub_type: Returns second part of the string value of field <tt>'Content-Type'</tt>.
|
2660
|
+
# - #range: Returns an array of Range objects of field <tt>'Range'</tt>, or +nil+.
|
2661
|
+
# - #range_length: Returns the integer length of the range given in field <tt>'Content-Range'</tt>.
|
2662
|
+
# - #type_params: Returns the string parameters for <tt>'Content-Type'</tt>.
|
2663
|
+
#
|
2664
|
+
# === Queries
|
2665
|
+
#
|
2666
|
+
# - #chunked?: Returns whether field <tt>'Transfer-Encoding'</tt> is set to <tt>'chunked'</tt>.
|
2667
|
+
# - #connection_close?: Returns whether field <tt>'Connection'</tt> is set to <tt>'close'</tt>.
|
2668
|
+
# - #connection_keep_alive?: Returns whether field <tt>'Connection'</tt> is set to <tt>'keep-alive'</tt>.
|
2669
|
+
# - #key?: Returns whether a given key exists.
|
2670
|
+
#
|
2671
|
+
# === Iterators
|
2672
|
+
#
|
2673
|
+
# - #each_capitalized: Passes each field capitalized-name/value pair to the block.
|
2674
|
+
# - #each_capitalized_name: Passes each capitalized field name to the block.
|
2675
|
+
# - #each_header: Passes each field name/value pair to the block.
|
2676
|
+
# - #each_name: Passes each field name to the block.
|
2677
|
+
# - #each_value: Passes each string field value to the block.
|
2678
|
+
#
|
2679
|
+
# source://net-http//lib/net/http/header.rb#181
|
2680
|
+
module Net::HTTPHeader
|
2681
|
+
# Returns the string field value for the case-insensitive field +key+,
|
2682
|
+
# or +nil+ if there is no such key;
|
2683
|
+
# see {Fields}[rdoc-ref:Net::HTTPHeader@Fields]:
|
2684
|
+
#
|
2685
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
2686
|
+
# res['Connection'] # => "keep-alive"
|
2687
|
+
# res['Nosuch'] # => nil
|
2688
|
+
#
|
2689
|
+
# Note that some field values may be retrieved via convenience methods;
|
2690
|
+
# see {Getters}[rdoc-ref:Net::HTTPHeader@Getters].
|
2691
|
+
#
|
2692
|
+
# source://net-http//lib/net/http/header.rb#224
|
2693
|
+
def [](key); end
|
2694
|
+
|
2695
|
+
# Sets the value for the case-insensitive +key+ to +val+,
|
2696
|
+
# overwriting the previous value if the field exists;
|
2697
|
+
# see {Fields}[rdoc-ref:Net::HTTPHeader@Fields]:
|
2698
|
+
#
|
2699
|
+
# req = Net::HTTP::Get.new(uri)
|
2700
|
+
# req['Accept'] # => "*/*"
|
2701
|
+
# req['Accept'] = 'text/html'
|
2702
|
+
# req['Accept'] # => "text/html"
|
2703
|
+
#
|
2704
|
+
# Note that some field values may be set via convenience methods;
|
2705
|
+
# see {Setters}[rdoc-ref:Net::HTTPHeader@Setters].
|
2706
|
+
#
|
2707
|
+
# source://net-http//lib/net/http/header.rb#240
|
2708
|
+
def []=(key, val); end
|
2709
|
+
|
2710
|
+
# Adds value +val+ to the value array for field +key+ if the field exists;
|
2711
|
+
# creates the field with the given +key+ and +val+ if it does not exist.
|
2712
|
+
# see {Fields}[rdoc-ref:Net::HTTPHeader@Fields]:
|
2713
|
+
#
|
2714
|
+
# req = Net::HTTP::Get.new(uri)
|
2715
|
+
# req.add_field('Foo', 'bar')
|
2716
|
+
# req['Foo'] # => "bar"
|
2717
|
+
# req.add_field('Foo', 'baz')
|
2718
|
+
# req['Foo'] # => "bar, baz"
|
2719
|
+
# req.add_field('Foo', %w[baz bam])
|
2720
|
+
# req['Foo'] # => "bar, baz, baz, bam"
|
2721
|
+
# req.get_fields('Foo') # => ["bar", "baz", "baz", "bam"]
|
2722
|
+
#
|
2723
|
+
# source://net-http//lib/net/http/header.rb#261
|
2724
|
+
def add_field(key, val); end
|
2725
|
+
|
2726
|
+
# Sets header <tt>'Authorization'</tt> using the given
|
2727
|
+
# +account+ and +password+ strings:
|
2728
|
+
#
|
2729
|
+
# req.basic_auth('my_account', 'my_password')
|
2730
|
+
# req['Authorization']
|
2731
|
+
# # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="
|
2732
|
+
#
|
2733
|
+
# source://net-http//lib/net/http/header.rb#945
|
2734
|
+
def basic_auth(account, password); end
|
2735
|
+
|
2736
|
+
# Like #each_header, but the keys are returned in capitalized form.
|
2737
|
+
#
|
2738
|
+
# Net::HTTPHeader#canonical_each is an alias for Net::HTTPHeader#each_capitalized.
|
2739
|
+
#
|
2740
|
+
# source://net-http//lib/net/http/header.rb#484
|
2741
|
+
def canonical_each; end
|
2742
|
+
|
2743
|
+
# Returns +true+ if field <tt>'Transfer-Encoding'</tt>
|
2744
|
+
# exists and has value <tt>'chunked'</tt>,
|
2745
|
+
# +false+ otherwise;
|
2746
|
+
# see {Transfer-Encoding response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#transfer-encoding-response-header]:
|
2747
|
+
#
|
2748
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
2749
|
+
# res['Transfer-Encoding'] # => "chunked"
|
2750
|
+
# res.chunked? # => true
|
2751
|
+
#
|
2752
|
+
# @return [Boolean]
|
2753
|
+
#
|
2754
|
+
# source://net-http//lib/net/http/header.rb#654
|
2755
|
+
def chunked?; end
|
2756
|
+
|
2757
|
+
# Returns whether the HTTP session is to be closed.
|
2758
|
+
#
|
2759
|
+
# @return [Boolean]
|
2760
|
+
#
|
2761
|
+
# source://net-http//lib/net/http/header.rb#966
|
2762
|
+
def connection_close?; end
|
2763
|
+
|
2764
|
+
# Returns whether the HTTP session is to be kept alive.
|
2765
|
+
#
|
2766
|
+
# @return [Boolean]
|
2767
|
+
#
|
2768
|
+
# source://net-http//lib/net/http/header.rb#974
|
2769
|
+
def connection_keep_alive?; end
|
2770
|
+
|
2771
|
+
# Returns the value of field <tt>'Content-Length'</tt> as an integer,
|
2772
|
+
# or +nil+ if there is no such field;
|
2773
|
+
# see {Content-Length request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-length-request-header]:
|
2774
|
+
#
|
2775
|
+
# res = Net::HTTP.get_response(hostname, '/nosuch/1')
|
2776
|
+
# res.content_length # => 2
|
2777
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
2778
|
+
# res.content_length # => nil
|
2779
|
+
#
|
2780
|
+
# source://net-http//lib/net/http/header.rb#616
|
2781
|
+
def content_length; end
|
2782
|
+
|
2783
|
+
# Sets the value of field <tt>'Content-Length'</tt> to the given numeric;
|
2784
|
+
# see {Content-Length response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-length-response-header]:
|
2785
|
+
#
|
2786
|
+
# _uri = uri.dup
|
2787
|
+
# hostname = _uri.hostname # => "jsonplaceholder.typicode.com"
|
2788
|
+
# _uri.path = '/posts' # => "/posts"
|
2789
|
+
# req = Net::HTTP::Post.new(_uri) # => #<Net::HTTP::Post POST>
|
2790
|
+
# req.body = '{"title": "foo","body": "bar","userId": 1}'
|
2791
|
+
# req.content_length = req.body.size # => 42
|
2792
|
+
# req.content_type = 'application/json'
|
2793
|
+
# res = Net::HTTP.start(hostname) do |http|
|
2794
|
+
# http.request(req)
|
2795
|
+
# end # => #<Net::HTTPCreated 201 Created readbody=true>
|
2796
|
+
#
|
2797
|
+
# source://net-http//lib/net/http/header.rb#637
|
2798
|
+
def content_length=(len); end
|
2799
|
+
|
2800
|
+
# Returns a Range object representing the value of field
|
2801
|
+
# <tt>'Content-Range'</tt>, or +nil+ if no such field exists;
|
2802
|
+
# see {Content-Range response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range-response-header]:
|
2803
|
+
#
|
2804
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
2805
|
+
# res['Content-Range'] # => nil
|
2806
|
+
# res['Content-Range'] = 'bytes 0-499/1000'
|
2807
|
+
# res['Content-Range'] # => "bytes 0-499/1000"
|
2808
|
+
# res.content_range # => 0..499
|
2809
|
+
#
|
2810
|
+
# source://net-http//lib/net/http/header.rb#670
|
2811
|
+
def content_range; end
|
2812
|
+
|
2813
|
+
# Returns the {media type}[https://en.wikipedia.org/wiki/Media_type]
|
2814
|
+
# from the value of field <tt>'Content-Type'</tt>,
|
2815
|
+
# or +nil+ if no such field exists;
|
2816
|
+
# see {Content-Type response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-response-header]:
|
2817
|
+
#
|
2818
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
2819
|
+
# res['content-type'] # => "application/json; charset=utf-8"
|
2820
|
+
# res.content_type # => "application/json"
|
2821
|
+
#
|
2822
|
+
# source://net-http//lib/net/http/header.rb#701
|
2823
|
+
def content_type; end
|
2824
|
+
|
2825
|
+
# Sets the value of field <tt>'Content-Type'</tt>;
|
2826
|
+
# returns the new value;
|
2827
|
+
# see {Content-Type request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-request-header]:
|
2828
|
+
#
|
2829
|
+
# req = Net::HTTP::Get.new(uri)
|
2830
|
+
# req.set_content_type('application/json') # => ["application/json"]
|
2831
|
+
#
|
2832
|
+
# Net::HTTPHeader#content_type= is an alias for Net::HTTPHeader#set_content_type.
|
2833
|
+
#
|
2834
|
+
# source://net-http//lib/net/http/header.rb#772
|
2835
|
+
def content_type=(type, params = T.unsafe(nil)); end
|
2836
|
+
|
2837
|
+
# Removes the header for the given case-insensitive +key+
|
2838
|
+
# (see {Fields}[rdoc-ref:Net::HTTPHeader@Fields]);
|
2839
|
+
# returns the deleted value, or +nil+ if no such field exists:
|
2840
|
+
#
|
2841
|
+
# req = Net::HTTP::Get.new(uri)
|
2842
|
+
# req.delete('Accept') # => ["*/*"]
|
2843
|
+
# req.delete('Nosuch') # => nil
|
2844
|
+
#
|
2845
|
+
# source://net-http//lib/net/http/header.rb#453
|
2846
|
+
def delete(key); end
|
2847
|
+
|
2848
|
+
# Calls the block with each key/value pair:
|
2849
|
+
#
|
2850
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
2851
|
+
# res.each_header do |key, value|
|
2852
|
+
# p [key, value] if key.start_with?('c')
|
2853
|
+
# end
|
2854
|
+
#
|
2855
|
+
# Output:
|
2856
|
+
#
|
2857
|
+
# ["content-type", "application/json; charset=utf-8"]
|
2858
|
+
# ["connection", "keep-alive"]
|
2859
|
+
# ["cache-control", "max-age=43200"]
|
2860
|
+
# ["cf-cache-status", "HIT"]
|
2861
|
+
# ["cf-ray", "771d17e9bc542cf5-ORD"]
|
2862
|
+
#
|
2863
|
+
# Returns an enumerator if no block is given.
|
2864
|
+
#
|
2865
|
+
# Net::HTTPHeader#each is an alias for Net::HTTPHeader#each_header.
|
2866
|
+
#
|
2867
|
+
# source://net-http//lib/net/http/header.rb#364
|
2868
|
+
def each; end
|
2869
|
+
|
2870
|
+
# Like #each_header, but the keys are returned in capitalized form.
|
2871
|
+
#
|
2872
|
+
# Net::HTTPHeader#canonical_each is an alias for Net::HTTPHeader#each_capitalized.
|
2873
|
+
#
|
2874
|
+
# source://net-http//lib/net/http/header.rb#484
|
2875
|
+
def each_capitalized; end
|
2876
|
+
|
2877
|
+
# Calls the block with each capitalized field name:
|
2878
|
+
#
|
2879
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
2880
|
+
# res.each_capitalized_name do |key|
|
2881
|
+
# p key if key.start_with?('C')
|
2882
|
+
# end
|
2883
|
+
#
|
2884
|
+
# Output:
|
2885
|
+
#
|
2886
|
+
# "Content-Type"
|
2887
|
+
# "Connection"
|
2888
|
+
# "Cache-Control"
|
2889
|
+
# "Cf-Cache-Status"
|
2890
|
+
# "Cf-Ray"
|
2891
|
+
#
|
2892
|
+
# The capitalization is system-dependent;
|
2893
|
+
# see {Case Mapping}[https://docs.ruby-lang.org/en/master/case_mapping_rdoc.html].
|
2894
|
+
#
|
2895
|
+
# Returns an enumerator if no block is given.
|
2896
|
+
#
|
2897
|
+
# source://net-http//lib/net/http/header.rb#417
|
2898
|
+
def each_capitalized_name; end
|
2899
|
+
|
2900
|
+
# Calls the block with each key/value pair:
|
2901
|
+
#
|
2902
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
2903
|
+
# res.each_header do |key, value|
|
2904
|
+
# p [key, value] if key.start_with?('c')
|
2905
|
+
# end
|
2906
|
+
#
|
2907
|
+
# Output:
|
2908
|
+
#
|
2909
|
+
# ["content-type", "application/json; charset=utf-8"]
|
2910
|
+
# ["connection", "keep-alive"]
|
2911
|
+
# ["cache-control", "max-age=43200"]
|
2912
|
+
# ["cf-cache-status", "HIT"]
|
2913
|
+
# ["cf-ray", "771d17e9bc542cf5-ORD"]
|
2914
|
+
#
|
2915
|
+
# Returns an enumerator if no block is given.
|
2916
|
+
#
|
2917
|
+
# Net::HTTPHeader#each is an alias for Net::HTTPHeader#each_header.
|
2918
|
+
#
|
2919
|
+
# source://net-http//lib/net/http/header.rb#364
|
2920
|
+
def each_header; end
|
2921
|
+
|
2922
|
+
# Calls the block with each field key:
|
2923
|
+
#
|
2924
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
2925
|
+
# res.each_key do |key|
|
2926
|
+
# p key if key.start_with?('c')
|
2927
|
+
# end
|
2928
|
+
#
|
2929
|
+
# Output:
|
2930
|
+
#
|
2931
|
+
# "content-type"
|
2932
|
+
# "connection"
|
2933
|
+
# "cache-control"
|
2934
|
+
# "cf-cache-status"
|
2935
|
+
# "cf-ray"
|
2936
|
+
#
|
2937
|
+
# Returns an enumerator if no block is given.
|
2938
|
+
#
|
2939
|
+
# Net::HTTPHeader#each_name is an alias for Net::HTTPHeader#each_key.
|
2940
|
+
#
|
2941
|
+
# source://net-http//lib/net/http/header.rb#391
|
2942
|
+
def each_key(&block); end
|
2943
|
+
|
2944
|
+
# Calls the block with each field key:
|
2945
|
+
#
|
2946
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
2947
|
+
# res.each_key do |key|
|
2948
|
+
# p key if key.start_with?('c')
|
2949
|
+
# end
|
2950
|
+
#
|
2951
|
+
# Output:
|
2952
|
+
#
|
2953
|
+
# "content-type"
|
2954
|
+
# "connection"
|
2955
|
+
# "cache-control"
|
2956
|
+
# "cf-cache-status"
|
2957
|
+
# "cf-ray"
|
2958
|
+
#
|
2959
|
+
# Returns an enumerator if no block is given.
|
2960
|
+
#
|
2961
|
+
# Net::HTTPHeader#each_name is an alias for Net::HTTPHeader#each_key.
|
2962
|
+
#
|
2963
|
+
# source://net-http//lib/net/http/header.rb#391
|
2964
|
+
def each_name(&block); end
|
2965
|
+
|
2966
|
+
# Calls the block with each string field value:
|
2967
|
+
#
|
2968
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
2969
|
+
# res.each_value do |value|
|
2970
|
+
# p value if value.start_with?('c')
|
2971
|
+
# end
|
2972
|
+
#
|
2973
|
+
# Output:
|
2974
|
+
#
|
2975
|
+
# "chunked"
|
2976
|
+
# "cf-q-config;dur=6.0000002122251e-06"
|
2977
|
+
# "cloudflare"
|
2978
|
+
#
|
2979
|
+
# Returns an enumerator if no block is given.
|
2980
|
+
#
|
2981
|
+
# source://net-http//lib/net/http/header.rb#438
|
2982
|
+
def each_value; end
|
2983
|
+
|
2984
|
+
# call-seq:
|
2985
|
+
# fetch(key, default_val = nil) {|key| ... } -> object
|
2986
|
+
# fetch(key, default_val = nil) -> value or default_val
|
2987
|
+
#
|
2988
|
+
# With a block, returns the string value for +key+ if it exists;
|
2989
|
+
# otherwise returns the value of the block;
|
2990
|
+
# ignores the +default_val+;
|
2991
|
+
# see {Fields}[rdoc-ref:Net::HTTPHeader@Fields]:
|
2992
|
+
#
|
2993
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
2994
|
+
#
|
2995
|
+
# # Field exists; block not called.
|
2996
|
+
# res.fetch('Connection') do |value|
|
2997
|
+
# fail 'Cannot happen'
|
2998
|
+
# end # => "keep-alive"
|
2999
|
+
#
|
3000
|
+
# # Field does not exist; block called.
|
3001
|
+
# res.fetch('Nosuch') do |value|
|
3002
|
+
# value.downcase
|
3003
|
+
# end # => "nosuch"
|
3004
|
+
#
|
3005
|
+
# With no block, returns the string value for +key+ if it exists;
|
3006
|
+
# otherwise, returns +default_val+ if it was given;
|
3007
|
+
# otherwise raises an exception:
|
3008
|
+
#
|
3009
|
+
# res.fetch('Connection', 'Foo') # => "keep-alive"
|
3010
|
+
# res.fetch('Nosuch', 'Foo') # => "Foo"
|
3011
|
+
# res.fetch('Nosuch') # Raises KeyError.
|
3012
|
+
#
|
3013
|
+
# source://net-http//lib/net/http/header.rb#341
|
3014
|
+
def fetch(key, *args, &block); end
|
3015
|
+
|
3016
|
+
# Sets the request body to a URL-encoded string derived from argument +params+,
|
3017
|
+
# and sets request header field <tt>'Content-Type'</tt>
|
3018
|
+
# to <tt>'application/x-www-form-urlencoded'</tt>.
|
3019
|
+
#
|
3020
|
+
# The resulting request is suitable for HTTP request +POST+ or +PUT+.
|
3021
|
+
#
|
3022
|
+
# Argument +params+ must be suitable for use as argument +enum+ to
|
3023
|
+
# {URI.encode_www_form}[https://docs.ruby-lang.org/en/master/URI.html#method-c-encode_www_form].
|
3024
|
+
#
|
3025
|
+
# With only argument +params+ given,
|
3026
|
+
# sets the body to a URL-encoded string with the default separator <tt>'&'</tt>:
|
3027
|
+
#
|
3028
|
+
# req = Net::HTTP::Post.new('example.com')
|
3029
|
+
#
|
3030
|
+
# req.set_form_data(q: 'ruby', lang: 'en')
|
3031
|
+
# req.body # => "q=ruby&lang=en"
|
3032
|
+
# req['Content-Type'] # => "application/x-www-form-urlencoded"
|
3033
|
+
#
|
3034
|
+
# req.set_form_data([['q', 'ruby'], ['lang', 'en']])
|
3035
|
+
# req.body # => "q=ruby&lang=en"
|
3036
|
+
#
|
3037
|
+
# req.set_form_data(q: ['ruby', 'perl'], lang: 'en')
|
3038
|
+
# req.body # => "q=ruby&q=perl&lang=en"
|
3039
|
+
#
|
3040
|
+
# req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']])
|
3041
|
+
# req.body # => "q=ruby&q=perl&lang=en"
|
3042
|
+
#
|
3043
|
+
# With string argument +sep+ also given,
|
3044
|
+
# uses that string as the separator:
|
3045
|
+
#
|
3046
|
+
# req.set_form_data({q: 'ruby', lang: 'en'}, '|')
|
3047
|
+
# req.body # => "q=ruby|lang=en"
|
3048
|
+
#
|
3049
|
+
# Net::HTTPHeader#form_data= is an alias for Net::HTTPHeader#set_form_data.
|
3050
|
+
#
|
3051
|
+
# source://net-http//lib/net/http/header.rb#812
|
3052
|
+
def form_data=(params, sep = T.unsafe(nil)); end
|
3053
|
+
|
3054
|
+
# Returns the array field value for the given +key+,
|
3055
|
+
# or +nil+ if there is no such field;
|
3056
|
+
# see {Fields}[rdoc-ref:Net::HTTPHeader@Fields]:
|
3057
|
+
#
|
3058
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
3059
|
+
# res.get_fields('Connection') # => ["keep-alive"]
|
3060
|
+
# res.get_fields('Nosuch') # => nil
|
3061
|
+
#
|
3062
|
+
# source://net-http//lib/net/http/header.rb#306
|
3063
|
+
def get_fields(key); end
|
3064
|
+
|
3065
|
+
# source://net-http//lib/net/http/header.rb#185
|
3066
|
+
def initialize_http_header(initheader); end
|
3067
|
+
|
3068
|
+
# Returns +true+ if the field for the case-insensitive +key+ exists, +false+ otherwise:
|
3069
|
+
#
|
3070
|
+
# req = Net::HTTP::Get.new(uri)
|
3071
|
+
# req.key?('Accept') # => true
|
3072
|
+
# req.key?('Nosuch') # => false
|
3073
|
+
#
|
3074
|
+
# @return [Boolean]
|
3075
|
+
#
|
3076
|
+
# source://net-http//lib/net/http/header.rb#463
|
3077
|
+
def key?(key); end
|
3078
|
+
|
3079
|
+
# source://net-http//lib/net/http/header.rb#208
|
3080
|
+
def length; end
|
3081
|
+
|
3082
|
+
# Returns the leading ('type') part of the
|
3083
|
+
# {media type}[https://en.wikipedia.org/wiki/Media_type]
|
3084
|
+
# from the value of field <tt>'Content-Type'</tt>,
|
3085
|
+
# or +nil+ if no such field exists;
|
3086
|
+
# see {Content-Type response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-response-header]:
|
3087
|
+
#
|
3088
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
3089
|
+
# res['content-type'] # => "application/json; charset=utf-8"
|
3090
|
+
# res.main_type # => "application"
|
3091
|
+
#
|
3092
|
+
# source://net-http//lib/net/http/header.rb#723
|
3093
|
+
def main_type; end
|
3094
|
+
|
3095
|
+
# Sets header <tt>'Proxy-Authorization'</tt> using the given
|
3096
|
+
# +account+ and +password+ strings:
|
3097
|
+
#
|
3098
|
+
# req.proxy_basic_auth('my_account', 'my_password')
|
3099
|
+
# req['Proxy-Authorization']
|
3100
|
+
# # => "Basic bXlfYWNjb3VudDpteV9wYXNzd29yZA=="
|
3101
|
+
#
|
3102
|
+
# source://net-http//lib/net/http/header.rb#956
|
3103
|
+
def proxy_basic_auth(account, password); end
|
3104
|
+
|
3105
|
+
# Returns an array of Range objects that represent
|
3106
|
+
# the value of field <tt>'Range'</tt>,
|
3107
|
+
# or +nil+ if there is no such field;
|
3108
|
+
# see {Range request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request-header]:
|
3109
|
+
#
|
3110
|
+
# req = Net::HTTP::Get.new(uri)
|
3111
|
+
# req['Range'] = 'bytes=0-99,200-299,400-499'
|
3112
|
+
# req.range # => [0..99, 200..299, 400..499]
|
3113
|
+
# req.delete('Range')
|
3114
|
+
# req.range # # => nil
|
3115
|
+
#
|
3116
|
+
# source://net-http//lib/net/http/header.rb#509
|
3117
|
+
def range; end
|
3118
|
+
|
3119
|
+
# call-seq:
|
3120
|
+
# set_range(length) -> length
|
3121
|
+
# set_range(offset, length) -> range
|
3122
|
+
# set_range(begin..length) -> range
|
3123
|
+
#
|
3124
|
+
# Sets the value for field <tt>'Range'</tt>;
|
3125
|
+
# see {Range request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request-header]:
|
3126
|
+
#
|
3127
|
+
# With argument +length+:
|
3128
|
+
#
|
3129
|
+
# req = Net::HTTP::Get.new(uri)
|
3130
|
+
# req.set_range(100) # => 100
|
3131
|
+
# req['Range'] # => "bytes=0-99"
|
3132
|
+
#
|
3133
|
+
# With arguments +offset+ and +length+:
|
3134
|
+
#
|
3135
|
+
# req.set_range(100, 100) # => 100...200
|
3136
|
+
# req['Range'] # => "bytes=100-199"
|
3137
|
+
#
|
3138
|
+
# With argument +range+:
|
3139
|
+
#
|
3140
|
+
# req.set_range(100..199) # => 100..199
|
3141
|
+
# req['Range'] # => "bytes=100-199"
|
3142
|
+
#
|
3143
|
+
# Net::HTTPHeader#range= is an alias for Net::HTTPHeader#set_range.
|
3144
|
+
#
|
3145
|
+
# source://net-http//lib/net/http/header.rb#576
|
3146
|
+
def range=(r, e = T.unsafe(nil)); end
|
3147
|
+
|
3148
|
+
# Returns the integer representing length of the value of field
|
3149
|
+
# <tt>'Content-Range'</tt>, or +nil+ if no such field exists;
|
3150
|
+
# see {Content-Range response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-range-response-header]:
|
3151
|
+
#
|
3152
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
3153
|
+
# res['Content-Range'] # => nil
|
3154
|
+
# res['Content-Range'] = 'bytes 0-499/1000'
|
3155
|
+
# res.range_length # => 500
|
3156
|
+
#
|
3157
|
+
# source://net-http//lib/net/http/header.rb#687
|
3158
|
+
def range_length; end
|
3159
|
+
|
3160
|
+
# Sets the value of field <tt>'Content-Type'</tt>;
|
3161
|
+
# returns the new value;
|
3162
|
+
# see {Content-Type request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-request-header]:
|
3163
|
+
#
|
3164
|
+
# req = Net::HTTP::Get.new(uri)
|
3165
|
+
# req.set_content_type('application/json') # => ["application/json"]
|
3166
|
+
#
|
3167
|
+
# Net::HTTPHeader#content_type= is an alias for Net::HTTPHeader#set_content_type.
|
3168
|
+
#
|
3169
|
+
# source://net-http//lib/net/http/header.rb#772
|
3170
|
+
def set_content_type(type, params = T.unsafe(nil)); end
|
3171
|
+
|
3172
|
+
# Stores form data to be used in a +POST+ or +PUT+ request.
|
3173
|
+
#
|
3174
|
+
# The form data given in +params+ consists of zero or more fields;
|
3175
|
+
# each field is:
|
3176
|
+
#
|
3177
|
+
# - A scalar value.
|
3178
|
+
# - A name/value pair.
|
3179
|
+
# - An IO stream opened for reading.
|
3180
|
+
#
|
3181
|
+
# Argument +params+ should be an
|
3182
|
+
# {Enumerable}[https://docs.ruby-lang.org/en/master/Enumerable.html#module-Enumerable-label-Enumerable+in+Ruby+Classes]
|
3183
|
+
# (method <tt>params.map</tt> will be called),
|
3184
|
+
# and is often an array or hash.
|
3185
|
+
#
|
3186
|
+
# First, we set up a request:
|
3187
|
+
#
|
3188
|
+
# _uri = uri.dup
|
3189
|
+
# _uri.path ='/posts'
|
3190
|
+
# req = Net::HTTP::Post.new(_uri)
|
3191
|
+
#
|
3192
|
+
# <b>Argument +params+ As an Array</b>
|
3193
|
+
#
|
3194
|
+
# When +params+ is an array,
|
3195
|
+
# each of its elements is a subarray that defines a field;
|
3196
|
+
# the subarray may contain:
|
3197
|
+
#
|
3198
|
+
# - One string:
|
3199
|
+
#
|
3200
|
+
# req.set_form([['foo'], ['bar'], ['baz']])
|
3201
|
+
#
|
3202
|
+
# - Two strings:
|
3203
|
+
#
|
3204
|
+
# req.set_form([%w[foo 0], %w[bar 1], %w[baz 2]])
|
3205
|
+
#
|
3206
|
+
# - When argument +enctype+ (see below) is given as
|
3207
|
+
# <tt>'multipart/form-data'</tt>:
|
3208
|
+
#
|
3209
|
+
# - A string name and an IO stream opened for reading:
|
3210
|
+
#
|
3211
|
+
# require 'stringio'
|
3212
|
+
# req.set_form([['file', StringIO.new('Ruby is cool.')]])
|
3213
|
+
#
|
3214
|
+
# - A string name, an IO stream opened for reading,
|
3215
|
+
# and an options hash, which may contain these entries:
|
3216
|
+
#
|
3217
|
+
# - +:filename+: The name of the file to use.
|
3218
|
+
# - +:content_type+: The content type of the uploaded file.
|
3219
|
+
#
|
3220
|
+
# Example:
|
3221
|
+
#
|
3222
|
+
# req.set_form([['file', file, {filename: "other-filename.foo"}]]
|
3223
|
+
#
|
3224
|
+
# The various forms may be mixed:
|
3225
|
+
#
|
3226
|
+
# req.set_form(['foo', %w[bar 1], ['file', file]])
|
3227
|
+
#
|
3228
|
+
# <b>Argument +params+ As a Hash</b>
|
3229
|
+
#
|
3230
|
+
# When +params+ is a hash,
|
3231
|
+
# each of its entries is a name/value pair that defines a field:
|
3232
|
+
#
|
3233
|
+
# - The name is a string.
|
3234
|
+
# - The value may be:
|
3235
|
+
#
|
3236
|
+
# - +nil+.
|
3237
|
+
# - Another string.
|
3238
|
+
# - An IO stream opened for reading
|
3239
|
+
# (only when argument +enctype+ -- see below -- is given as
|
3240
|
+
# <tt>'multipart/form-data'</tt>).
|
3241
|
+
#
|
3242
|
+
# Examples:
|
3243
|
+
#
|
3244
|
+
# # Nil-valued fields.
|
3245
|
+
# req.set_form({'foo' => nil, 'bar' => nil, 'baz' => nil})
|
3246
|
+
#
|
3247
|
+
# # String-valued fields.
|
3248
|
+
# req.set_form({'foo' => 0, 'bar' => 1, 'baz' => 2})
|
3249
|
+
#
|
3250
|
+
# # IO-valued field.
|
3251
|
+
# require 'stringio'
|
3252
|
+
# req.set_form({'file' => StringIO.new('Ruby is cool.')})
|
3253
|
+
#
|
3254
|
+
# # Mixture of fields.
|
3255
|
+
# req.set_form({'foo' => nil, 'bar' => 1, 'file' => file})
|
3256
|
+
#
|
3257
|
+
# Optional argument +enctype+ specifies the value to be given
|
3258
|
+
# to field <tt>'Content-Type'</tt>, and must be one of:
|
3259
|
+
#
|
3260
|
+
# - <tt>'application/x-www-form-urlencoded'</tt> (the default).
|
3261
|
+
# - <tt>'multipart/form-data'</tt>;
|
3262
|
+
# see {RFC 7578}[https://www.rfc-editor.org/rfc/rfc7578].
|
3263
|
+
#
|
3264
|
+
# Optional argument +formopt+ is a hash of options
|
3265
|
+
# (applicable only when argument +enctype+
|
3266
|
+
# is <tt>'multipart/form-data'</tt>)
|
3267
|
+
# that may include the following entries:
|
3268
|
+
#
|
3269
|
+
# - +:boundary+: The value is the boundary string for the multipart message.
|
3270
|
+
# If not given, the boundary is a random string.
|
3271
|
+
# See {Boundary}[https://www.rfc-editor.org/rfc/rfc7578#section-4.1].
|
3272
|
+
# - +:charset+: Value is the character set for the form submission.
|
3273
|
+
# Field names and values of non-file fields should be encoded with this charset.
|
3274
|
+
#
|
3275
|
+
# source://net-http//lib/net/http/header.rb#924
|
3276
|
+
def set_form(params, enctype = T.unsafe(nil), formopt = T.unsafe(nil)); end
|
3277
|
+
|
3278
|
+
# Sets the request body to a URL-encoded string derived from argument +params+,
|
3279
|
+
# and sets request header field <tt>'Content-Type'</tt>
|
3280
|
+
# to <tt>'application/x-www-form-urlencoded'</tt>.
|
3281
|
+
#
|
3282
|
+
# The resulting request is suitable for HTTP request +POST+ or +PUT+.
|
3283
|
+
#
|
3284
|
+
# Argument +params+ must be suitable for use as argument +enum+ to
|
3285
|
+
# {URI.encode_www_form}[https://docs.ruby-lang.org/en/master/URI.html#method-c-encode_www_form].
|
3286
|
+
#
|
3287
|
+
# With only argument +params+ given,
|
3288
|
+
# sets the body to a URL-encoded string with the default separator <tt>'&'</tt>:
|
3289
|
+
#
|
3290
|
+
# req = Net::HTTP::Post.new('example.com')
|
3291
|
+
#
|
3292
|
+
# req.set_form_data(q: 'ruby', lang: 'en')
|
3293
|
+
# req.body # => "q=ruby&lang=en"
|
3294
|
+
# req['Content-Type'] # => "application/x-www-form-urlencoded"
|
3295
|
+
#
|
3296
|
+
# req.set_form_data([['q', 'ruby'], ['lang', 'en']])
|
3297
|
+
# req.body # => "q=ruby&lang=en"
|
3298
|
+
#
|
3299
|
+
# req.set_form_data(q: ['ruby', 'perl'], lang: 'en')
|
3300
|
+
# req.body # => "q=ruby&q=perl&lang=en"
|
3301
|
+
#
|
3302
|
+
# req.set_form_data([['q', 'ruby'], ['q', 'perl'], ['lang', 'en']])
|
3303
|
+
# req.body # => "q=ruby&q=perl&lang=en"
|
3304
|
+
#
|
3305
|
+
# With string argument +sep+ also given,
|
3306
|
+
# uses that string as the separator:
|
3307
|
+
#
|
3308
|
+
# req.set_form_data({q: 'ruby', lang: 'en'}, '|')
|
3309
|
+
# req.body # => "q=ruby|lang=en"
|
3310
|
+
#
|
3311
|
+
# Net::HTTPHeader#form_data= is an alias for Net::HTTPHeader#set_form_data.
|
3312
|
+
#
|
3313
|
+
# source://net-http//lib/net/http/header.rb#812
|
3314
|
+
def set_form_data(params, sep = T.unsafe(nil)); end
|
3315
|
+
|
3316
|
+
# call-seq:
|
3317
|
+
# set_range(length) -> length
|
3318
|
+
# set_range(offset, length) -> range
|
3319
|
+
# set_range(begin..length) -> range
|
3320
|
+
#
|
3321
|
+
# Sets the value for field <tt>'Range'</tt>;
|
3322
|
+
# see {Range request header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#range-request-header]:
|
3323
|
+
#
|
3324
|
+
# With argument +length+:
|
3325
|
+
#
|
3326
|
+
# req = Net::HTTP::Get.new(uri)
|
3327
|
+
# req.set_range(100) # => 100
|
3328
|
+
# req['Range'] # => "bytes=0-99"
|
3329
|
+
#
|
3330
|
+
# With arguments +offset+ and +length+:
|
3331
|
+
#
|
3332
|
+
# req.set_range(100, 100) # => 100...200
|
3333
|
+
# req['Range'] # => "bytes=100-199"
|
3334
|
+
#
|
3335
|
+
# With argument +range+:
|
3336
|
+
#
|
3337
|
+
# req.set_range(100..199) # => 100..199
|
3338
|
+
# req['Range'] # => "bytes=100-199"
|
3339
|
+
#
|
3340
|
+
# Net::HTTPHeader#range= is an alias for Net::HTTPHeader#set_range.
|
3341
|
+
#
|
3342
|
+
# source://net-http//lib/net/http/header.rb#576
|
3343
|
+
def set_range(r, e = T.unsafe(nil)); end
|
3344
|
+
|
3345
|
+
# source://net-http//lib/net/http/header.rb#208
|
3346
|
+
def size; end
|
3347
|
+
|
3348
|
+
# Returns the trailing ('subtype') part of the
|
3349
|
+
# {media type}[https://en.wikipedia.org/wiki/Media_type]
|
3350
|
+
# from the value of field <tt>'Content-Type'</tt>,
|
3351
|
+
# or +nil+ if no such field exists;
|
3352
|
+
# see {Content-Type response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-response-header]:
|
3353
|
+
#
|
3354
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
3355
|
+
# res['content-type'] # => "application/json; charset=utf-8"
|
3356
|
+
# res.sub_type # => "json"
|
3357
|
+
#
|
3358
|
+
# source://net-http//lib/net/http/header.rb#738
|
3359
|
+
def sub_type; end
|
3360
|
+
|
3361
|
+
# Returns a hash of the key/value pairs:
|
3362
|
+
#
|
3363
|
+
# req = Net::HTTP::Get.new(uri)
|
3364
|
+
# req.to_hash
|
3365
|
+
# # =>
|
3366
|
+
# {"accept-encoding"=>["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"],
|
3367
|
+
# "accept"=>["*/*"],
|
3368
|
+
# "user-agent"=>["Ruby"],
|
3369
|
+
# "host"=>["jsonplaceholder.typicode.com"]}
|
3370
|
+
#
|
3371
|
+
# source://net-http//lib/net/http/header.rb#477
|
3372
|
+
def to_hash; end
|
3373
|
+
|
3374
|
+
# Returns the trailing ('parameters') part of the value of field <tt>'Content-Type'</tt>,
|
3375
|
+
# or +nil+ if no such field exists;
|
3376
|
+
# see {Content-Type response header}[https://en.wikipedia.org/wiki/List_of_HTTP_header_fields#content-type-response-header]:
|
3377
|
+
#
|
3378
|
+
# res = Net::HTTP.get_response(hostname, '/todos/1')
|
3379
|
+
# res['content-type'] # => "application/json; charset=utf-8"
|
3380
|
+
# res.type_params # => {"charset"=>"utf-8"}
|
3381
|
+
#
|
3382
|
+
# source://net-http//lib/net/http/header.rb#753
|
3383
|
+
def type_params; end
|
3384
|
+
|
3385
|
+
private
|
3386
|
+
|
3387
|
+
# source://net-http//lib/net/http/header.rb#285
|
3388
|
+
def append_field_value(ary, val); end
|
3389
|
+
|
3390
|
+
# source://net-http//lib/net/http/header.rb#960
|
3391
|
+
def basic_encode(account, password); end
|
3392
|
+
|
3393
|
+
# source://net-http//lib/net/http/header.rb#493
|
3394
|
+
def capitalize(name); end
|
3395
|
+
|
3396
|
+
# source://net-http//lib/net/http/header.rb#270
|
3397
|
+
def set_field(key, val); end
|
3398
|
+
end
|
3399
|
+
|
3400
|
+
# source://net-http//lib/net/http/header.rb#183
|
3401
|
+
Net::HTTPHeader::MAX_FIELD_LENGTH = T.let(T.unsafe(nil), Integer)
|
3402
|
+
|
3403
|
+
# source://net-http//lib/net/http/header.rb#182
|
3404
|
+
Net::HTTPHeader::MAX_KEY_LENGTH = T.let(T.unsafe(nil), Integer)
|
3405
|
+
|
3406
|
+
# source://net-http//lib/net/http/responses.rb#23
|
3407
|
+
Net::HTTPInformation::EXCEPTION_TYPE = Net::HTTPError
|
3408
|
+
|
3409
|
+
# source://net-http//lib/net/http/backward.rb#19
|
3410
|
+
Net::HTTPInformationCode = Net::HTTPInformation
|
3411
|
+
|
3412
|
+
# Response class for <tt>Loop Detected (WebDAV)</tt> responses (status code 508).
|
3413
|
+
#
|
3414
|
+
# The server detected an infinite loop while processing the request.
|
3415
|
+
#
|
3416
|
+
# :include: doc/net-http/included_getters.rdoc
|
3417
|
+
#
|
3418
|
+
# References:
|
3419
|
+
#
|
3420
|
+
# - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/508].
|
3421
|
+
# - {RFC 5942}[https://www.rfc-editor.org/rfc/rfc5842.html#section-7.2].
|
3422
|
+
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#508].
|
3423
|
+
#
|
3424
|
+
# source://net-http//lib/net/http/responses.rb#1061
|
3425
|
+
class Net::HTTPLoopDetected < ::Net::HTTPServerError; end
|
3426
|
+
|
3427
|
+
# source://net-http//lib/net/http/responses.rb#1062
|
3428
|
+
Net::HTTPLoopDetected::HAS_BODY = T.let(T.unsafe(nil), TrueClass)
|
3429
|
+
|
3430
|
+
# Response class for <tt>Misdirected Request</tt> responses (status code 421).
|
3431
|
+
#
|
3432
|
+
# The request was directed at a server that is not able to produce a response.
|
3433
|
+
#
|
3434
|
+
# :include: doc/net-http/included_getters.rdoc
|
3435
|
+
#
|
3436
|
+
# References:
|
3437
|
+
#
|
3438
|
+
# - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-421-misdirected-request].
|
3439
|
+
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#421].
|
3440
|
+
#
|
3441
|
+
# source://net-http//lib/net/http/responses.rb#776
|
3442
|
+
class Net::HTTPMisdirectedRequest < ::Net::HTTPClientError; end
|
3443
|
+
|
3444
|
+
# source://net-http//lib/net/http/responses.rb#777
|
3445
|
+
Net::HTTPMisdirectedRequest::HAS_BODY = T.let(T.unsafe(nil), TrueClass)
|
3446
|
+
|
3447
|
+
# source://net-http//lib/net/http/responses.rb#378
|
3448
|
+
Net::HTTPMovedTemporarily = Net::HTTPFound
|
3449
|
+
|
3450
|
+
# source://net-http//lib/net/http/responses.rb#343
|
3451
|
+
Net::HTTPMultipleChoice = Net::HTTPMultipleChoices
|
3452
|
+
|
3453
|
+
# Response class for <tt>Not Extended</tt> responses (status code 510).
|
3454
|
+
#
|
3455
|
+
# Further extensions to the request are required for the server to fulfill it.
|
3456
|
+
#
|
3457
|
+
# :include: doc/net-http/included_getters.rdoc
|
3458
|
+
#
|
3459
|
+
# References:
|
3460
|
+
#
|
3461
|
+
# - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/510].
|
3462
|
+
# - {RFC 2774}[https://www.rfc-editor.org/rfc/rfc2774.html#section-7].
|
3463
|
+
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#510].
|
3464
|
+
#
|
3465
|
+
# source://net-http//lib/net/http/responses.rb#1078
|
3466
|
+
class Net::HTTPNotExtended < ::Net::HTTPServerError; end
|
3467
|
+
|
3468
|
+
# source://net-http//lib/net/http/responses.rb#1079
|
3469
|
+
Net::HTTPNotExtended::HAS_BODY = T.let(T.unsafe(nil), TrueClass)
|
3470
|
+
|
3471
|
+
# Response class for <tt>Payload Too Large</tt> responses (status code 413).
|
3472
|
+
#
|
3473
|
+
# The request is larger than the server is willing or able to process.
|
3474
|
+
#
|
3475
|
+
# :include: doc/net-http/included_getters.rdoc
|
3476
|
+
#
|
3477
|
+
# References:
|
3478
|
+
#
|
3479
|
+
# - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/413].
|
3480
|
+
# - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-413-content-too-large].
|
3481
|
+
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#413].
|
3482
|
+
#
|
3483
|
+
# source://net-http//lib/net/http/responses.rb#688
|
3484
|
+
class Net::HTTPPayloadTooLarge < ::Net::HTTPClientError; end
|
3485
|
+
|
3486
|
+
# source://net-http//lib/net/http/responses.rb#689
|
3487
|
+
Net::HTTPPayloadTooLarge::HAS_BODY = T.let(T.unsafe(nil), TrueClass)
|
3488
|
+
|
3489
|
+
# Response class for +Processing+ responses (status code 102).
|
3490
|
+
#
|
3491
|
+
# The +Processing+ response indicates that the server has received
|
3492
|
+
# and is processing the request, but no response is available yet.
|
3493
|
+
#
|
3494
|
+
# :include: doc/net-http/included_getters.rdoc
|
3495
|
+
#
|
3496
|
+
# References:
|
3497
|
+
#
|
3498
|
+
# - {RFC 2518}[https://www.rfc-editor.org/rfc/rfc2518#section-10.1].
|
3499
|
+
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#102].
|
3500
|
+
#
|
3501
|
+
# source://net-http//lib/net/http/responses.rb#129
|
3502
|
+
class Net::HTTPProcessing < ::Net::HTTPInformation; end
|
3503
|
+
|
3504
|
+
# source://net-http//lib/net/http/responses.rb#130
|
3505
|
+
Net::HTTPProcessing::HAS_BODY = T.let(T.unsafe(nil), FalseClass)
|
3506
|
+
|
3507
|
+
# Response class for <tt>Range Not Satisfiable</tt> responses (status code 416).
|
3508
|
+
#
|
3509
|
+
# The request entity has a media type which the server or resource does not support.
|
3510
|
+
#
|
3511
|
+
# :include: doc/net-http/included_getters.rdoc
|
3512
|
+
#
|
3513
|
+
# References:
|
3514
|
+
#
|
3515
|
+
# - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/416].
|
3516
|
+
# - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-416-range-not-satisfiable].
|
3517
|
+
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#416].
|
3518
|
+
#
|
3519
|
+
# source://net-http//lib/net/http/responses.rb#739
|
3520
|
+
class Net::HTTPRangeNotSatisfiable < ::Net::HTTPClientError; end
|
3521
|
+
|
3522
|
+
# source://net-http//lib/net/http/responses.rb#740
|
3523
|
+
Net::HTTPRangeNotSatisfiable::HAS_BODY = T.let(T.unsafe(nil), TrueClass)
|
3524
|
+
|
3525
|
+
# source://net-http//lib/net/http/responses.rb#53
|
3526
|
+
Net::HTTPRedirection::EXCEPTION_TYPE = Net::HTTPRetriableError
|
3527
|
+
|
3528
|
+
# source://net-http//lib/net/http/backward.rb#21
|
3529
|
+
Net::HTTPRedirectionCode = Net::HTTPRedirection
|
3530
|
+
|
3531
|
+
# source://net-http//lib/net/http/responses.rb#709
|
3532
|
+
Net::HTTPRequestURITooLarge = Net::HTTPURITooLong
|
3533
|
+
|
3534
|
+
# Typo since 2001
|
3535
|
+
#
|
3536
|
+
# source://net-http//lib/net/http/backward.rb#28
|
3537
|
+
Net::HTTPResponceReceiver = Net::HTTPResponse
|
3538
|
+
|
3539
|
+
# This class is the base class for \Net::HTTP response classes.
|
3540
|
+
#
|
3541
|
+
# == About the Examples
|
3542
|
+
#
|
3543
|
+
# :include: doc/net-http/examples.rdoc
|
3544
|
+
#
|
3545
|
+
# == Returned Responses
|
3546
|
+
#
|
3547
|
+
# \Method Net::HTTP.get_response returns
|
3548
|
+
# an instance of one of the subclasses of \Net::HTTPResponse:
|
3549
|
+
#
|
3550
|
+
# Net::HTTP.get_response(uri)
|
3551
|
+
# # => #<Net::HTTPOK 200 OK readbody=true>
|
3552
|
+
# Net::HTTP.get_response(hostname, '/nosuch')
|
3553
|
+
# # => #<Net::HTTPNotFound 404 Not Found readbody=true>
|
3554
|
+
#
|
3555
|
+
# As does method Net::HTTP#request:
|
3556
|
+
#
|
3557
|
+
# req = Net::HTTP::Get.new(uri)
|
3558
|
+
# Net::HTTP.start(hostname) do |http|
|
3559
|
+
# http.request(req)
|
3560
|
+
# end # => #<Net::HTTPOK 200 OK readbody=true>
|
3561
|
+
#
|
3562
|
+
# \Class \Net::HTTPResponse includes module Net::HTTPHeader,
|
3563
|
+
# which provides access to response header values via (among others):
|
3564
|
+
#
|
3565
|
+
# - \Hash-like method <tt>[]</tt>.
|
3566
|
+
# - Specific reader methods, such as +content_type+.
|
3567
|
+
#
|
3568
|
+
# Examples:
|
3569
|
+
#
|
3570
|
+
# res = Net::HTTP.get_response(uri) # => #<Net::HTTPOK 200 OK readbody=true>
|
3571
|
+
# res['Content-Type'] # => "text/html; charset=UTF-8"
|
3572
|
+
# res.content_type # => "text/html"
|
3573
|
+
#
|
3574
|
+
# == Response Subclasses
|
3575
|
+
#
|
3576
|
+
# \Class \Net::HTTPResponse has a subclass for each
|
3577
|
+
# {HTTP status code}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes].
|
3578
|
+
# You can look up the response class for a given code:
|
3579
|
+
#
|
3580
|
+
# Net::HTTPResponse::CODE_TO_OBJ['200'] # => Net::HTTPOK
|
3581
|
+
# Net::HTTPResponse::CODE_TO_OBJ['400'] # => Net::HTTPBadRequest
|
3582
|
+
# Net::HTTPResponse::CODE_TO_OBJ['404'] # => Net::HTTPNotFound
|
3583
|
+
#
|
3584
|
+
# And you can retrieve the status code for a response object:
|
3585
|
+
#
|
3586
|
+
# Net::HTTP.get_response(uri).code # => "200"
|
3587
|
+
# Net::HTTP.get_response(hostname, '/nosuch').code # => "404"
|
3588
|
+
#
|
3589
|
+
# The response subclasses (indentation shows class hierarchy):
|
3590
|
+
#
|
3591
|
+
# - Net::HTTPUnknownResponse (for unhandled \HTTP extensions).
|
3592
|
+
#
|
3593
|
+
# - Net::HTTPInformation:
|
3594
|
+
#
|
3595
|
+
# - Net::HTTPContinue (100)
|
3596
|
+
# - Net::HTTPSwitchProtocol (101)
|
3597
|
+
# - Net::HTTPProcessing (102)
|
3598
|
+
# - Net::HTTPEarlyHints (103)
|
3599
|
+
#
|
3600
|
+
# - Net::HTTPSuccess:
|
3601
|
+
#
|
3602
|
+
# - Net::HTTPOK (200)
|
3603
|
+
# - Net::HTTPCreated (201)
|
3604
|
+
# - Net::HTTPAccepted (202)
|
3605
|
+
# - Net::HTTPNonAuthoritativeInformation (203)
|
3606
|
+
# - Net::HTTPNoContent (204)
|
3607
|
+
# - Net::HTTPResetContent (205)
|
3608
|
+
# - Net::HTTPPartialContent (206)
|
3609
|
+
# - Net::HTTPMultiStatus (207)
|
3610
|
+
# - Net::HTTPAlreadyReported (208)
|
3611
|
+
# - Net::HTTPIMUsed (226)
|
3612
|
+
#
|
3613
|
+
# - Net::HTTPRedirection:
|
3614
|
+
#
|
3615
|
+
# - Net::HTTPMultipleChoices (300)
|
3616
|
+
# - Net::HTTPMovedPermanently (301)
|
3617
|
+
# - Net::HTTPFound (302)
|
3618
|
+
# - Net::HTTPSeeOther (303)
|
3619
|
+
# - Net::HTTPNotModified (304)
|
3620
|
+
# - Net::HTTPUseProxy (305)
|
3621
|
+
# - Net::HTTPTemporaryRedirect (307)
|
3622
|
+
# - Net::HTTPPermanentRedirect (308)
|
3623
|
+
#
|
3624
|
+
# - Net::HTTPClientError:
|
3625
|
+
#
|
3626
|
+
# - Net::HTTPBadRequest (400)
|
3627
|
+
# - Net::HTTPUnauthorized (401)
|
3628
|
+
# - Net::HTTPPaymentRequired (402)
|
3629
|
+
# - Net::HTTPForbidden (403)
|
3630
|
+
# - Net::HTTPNotFound (404)
|
3631
|
+
# - Net::HTTPMethodNotAllowed (405)
|
3632
|
+
# - Net::HTTPNotAcceptable (406)
|
3633
|
+
# - Net::HTTPProxyAuthenticationRequired (407)
|
3634
|
+
# - Net::HTTPRequestTimeOut (408)
|
3635
|
+
# - Net::HTTPConflict (409)
|
3636
|
+
# - Net::HTTPGone (410)
|
3637
|
+
# - Net::HTTPLengthRequired (411)
|
3638
|
+
# - Net::HTTPPreconditionFailed (412)
|
3639
|
+
# - Net::HTTPRequestEntityTooLarge (413)
|
3640
|
+
# - Net::HTTPRequestURITooLong (414)
|
3641
|
+
# - Net::HTTPUnsupportedMediaType (415)
|
3642
|
+
# - Net::HTTPRequestedRangeNotSatisfiable (416)
|
3643
|
+
# - Net::HTTPExpectationFailed (417)
|
3644
|
+
# - Net::HTTPMisdirectedRequest (421)
|
3645
|
+
# - Net::HTTPUnprocessableEntity (422)
|
3646
|
+
# - Net::HTTPLocked (423)
|
3647
|
+
# - Net::HTTPFailedDependency (424)
|
3648
|
+
# - Net::HTTPUpgradeRequired (426)
|
3649
|
+
# - Net::HTTPPreconditionRequired (428)
|
3650
|
+
# - Net::HTTPTooManyRequests (429)
|
3651
|
+
# - Net::HTTPRequestHeaderFieldsTooLarge (431)
|
3652
|
+
# - Net::HTTPUnavailableForLegalReasons (451)
|
3653
|
+
#
|
3654
|
+
# - Net::HTTPServerError:
|
3655
|
+
#
|
3656
|
+
# - Net::HTTPInternalServerError (500)
|
3657
|
+
# - Net::HTTPNotImplemented (501)
|
3658
|
+
# - Net::HTTPBadGateway (502)
|
3659
|
+
# - Net::HTTPServiceUnavailable (503)
|
3660
|
+
# - Net::HTTPGatewayTimeOut (504)
|
3661
|
+
# - Net::HTTPVersionNotSupported (505)
|
3662
|
+
# - Net::HTTPVariantAlsoNegotiates (506)
|
3663
|
+
# - Net::HTTPInsufficientStorage (507)
|
3664
|
+
# - Net::HTTPLoopDetected (508)
|
3665
|
+
# - Net::HTTPNotExtended (510)
|
3666
|
+
# - Net::HTTPNetworkAuthenticationRequired (511)
|
3667
|
+
#
|
3668
|
+
# There is also the Net::HTTPBadResponse exception which is raised when
|
3669
|
+
# there is a protocol error.
|
3670
|
+
#
|
3671
|
+
# source://net-http//lib/net/http/response.rb#135
|
3672
|
+
class Net::HTTPResponse
|
3673
|
+
include ::Net::HTTPHeader
|
3674
|
+
|
3675
|
+
# @return [HTTPResponse] a new instance of HTTPResponse
|
3676
|
+
#
|
3677
|
+
# source://net-http//lib/net/http/response.rb#194
|
3678
|
+
def initialize(httpv, code, msg); end
|
3679
|
+
|
3680
|
+
# Returns the string response body;
|
3681
|
+
# note that repeated calls for the unmodified body return a cached string:
|
3682
|
+
#
|
3683
|
+
# path = '/todos/1'
|
3684
|
+
# Net::HTTP.start(hostname) do |http|
|
3685
|
+
# res = http.get(path)
|
3686
|
+
# p res.body
|
3687
|
+
# p http.head(path).body # No body.
|
3688
|
+
# end
|
3689
|
+
#
|
3690
|
+
# Output:
|
3691
|
+
#
|
3692
|
+
# "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}"
|
3693
|
+
# nil
|
3694
|
+
#
|
3695
|
+
# source://net-http//lib/net/http/response.rb#400
|
3696
|
+
def body; end
|
3697
|
+
|
3698
|
+
# Sets the body of the response to the given value.
|
3699
|
+
#
|
3700
|
+
# source://net-http//lib/net/http/response.rb#405
|
3701
|
+
def body=(value); end
|
3702
|
+
|
3703
|
+
# Returns the value set by body_encoding=, or +false+ if none;
|
3704
|
+
# see #body_encoding=.
|
3705
|
+
#
|
3706
|
+
# source://net-http//lib/net/http/response.rb#229
|
3707
|
+
def body_encoding; end
|
3708
|
+
|
3709
|
+
# Sets the encoding that should be used when reading the body:
|
3710
|
+
#
|
3711
|
+
# - If the given value is an Encoding object, that encoding will be used.
|
3712
|
+
# - Otherwise if the value is a string, the value of
|
3713
|
+
# {Encoding#find(value)}[https://docs.ruby-lang.org/en/master/Encoding.html#method-c-find]
|
3714
|
+
# will be used.
|
3715
|
+
# - Otherwise an encoding will be deduced from the body itself.
|
3716
|
+
#
|
3717
|
+
# Examples:
|
3718
|
+
#
|
3719
|
+
# http = Net::HTTP.new(hostname)
|
3720
|
+
# req = Net::HTTP::Get.new('/')
|
3721
|
+
#
|
3722
|
+
# http.request(req) do |res|
|
3723
|
+
# p res.body.encoding # => #<Encoding:ASCII-8BIT>
|
3724
|
+
# end
|
3725
|
+
#
|
3726
|
+
# http.request(req) do |res|
|
3727
|
+
# res.body_encoding = "UTF-8"
|
3728
|
+
# p res.body.encoding # => #<Encoding:UTF-8>
|
3729
|
+
# end
|
3730
|
+
#
|
3731
|
+
# source://net-http//lib/net/http/response.rb#253
|
3732
|
+
def body_encoding=(value); end
|
3733
|
+
|
3734
|
+
# The HTTP result code string. For example, '302'. You can also
|
3735
|
+
# determine the response type by examining which response subclass
|
3736
|
+
# the response object is an instance of.
|
3737
|
+
#
|
3738
|
+
# source://net-http//lib/net/http/response.rb#213
|
3739
|
+
def code; end
|
3740
|
+
|
3741
|
+
# response <-> exception relationship
|
3742
|
+
#
|
3743
|
+
# source://net-http//lib/net/http/response.rb#270
|
3744
|
+
def code_type; end
|
3745
|
+
|
3746
|
+
# Set to true automatically when the request did not contain an
|
3747
|
+
# Accept-Encoding header from the user.
|
3748
|
+
#
|
3749
|
+
# source://net-http//lib/net/http/response.rb#225
|
3750
|
+
def decode_content; end
|
3751
|
+
|
3752
|
+
# Set to true automatically when the request did not contain an
|
3753
|
+
# Accept-Encoding header from the user.
|
3754
|
+
#
|
3755
|
+
# source://net-http//lib/net/http/response.rb#225
|
3756
|
+
def decode_content=(_arg0); end
|
3757
|
+
|
3758
|
+
# Returns the string response body;
|
3759
|
+
# note that repeated calls for the unmodified body return a cached string:
|
3760
|
+
#
|
3761
|
+
# path = '/todos/1'
|
3762
|
+
# Net::HTTP.start(hostname) do |http|
|
3763
|
+
# res = http.get(path)
|
3764
|
+
# p res.body
|
3765
|
+
# p http.head(path).body # No body.
|
3766
|
+
# end
|
3767
|
+
#
|
3768
|
+
# Output:
|
3769
|
+
#
|
3770
|
+
# "{\n \"userId\": 1,\n \"id\": 1,\n \"title\": \"delectus aut autem\",\n \"completed\": false\n}"
|
3771
|
+
# nil
|
3772
|
+
#
|
3773
|
+
# source://net-http//lib/net/http/response.rb#400
|
3774
|
+
def entity; end
|
3775
|
+
|
3776
|
+
# @raise [error_type()]
|
3777
|
+
#
|
3778
|
+
# source://net-http//lib/net/http/response.rb#274
|
3779
|
+
def error!; end
|
3780
|
+
|
3781
|
+
# source://net-http//lib/net/http/response.rb#280
|
3782
|
+
def error_type; end
|
3783
|
+
|
3784
|
+
# source://net-http//lib/net/http/response.rb#302
|
3785
|
+
def header; end
|
3786
|
+
|
3787
|
+
# The HTTP version supported by the server.
|
3788
|
+
#
|
3789
|
+
# source://net-http//lib/net/http/response.rb#208
|
3790
|
+
def http_version; end
|
3791
|
+
|
3792
|
+
# Whether to ignore EOF when reading bodies with a specified Content-Length
|
3793
|
+
# header.
|
3794
|
+
#
|
3795
|
+
# source://net-http//lib/net/http/response.rb#260
|
3796
|
+
def ignore_eof; end
|
3797
|
+
|
3798
|
+
# Whether to ignore EOF when reading bodies with a specified Content-Length
|
3799
|
+
# header.
|
3800
|
+
#
|
3801
|
+
# source://net-http//lib/net/http/response.rb#260
|
3802
|
+
def ignore_eof=(_arg0); end
|
3803
|
+
|
3804
|
+
# source://net-http//lib/net/http/response.rb#262
|
3805
|
+
def inspect; end
|
3806
|
+
|
3807
|
+
# The HTTP result message sent by the server. For example, 'Not Found'.
|
3808
|
+
#
|
3809
|
+
# source://net-http//lib/net/http/response.rb#216
|
3810
|
+
def message; end
|
3811
|
+
|
3812
|
+
# The HTTP result message sent by the server. For example, 'Not Found'.
|
3813
|
+
#
|
3814
|
+
# source://net-http//lib/net/http/response.rb#216
|
3815
|
+
def msg; end
|
3816
|
+
|
3817
|
+
# Gets the entity body returned by the remote HTTP server.
|
3818
|
+
#
|
3819
|
+
# If a block is given, the body is passed to the block, and
|
3820
|
+
# the body is provided in fragments, as it is read in from the socket.
|
3821
|
+
#
|
3822
|
+
# If +dest+ argument is given, response is read into that variable,
|
3823
|
+
# with <code>dest#<<</code> method (it could be String or IO, or any
|
3824
|
+
# other object responding to <code><<</code>).
|
3825
|
+
#
|
3826
|
+
# Calling this method a second or subsequent time for the same
|
3827
|
+
# HTTPResponse object will return the value already read.
|
3828
|
+
#
|
3829
|
+
# http.request_get('/index.html') {|res|
|
3830
|
+
# puts res.read_body
|
3831
|
+
# }
|
3832
|
+
#
|
3833
|
+
# http.request_get('/index.html') {|res|
|
3834
|
+
# p res.read_body.object_id # 538149362
|
3835
|
+
# p res.read_body.object_id # 538149362
|
3836
|
+
# }
|
3837
|
+
#
|
3838
|
+
# # using iterator
|
3839
|
+
# http.request_get('/index.html') {|res|
|
3840
|
+
# res.read_body do |segment|
|
3841
|
+
# print segment
|
3842
|
+
# end
|
3843
|
+
# }
|
3844
|
+
#
|
3845
|
+
# source://net-http//lib/net/http/response.rb#355
|
3846
|
+
def read_body(dest = T.unsafe(nil), &block); end
|
3847
|
+
|
3848
|
+
# source://net-http//lib/net/http/response.rb#307
|
3849
|
+
def read_header; end
|
3850
|
+
|
3851
|
+
# body
|
3852
|
+
#
|
3853
|
+
# source://net-http//lib/net/http/response.rb#316
|
3854
|
+
def reading_body(sock, reqmethodallowbody); end
|
3855
|
+
|
3856
|
+
# header (for backward compatibility only; DO NOT USE)
|
3857
|
+
#
|
3858
|
+
# source://net-http//lib/net/http/response.rb#297
|
3859
|
+
def response; end
|
3860
|
+
|
3861
|
+
# The URI used to fetch this response. The response URI is only available
|
3862
|
+
# if a URI was used to create the request.
|
3863
|
+
#
|
3864
|
+
# source://net-http//lib/net/http/response.rb#221
|
3865
|
+
def uri; end
|
3866
|
+
|
3867
|
+
# source://net-http//lib/net/http/response.rb#289
|
3868
|
+
def uri=(uri); end
|
3869
|
+
|
3870
|
+
# Raises an HTTP error if the response is not 2xx (success).
|
3871
|
+
#
|
3872
|
+
# source://net-http//lib/net/http/response.rb#285
|
3873
|
+
def value; end
|
3874
|
+
|
3875
|
+
private
|
3876
|
+
|
3877
|
+
# source://net-http//lib/net/http/response.rb#450
|
3878
|
+
def check_bom(str); end
|
3879
|
+
|
3880
|
+
# source://net-http//lib/net/http/response.rb#414
|
3881
|
+
def detect_encoding(str, encoding = T.unsafe(nil)); end
|
3882
|
+
|
3883
|
+
# source://net-http//lib/net/http/response.rb#540
|
3884
|
+
def extracting_encodings_from_meta_elements(value); end
|
3885
|
+
|
3886
|
+
# source://net-http//lib/net/http/response.rb#505
|
3887
|
+
def get_attribute(ss); end
|
3888
|
+
|
3889
|
+
# Checks for a supported Content-Encoding header and yields an Inflate
|
3890
|
+
# wrapper for this response's socket when zlib is present. If the
|
3891
|
+
# Content-Encoding is not supported or zlib is missing, the plain socket is
|
3892
|
+
# yielded.
|
3893
|
+
#
|
3894
|
+
# If a Content-Range header is present, a plain socket is yielded as the
|
3895
|
+
# bytes in the range may not be a complete deflate block.
|
3896
|
+
#
|
3897
|
+
# source://net-http//lib/net/http/response.rb#557
|
3898
|
+
def inflater; end
|
3899
|
+
|
3900
|
+
# @raise [ArgumentError]
|
3901
|
+
#
|
3902
|
+
# source://net-http//lib/net/http/response.rb#646
|
3903
|
+
def procdest(dest, block); end
|
3904
|
+
|
3905
|
+
# source://net-http//lib/net/http/response.rb#592
|
3906
|
+
def read_body_0(dest); end
|
3907
|
+
|
3908
|
+
# read_chunked reads from +@socket+ for chunk-size, chunk-extension, CRLF,
|
3909
|
+
# etc. and +chunk_data_io+ for chunk-data which may be deflate or gzip
|
3910
|
+
# encoded.
|
3911
|
+
#
|
3912
|
+
# See RFC 2616 section 3.6.1 for definitions
|
3913
|
+
#
|
3914
|
+
# source://net-http//lib/net/http/response.rb#622
|
3915
|
+
def read_chunked(dest, chunk_data_io); end
|
3916
|
+
|
3917
|
+
# source://net-http//lib/net/http/response.rb#464
|
3918
|
+
def scanning_meta(str); end
|
3919
|
+
|
3920
|
+
# source://net-http//lib/net/http/response.rb#434
|
3921
|
+
def sniff_encoding(str, encoding = T.unsafe(nil)); end
|
3922
|
+
|
3923
|
+
# @raise [IOError]
|
3924
|
+
#
|
3925
|
+
# source://net-http//lib/net/http/response.rb#642
|
3926
|
+
def stream_check; end
|
3927
|
+
|
3928
|
+
class << self
|
3929
|
+
# true if the response has a body.
|
3930
|
+
#
|
3931
|
+
# @return [Boolean]
|
3932
|
+
#
|
3933
|
+
# source://net-http//lib/net/http/response.rb#138
|
3934
|
+
def body_permitted?; end
|
3935
|
+
|
3936
|
+
# source://net-http//lib/net/http/response.rb#142
|
3937
|
+
def exception_type; end
|
3938
|
+
|
3939
|
+
# source://net-http//lib/net/http/response.rb#146
|
3940
|
+
def read_new(sock); end
|
3941
|
+
|
3942
|
+
private
|
3943
|
+
|
3944
|
+
# @yield [key, value]
|
3945
|
+
#
|
3946
|
+
# source://net-http//lib/net/http/response.rb#170
|
3947
|
+
def each_response_header(sock); end
|
3948
|
+
|
3949
|
+
# source://net-http//lib/net/http/response.rb#157
|
3950
|
+
def read_status_line(sock); end
|
3951
|
+
|
3952
|
+
# source://net-http//lib/net/http/response.rb#164
|
3953
|
+
def response_class(code); end
|
3954
|
+
end
|
3955
|
+
end
|
3956
|
+
|
3957
|
+
# Inflater is a wrapper around Net::BufferedIO that transparently inflates
|
3958
|
+
# zlib and gzip streams.
|
3959
|
+
#
|
3960
|
+
# source://net-http//lib/net/http/response.rb#660
|
3961
|
+
class Net::HTTPResponse::Inflater
|
3962
|
+
# Creates a new Inflater wrapping +socket+
|
3963
|
+
#
|
3964
|
+
# @return [Inflater] a new instance of Inflater
|
3965
|
+
#
|
3966
|
+
# source://net-http//lib/net/http/response.rb#665
|
3967
|
+
def initialize(socket); end
|
3968
|
+
|
3969
|
+
# The number of bytes inflated, used to update the Content-Length of
|
3970
|
+
# the response.
|
3971
|
+
#
|
3972
|
+
# source://net-http//lib/net/http/response.rb#683
|
3973
|
+
def bytes_inflated; end
|
3974
|
+
|
3975
|
+
# Finishes the inflate stream.
|
3976
|
+
#
|
3977
|
+
# source://net-http//lib/net/http/response.rb#674
|
3978
|
+
def finish; end
|
3979
|
+
|
3980
|
+
# Returns a Net::ReadAdapter that inflates each read chunk into +dest+.
|
3981
|
+
#
|
3982
|
+
# This allows a large response body to be inflated without storing the
|
3983
|
+
# entire body in memory.
|
3984
|
+
#
|
3985
|
+
# source://net-http//lib/net/http/response.rb#693
|
3986
|
+
def inflate_adapter(dest); end
|
3987
|
+
|
3988
|
+
# Reads +clen+ bytes from the socket, inflates them, then writes them to
|
3989
|
+
# +dest+. +ignore_eof+ is passed down to Net::BufferedIO#read
|
3990
|
+
#
|
3991
|
+
# Unlike Net::BufferedIO#read, this method returns more than +clen+ bytes.
|
3992
|
+
# At this time there is no way for a user of Net::HTTPResponse to read a
|
3993
|
+
# specific number of bytes from the HTTP response body, so this internal
|
3994
|
+
# API does not return the same number of bytes as were requested.
|
3995
|
+
#
|
3996
|
+
# See https://bugs.ruby-lang.org/issues/6492 for further discussion.
|
3997
|
+
#
|
3998
|
+
# source://net-http//lib/net/http/response.rb#720
|
3999
|
+
def read(clen, dest, ignore_eof = T.unsafe(nil)); end
|
4000
|
+
|
4001
|
+
# Reads the rest of the socket, inflates it, then writes it to +dest+.
|
4002
|
+
#
|
4003
|
+
# source://net-http//lib/net/http/response.rb#729
|
4004
|
+
def read_all(dest); end
|
4005
|
+
end
|
4006
|
+
|
4007
|
+
# source://net-http//lib/net/http/backward.rb#26
|
4008
|
+
Net::HTTPResponseReceiver = Net::HTTPResponse
|
4009
|
+
|
4010
|
+
# source://net-http//lib/net/http/backward.rb#22
|
4011
|
+
Net::HTTPRetriableCode = Net::HTTPRedirection
|
4012
|
+
|
4013
|
+
# source://net-http//lib/net/http/responses.rb#81
|
4014
|
+
Net::HTTPServerError::EXCEPTION_TYPE = Net::HTTPFatalError
|
4015
|
+
|
4016
|
+
# source://net-http//lib/net/http/backward.rb#25
|
4017
|
+
Net::HTTPServerErrorCode = Net::HTTPServerError
|
4018
|
+
|
4019
|
+
# source://net-http//lib/net/http/backward.rb#17
|
4020
|
+
Net::HTTPSession = Net::HTTP
|
4021
|
+
|
4022
|
+
# source://net-http//lib/net/http/responses.rb#38
|
4023
|
+
Net::HTTPSuccess::EXCEPTION_TYPE = Net::HTTPError
|
4024
|
+
|
4025
|
+
# source://net-http//lib/net/http/backward.rb#20
|
4026
|
+
Net::HTTPSuccessCode = Net::HTTPSuccess
|
4027
|
+
|
4028
|
+
# Response class for <tt>URI Too Long</tt> responses (status code 414).
|
4029
|
+
#
|
4030
|
+
# The URI provided was too long for the server to process.
|
4031
|
+
#
|
4032
|
+
# :include: doc/net-http/included_getters.rdoc
|
4033
|
+
#
|
4034
|
+
# References:
|
4035
|
+
#
|
4036
|
+
# - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/414].
|
4037
|
+
# - {RFC 9110}[https://www.rfc-editor.org/rfc/rfc9110.html#name-414-uri-too-long].
|
4038
|
+
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#414].
|
4039
|
+
#
|
4040
|
+
# source://net-http//lib/net/http/responses.rb#705
|
4041
|
+
class Net::HTTPURITooLong < ::Net::HTTPClientError; end
|
4042
|
+
|
4043
|
+
# source://net-http//lib/net/http/responses.rb#706
|
4044
|
+
Net::HTTPURITooLong::HAS_BODY = T.let(T.unsafe(nil), TrueClass)
|
4045
|
+
|
4046
|
+
# source://net-http//lib/net/http/responses.rb#9
|
4047
|
+
Net::HTTPUnknownResponse::EXCEPTION_TYPE = Net::HTTPError
|
4048
|
+
|
4049
|
+
# Response class for <tt>Variant Also Negotiates</tt> responses (status code 506).
|
4050
|
+
#
|
4051
|
+
# Transparent content negotiation for the request results in a circular reference.
|
4052
|
+
#
|
4053
|
+
# :include: doc/net-http/included_getters.rdoc
|
4054
|
+
#
|
4055
|
+
# References:
|
4056
|
+
#
|
4057
|
+
# - {Mozilla}[https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/506].
|
4058
|
+
# - {RFC 2295}[https://www.rfc-editor.org/rfc/rfc2295#section-8.1].
|
4059
|
+
# - {Wikipedia}[https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#506].
|
4060
|
+
#
|
4061
|
+
# source://net-http//lib/net/http/responses.rb#1029
|
4062
|
+
class Net::HTTPVariantAlsoNegotiates < ::Net::HTTPServerError; end
|
4063
|
+
|
4064
|
+
# source://net-http//lib/net/http/responses.rb#1030
|
4065
|
+
Net::HTTPVariantAlsoNegotiates::HAS_BODY = T.let(T.unsafe(nil), TrueClass)
|
4066
|
+
|
4067
|
+
# source://net-http//lib/net/http/backward.rb#12
|
4068
|
+
Net::NetPrivate::HTTPRequest = Net::HTTPRequest
|