Class: Octokit::Middleware::FollowRedirects
- Inherits:
-
Faraday::Middleware
- Object
- Faraday::Middleware
- Octokit::Middleware::FollowRedirects
- Defined in:
- lib/octokit/middleware/follow_redirects.rb
Overview
Public: Follow HTTP 301, 302, 303, and 307 redirects.
For HTTP 303, the original GET, POST, PUT, DELETE, or PATCH request gets converted into a GET. For HTTP 301, 302, and 307, the HTTP method remains unchanged.
This middleware currently only works with synchronous requests; i.e. it doesn’t support parallelism.
Constant Summary collapse
- ALLOWED_METHODS =
HTTP methods for which 30x redirects can be followed
Set.new [:head, :options, :get, :post, :put, :patch, :delete]
- REDIRECT_CODES =
HTTP redirect status codes that this middleware implements
Set.new [301, 302, 303, 307]
- ENV_TO_CLEAR =
Keys in env hash which will get cleared between requests
Set.new [:status, :response, :response_headers]
- FOLLOW_LIMIT =
Default value for max redirects followed
3
- URI_UNSAFE =
Regex that matches characters that need to be escaped in URLs, sans the “%” character which we assume already represents an escaped sequence.
/[^\-_.!~*'()a-zA-Z\d;\/?:@&=+$,\[\]%]/
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, options = {}) ⇒ FollowRedirects
constructor
Public: Initialize the middleware.
Constructor Details
#initialize(app, options = {}) ⇒ FollowRedirects
Public: Initialize the middleware.
options - An options Hash (default: {}):
:limit - A Integer redirect limit (default: 3).
53 54 55 56 57 58 |
# File 'lib/octokit/middleware/follow_redirects.rb', line 53 def initialize(app, = {}) super(app) @options = @convert_to_get = Set.new [303] end |
Instance Method Details
#call(env) ⇒ Object
60 61 62 |
# File 'lib/octokit/middleware/follow_redirects.rb', line 60 def call(env) perform_with_redirection(env, follow_limit) end |