Class: Netbout::Http
- Inherits:
-
Object
- Object
- Netbout::Http
- Defined in:
- lib/netbout/http.rb
Overview
Http page
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(iri, token) ⇒ Http
constructor
A new instance of Http.
- #post(hash) ⇒ Object
Constructor Details
#initialize(iri, token) ⇒ Http
Returns a new instance of Http.
40 41 42 43 |
# File 'lib/netbout/http.rb', line 40 def initialize(iri, token) @iri = iri @token = token end |
Instance Method Details
#get ⇒ Object
45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/netbout/http.rb', line 45 def get checked( Typhoeus::Request.get( @iri.to_s, accept_encoding: 'gzip', headers: headers, connecttimeout: CONNECT_TIMEOUT, timeout: CONNECT_TIMEOUT ) ) end |
#post(hash) ⇒ Object
57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
# File 'lib/netbout/http.rb', line 57 def post(hash) checked( Typhoeus::Request.post( @iri.to_s, accept_encoding: 'gzip', body: hash.map { |k, v| "#{k}=#{CGI.escape(v)}" }.join('&'), headers: headers.merge( 'Content-Type': 'application/x-www-form-urlencoded' ), connecttimeout: CONNECT_TIMEOUT, timeout: CONNECT_TIMEOUT ) ) end |