Class: Faye::Authentication::HTTPClient
- Inherits:
-
Object
- Object
- Faye::Authentication::HTTPClient
- Defined in:
- lib/faye/authentication/http_client.rb
Class Method Summary collapse
- .prepare_request(uri, channel, data, key, options = {}) ⇒ Object
- .publish(url, channel, data, key, options = {}) ⇒ Object
Class Method Details
.prepare_request(uri, channel, data, key, options = {}) ⇒ Object
13 14 15 16 17 18 19 20 |
# File 'lib/faye/authentication/http_client.rb', line 13 def self.prepare_request(uri, channel, data, key, = {}) req = Net::HTTP::Post.new(uri) = {'channel' => channel, 'clientId' => 'http'} ['signature'] = Faye::Authentication.sign(, key) if Faye::Authentication.authentication_required?(, ) ['data'] = data req.set_form_data(message: JSON.dump()) req end |
.publish(url, channel, data, key, options = {}) ⇒ Object
7 8 9 10 11 |
# File 'lib/faye/authentication/http_client.rb', line 7 def self.publish(url, channel, data, key, = {}) uri = URI(url) req = prepare_request(uri.request_uri, channel, data, key, ) Net::HTTP.start(uri.hostname, uri.port, :use_ssl => uri.scheme == 'https') { |http| http.request(req) } end |