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:
Emi Matchu 2023-10-12 18:14:20 -07:00
parent a21ae014ef
commit cbad00f32d
2 changed files with 2 additions and 1 deletions

View file

@ -2,7 +2,7 @@ require 'rocketamf/remote_gateway'
require 'ostruct'
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'
PET_VIEWER = RocketAMF::RemoteGateway.new(GATEWAY_URL).
service('CustomPetService').action('getViewerData')

View file

@ -80,6 +80,7 @@ module RocketAMF
def send_request(uri, req)
begin
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true if uri.instance_of? URI::HTTPS
return http.request(req)
rescue Exception => e
raise ConnectionError, e.message