sk-hoth 0.3.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/TODO CHANGED
@@ -1,2 +1,6 @@
1
+ options for transport
2
+ * https
3
+ * hmac
4
+
1
5
  * Make the rack provider independent from one specific transport.
2
6
  * Make the bodies of the rack_provider return an object which responds to each in order not break on Ruby 1.9.
@@ -1,6 +1,7 @@
1
1
  require 'hoth/transport/base'
2
2
  require 'hoth/transport/http'
3
3
  require 'hoth/transport/http_hmac'
4
+ require 'hoth/transport/https'
4
5
  require 'hoth/transport/bert'
5
6
  require 'hoth/transport/workling'
6
7
 
@@ -21,6 +22,11 @@ module Hoth
21
22
  :encoder => Encoding::Json
22
23
  },
23
24
  :http_hmac => :json_via_http_hmac,
25
+ :json_via_https => {
26
+ :transport_class => Transport::Https,
27
+ :encoder => Encoding::Json
28
+ },
29
+ :https => :json_via_https,
24
30
  :workling => {
25
31
  :transport_class => Transport::Workling
26
32
  }
@@ -0,0 +1,30 @@
1
+ require 'net/http'
2
+ require 'net/https'
3
+
4
+ module Hoth
5
+ module Transport
6
+ class Https < Http
7
+ def post_payload(payload)
8
+ uri = URI.parse(self.endpoint.to_url)
9
+
10
+ post = Net::HTTP::Post.new(uri.path)
11
+
12
+ post.set_form_data({
13
+ 'name' => self.name.to_s,
14
+ 'params' => encoder.encode(payload)
15
+ }, ';')
16
+
17
+ request = Net::HTTP.new(uri.host, uri.port)
18
+ request.use_ssl = true
19
+ response = request.start {|http| http.request(post) }
20
+
21
+ case response
22
+ when Net::HTTPSuccess, Net::HTTPRedirection
23
+ response
24
+ else
25
+ response.error!
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 1
9
- version: 0.3.1
8
+ - 2
9
+ version: 0.3.2
10
10
  platform: ruby
11
11
  authors:
12
12
  - Dirk Breuer
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-04-11 00:00:00 +02:00
18
+ date: 2010-04-14 00:00:00 +02:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -138,6 +138,7 @@ files:
138
138
  - lib/hoth/transport/bert.rb
139
139
  - lib/hoth/transport/http.rb
140
140
  - lib/hoth/transport/http_hmac.rb
141
+ - lib/hoth/transport/https.rb
141
142
  - lib/hoth/transport/workling.rb
142
143
  - lib/hoth/util/logger.rb
143
144
  - spec/spec_helper.rb