From cbad00f32dede60da7f38046d1a5164401e26709 Mon Sep 17 00:00:00 2001 From: Matchu Date: Thu, 12 Oct 2023 18:14:20 -0700 Subject: [PATCH] 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 --- app/models/pet.rb | 2 +- lib/rocketamf/remote_gateway/request.rb | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/app/models/pet.rb b/app/models/pet.rb index 16e682a6..e085a9db 100644 --- a/app/models/pet.rb +++ b/app/models/pet.rb @@ -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') diff --git a/lib/rocketamf/remote_gateway/request.rb b/lib/rocketamf/remote_gateway/request.rb index c289f69a..4dcaafda 100644 --- a/lib/rocketamf/remote_gateway/request.rb +++ b/lib/rocketamf/remote_gateway/request.rb @@ -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