Class: FocusNfe::HTTP::Adapters::NetHttp
- Inherits:
-
FocusNfe::HTTP::Adapter
- Object
- FocusNfe::HTTP::Adapter
- FocusNfe::HTTP::Adapters::NetHttp
- Defined in:
- lib/focus_nfe/http/adapters/net_http.rb
Overview
Adaptador HTTP padrão, implementado sobre a stdlib (+Net::HTTP+), sem
dependências externas. Aplica os timeouts recebidos no construtor, usa TLS
para URLs https, segue redirecionamentos 302 de download apenas para
destinos https (sem reenviar Authorization) e relança falhas de
transporte como Errors::ConnectionError.
Constant Summary collapse
- MAX_REDIRECTS =
Returns número máximo de redirecionamentos 302 seguidos.
5- VERBS =
Returns verbo => classe de requisição Net::HTTP.
{ get: Net::HTTP::Get, post: Net::HTTP::Post, put: Net::HTTP::Put, delete: Net::HTTP::Delete }.freeze
Instance Method Summary collapse
- #call(method, url, headers: {}, body: nil) ⇒ FocusNfe::HTTP::Response
-
#initialize(timeout: nil, open_timeout: nil) ⇒ NetHttp
constructor
A new instance of NetHttp.
Constructor Details
#initialize(timeout: nil, open_timeout: nil) ⇒ NetHttp
Returns a new instance of NetHttp.
29 30 31 32 33 |
# File 'lib/focus_nfe/http/adapters/net_http.rb', line 29 def initialize(timeout: nil, open_timeout: nil) super() @timeout = timeout @open_timeout = open_timeout end |
Instance Method Details
#call(method, url, headers: {}, body: nil) ⇒ FocusNfe::HTTP::Response
41 42 43 |
# File 'lib/focus_nfe/http/adapters/net_http.rb', line 41 def call(method, url, headers: {}, body: nil) dispatch(method, URI(url), headers, body, MAX_REDIRECTS) end |