active_shipping
active_shipping copied to clipboard
USPS returns gzip response
I've trying to see if my USPS credentials are valid, but I'm getting NoMethodError: undefined method `name' for nil:NilClass.
I jumped into the code and it seems that the response from USPS is gzipped.
My very bad solution for this in active_shipping/shipping/carriers/usps.rb
def commit(action, request, test = false)
response = ssl_get(request_url(action, request, test))
response.include?('xml') ? response : Zlib::GzipReader.new(StringIO.new(response)).read
end
I would imagine there is a better way to test if the string is gzipped or to request that it not be gzipped in the first place. I have a pretty basic setup and spent a few hours tracking this down. I didn't expect 2 basic lines in the tutorial to cause so much trouble.