Class: Wayfarer::Networking::HTTP
- Inherits:
-
Object
- Object
- Wayfarer::Networking::HTTP
show all
- Includes:
- Strategy
- Defined in:
- lib/wayfarer/networking/http.rb
Constant Summary
collapse
- CONNECTION_NAME =
"wayfarer"
Instance Method Summary
collapse
Methods included from Strategy
#live, #navigate, #renew_on
Instance Method Details
#create ⇒ Object
10
11
12
13
14
15
16
|
# File 'lib/wayfarer/networking/http.rb', line 10
def create
Net::HTTP::Persistent.new(name: CONNECTION_NAME).tap do |conn|
Wayfarer.config[:network][:http_headers].each do |key, val|
conn.[key] = val
end
end
end
|
#destroy(instance) ⇒ Object
18
19
20
|
# File 'lib/wayfarer/networking/http.rb', line 18
def destroy(instance)
instance.shutdown
end
|
#fetch(instance, url) ⇒ Object
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/wayfarer/networking/http.rb', line 22
def fetch(instance, url)
res = instance.request(URI(url))
return redirect(res["location"]) if res.is_a?(Net::HTTPRedirection)
success(url: url,
status_code: res.code.to_i,
body: res.body,
headers: res.to_hash.transform_values(&:first))
end
|