Fix AMFPHP requests
Okay, right, if we're just using www.neopets.com (like we are for now), it fails on http://www.neopets.com because it triggers a redirect that we don't follow. So here I 1) change the default to HTTPS, and 2) add HTTPS support to our little RocketAMF lib
This commit is contained in:
parent
a21ae014ef
commit
cbad00f32d
2 changed files with 2 additions and 1 deletions
|
@ -2,7 +2,7 @@ require 'rocketamf/remote_gateway'
|
||||||
require 'ostruct'
|
require 'ostruct'
|
||||||
|
|
||||||
class Pet < ApplicationRecord
|
class Pet < ApplicationRecord
|
||||||
NEOPETS_URL_ORIGIN = ENV['NEOPETS_URL_ORIGIN'] || 'http://www.neopets.com'
|
NEOPETS_URL_ORIGIN = ENV['NEOPETS_URL_ORIGIN'] || 'https://www.neopets.com'
|
||||||
GATEWAY_URL = NEOPETS_URL_ORIGIN + '/amfphp/gateway.php'
|
GATEWAY_URL = NEOPETS_URL_ORIGIN + '/amfphp/gateway.php'
|
||||||
PET_VIEWER = RocketAMF::RemoteGateway.new(GATEWAY_URL).
|
PET_VIEWER = RocketAMF::RemoteGateway.new(GATEWAY_URL).
|
||||||
service('CustomPetService').action('getViewerData')
|
service('CustomPetService').action('getViewerData')
|
||||||
|
|
|
@ -80,6 +80,7 @@ module RocketAMF
|
||||||
def send_request(uri, req)
|
def send_request(uri, req)
|
||||||
begin
|
begin
|
||||||
http = Net::HTTP.new(uri.host, uri.port)
|
http = Net::HTTP.new(uri.host, uri.port)
|
||||||
|
http.use_ssl = true if uri.instance_of? URI::HTTPS
|
||||||
return http.request(req)
|
return http.request(req)
|
||||||
rescue Exception => e
|
rescue Exception => e
|
||||||
raise ConnectionError, e.message
|
raise ConnectionError, e.message
|
||||||
|
|
Loading…
Reference in a new issue