USPS returns gzip response #163

Open
tfitts opened this Issue Jun 9, 2014 · 0 comments

Comments

Projects
None yet
1 participant

tfitts commented Jun 9, 2014

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment