Sha256: 6660ec47ec873bfb2ed56437215eb6f01903e8fc29ec8600c578bc11289111de

Contents?: true

Size: 759 Bytes

Versions: 10

Compression:

Stored size: 759 Bytes

Contents

require 'net/http'
require 'net/https'

module Hoth
  module Transport
    class Https < Http
      def post_payload(payload)
        uri = URI.parse(self.endpoint.to_url)
        
        post = Net::HTTP::Post.new(uri.path)
        
        post.set_form_data({
            'name'        => self.name.to_s,
            'caller_uuid' => Hoth.client_uuid,
            'params'      => encoder.encode(payload)
        }, ';')
        
        request = Net::HTTP.new(uri.host, uri.port)
        request.use_ssl = true
        response = request.start {|http| http.request(post) }
        
        case response
        when Net::HTTPSuccess, Net::HTTPRedirection
          response
        else
          response.error!
        end
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
hoth-0.4.2 lib/hoth/transport/https.rb
hoth-0.4.1 lib/hoth/transport/https.rb
hoth-0.4.0 lib/hoth/transport/https.rb
hoth-0.3.4 lib/hoth/transport/https.rb
hoth-0.3.3 lib/hoth/transport/https.rb
hoth-0.3.2.beta4 lib/hoth/transport/https.rb
hoth-0.3.2.beta3 lib/hoth/transport/https.rb
hoth-0.3.2.beta2 lib/hoth/transport/https.rb
hoth-0.3.2.beta1 lib/hoth/transport/https.rb
hoth-0.3.1 lib/hoth/transport/https.rb