Class: Zold::Http
- Inherits:
-
Object
- Object
- Zold::Http
- Defined in:
- lib/zold/http.rb
Overview
Http page
Constant Summary collapse
- SCORE_HEADER =
'X-Zold-Score'.freeze
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(uri, score = Score::ZERO) ⇒ Http
constructor
A new instance of Http.
- #put(body) ⇒ Object
Constructor Details
Instance Method Details
#get ⇒ Object
40 41 42 43 44 45 46 |
# File 'lib/zold/http.rb', line 40 def get http = Net::HTTP.new(@uri.host, @uri.port) http.read_timeout = 5 return http.request_get(@uri.path, headers) rescue StandardError => e return Net::HTTPServerError.new('1.1', '599', e.) end |
#put(body) ⇒ Object
48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/zold/http.rb', line 48 def put(body) http = Net::HTTP.new(@uri.host, @uri.port) http.read_timeout = 60 return http.request_put( @uri.path, body, headers.merge( 'Content-Type': 'text/plain', 'Content-Length': body.length.to_s ) ) rescue StandardError => e return Net::HTTPServerError.new('1.1', '599', e.) end |