-
Notifications
You must be signed in to change notification settings - Fork 80
[DOC] Clarify strategies #106
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -34,67 +34,71 @@ class HTTPHeaderSyntaxError < StandardError; end | |
|
|
||
| # \Class \Net::HTTP provides a rich library that implements the client | ||
| # in a client-server model that uses the \HTTP request-response protocol. | ||
| # For information about \HTTP, see | ||
| # For information about \HTTP, see: | ||
| # | ||
| # - {Hypertext Transfer Protocol}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol]. | ||
| # - {Technical overview}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Technical_overview]. | ||
| # | ||
| # Note: If you are performing only a few GET requests, consider using | ||
| # {OpenURI}[https://docs.ruby-lang.org/en/master/OpenURI.html]; | ||
| # otherwise, read on. | ||
| # | ||
| # == Synopsis | ||
| # | ||
| # If you are already familiar with \HTTP, this synopsis may be helpful. | ||
| # | ||
| # {Session}[rdoc-ref:Net::HTTP@Sessions] with multiple requests for | ||
| # {HTTP methods}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods]: | ||
| # | ||
| # Net::HTTP.start(hostname) do |http| | ||
| # # Session started automatically before block execution. | ||
| # http.get(path_or_uri, headers = {}) | ||
| # http.head(path_or_uri, headers = {}) | ||
| # http.post(path_or_uri, data, headers = {}) # Can also have a block. | ||
| # http.put(path_or_uri, data, headers = {}) | ||
| # http.delete(path_or_uri, headers = {Depth: 'Infinity'}) | ||
| # http.options(path_or_uri, headers = {}) | ||
| # http.trace(path_or_uri, headers = {}) | ||
| # http.patch(path_or_uri, data, headers = {}) # Can also have a block. | ||
| # # Session finished automatically at block exit. | ||
| # end | ||
| # | ||
| # {Session}[rdoc-ref:Net::HTTP@Sessions] with multiple requests for | ||
| # {WebDAV methods}[https://en.wikipedia.org/wiki/WebDAV#Implementation]: | ||
| # | ||
| # Net::HTTP.start(hostname) do |http| | ||
| # # Session started automatically before block execution. | ||
| # http.copy(path_or_uri, headers = {}) | ||
| # http.lock(path_or_uri, body, headers = {}) | ||
| # http.mkcol(path_or_uri, body = nil, headers = {}) | ||
| # http.move(path_or_uri, headers = {}) | ||
| # http.propfind(path_or_uri, body = nil, headers = {'Depth' => '0'}) | ||
| # http.proppatch(path_or_uri, body, headers = {}) | ||
| # http.unlock(path_or_uri, body, headers = {}) | ||
| # # Session finished automatically at block exit. | ||
| # end | ||
| # | ||
| # Each of the following methods automatically starts and finishes | ||
| # a {session}[rdoc-ref:Net::HTTP@Sessions] that sends a single request: | ||
| # | ||
| # # Return string response body. | ||
| # Net::HTTP.get(hostname, path, port = 80) | ||
| # Net::HTTP.get(uri, headers = {}, port = 80) | ||
| # == Strategies | ||
| # | ||
| # - If you will make only a few GET requests, | ||
| # consider using {OpenURI}[https://docs.ruby-lang.org/en/master/OpenURI.html]. | ||
| # - If performance is _not_ important, | ||
| # consider using various convenience methods in this class. | ||
| # Each of the following methods automatically starts and finishes | ||
| # a {session}[rdoc-ref:Net::HTTP@Sessions] that sends a single request: | ||
| # | ||
| # # Return string response body. | ||
| # Net::HTTP.get(hostname, path, port = 80) | ||
| # Net::HTTP.get(uri, headers = {}, port = 80) | ||
| # | ||
| # # Write string response body to $stdout. | ||
| # Net::HTTP.get_print(hostname, path_or_uri, port = 80) | ||
| # Net::HTTP.get_print(uri, headers = {}, port = 80) | ||
| # | ||
| # # Return response as Net::HTTPResponse object. | ||
| # Net::HTTP.get_response(hostname, path_or_uri, port = 80) | ||
| # Net::HTTP.get_response(uri, headers = {}, port = 80) | ||
| # Net::HTTP.post(uri, data, headers = {}) | ||
| # Net::HTTP.post_form(uri, params) | ||
| # | ||
| # - If performance _is_ important, consider using sessions, which lower request overhead: | ||
| # | ||
| # - {Session}[rdoc-ref:Net::HTTP@Sessions] with multiple requests for | ||
| # {HTTP methods}[https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol#Request_methods]: | ||
| # | ||
| # Net::HTTP.start(hostname) do |http| | ||
| # # Session started automatically before block execution. | ||
| # http.get(path_or_uri, headers = {}) | ||
| # http.head(path_or_uri, headers = {}) | ||
| # http.post(path_or_uri, body, headers = {}) # Can also have a block. | ||
| # http.put(path_or_uri, body, headers = {}) | ||
| # http.delete(path_or_uri, headers = {Depth: 'Infinity'}) | ||
| # http.options(path_or_uri, headers = {}) | ||
| # http.trace(path_or_uri, headers = {}) | ||
| # http.patch(path_or_uri, body, headers = {}) # Can also have a block. | ||
| # # Session finished automatically at block exit. | ||
| # end | ||
| # | ||
| # # Write string response body to $stdout. | ||
| # Net::HTTP.get_print(hostname, path_or_uri, port = 80) | ||
| # Net::HTTP.get_print(uri, headers = {}, port = 80) | ||
| # - {Session}[rdoc-ref:Net::HTTP@Sessions] with multiple requests for | ||
| # {WebDAV methods}[https://en.wikipedia.org/wiki/WebDAV#Implementation]: | ||
| # | ||
| # Net::HTTP.start(hostname) do |http| | ||
| # # Session started automatically before block execution. | ||
| # http.copy(path_or_uri, headers = {}) | ||
| # http.lock(path_or_uri, body, headers = {}) | ||
| # http.mkcol(path_or_uri, body = nil, headers = {}) | ||
| # http.move(path_or_uri, headers = {}) | ||
| # http.propfind(path_or_uri, body = nil, headers = {'Depth' => '0'}) | ||
| # http.proppatch(path_or_uri, body, headers = {}) | ||
| # http.unlock(path_or_uri, body, headers = {}) | ||
| # # Session finished automatically at block exit. | ||
| # end | ||
|
||
| # | ||
| # # Return response as Net::HTTPResponse object. | ||
| # Net::HTTP.get_response(hostname, path_or_uri, port = 80) | ||
| # Net::HTTP.get_response(uri, headers = {}, port = 80) | ||
| # The methods cited above are convenience methods that, via their few arguments, | ||
| # allow minimal control over the requests. | ||
| # For greater control, consider using {request objects}[rdoc-ref:Net::HTTPRequest]. | ||
| # | ||
| # Net::HTTP.post(uri, data, headers = {}) | ||
| # Net::HTTP.post_form(uri, params) | ||
| # | ||
| # == About the Examples | ||
| # | ||
|
|
@@ -183,7 +187,7 @@ class HTTPHeaderSyntaxError < StandardError; end | |
| # - May contain any number of requests. | ||
| # - Is ended by instance method Net::HTTP#finish. | ||
| # | ||
| # See example sessions at the {Synopsis}[rdoc-ref:Net::HTTP@Synopsis]. | ||
| # See example sessions at {Strategies}[rdoc-ref:Net::HTTP@Strategies]. | ||
| # | ||
| # === Session Using \Net::HTTP.start | ||
| # | ||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what this means. Why is using these methods bad for performance? If you're just sending a single request then it shouldn't be any slower right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Modified.