Skip to content

Instantly share code, notes, and snippets.

@kenmazaika
Created November 29, 2012 22:49
Show Gist options
  • Select an option

  • Save kenmazaika/4172436 to your computer and use it in GitHub Desktop.

Select an option

Save kenmazaika/4172436 to your computer and use it in GitHub Desktop.
omg_lol.rb
class OmgLol < HTTParty::Request
def perform(&block)
validate
setup_raw_request
chunked_body = nil
# stored locally, changed from just using the method
http_client = http
http_client.ciphers = 'RC4-SHA'
self.last_response = http_client.request(@raw_request) do |http_response|
if block
chunks = []
http_response.read_body do |fragment|
chunks << fragment
block.call(fragment)
end
chunked_body = chunks.join
end
end
handle_deflation
handle_response(chunked_body)
end
def handle_response(body)
if response_redirects?
options[:limit] -= 1
self.path = last_response['location']
self.redirect = true
self.http_method = Net::HTTP::Get unless options[:maintain_method_across_redirects]
capture_cookies(last_response)
perform
else
body = body || last_response.body
HTTParty::Response.new(self, last_response, :body => body)
end
end
end
OmgLol.new(Net::HTTP::Get, "https://www.stage2p1297.stage.paypal.com:10882").perform
=> #<HTTParty::Response:0x5a80ae8 @parsed_response={:body=>"<?xml version='1.0' encoding='UTF-8'?><ms:errorMessage xmlns:ms=\"http://www.ebay.com/marketplace/services\"><ms:error><ms:errorId>2003</ms:errorId><ms:domain>CoreRuntime</ms:domain><ms:subdomain>Inbound_Meta_Data</ms:subdomain><ms:severity>Error</ms:severity><ms:category>Request</ms:category><ms:message>Missing SOA service name header</ms:message></ms:error><ms:error><ms:errorId>2038</ms:errorId><ms:domain>CoreRuntime</ms:domain><ms:subdomain>System</ms:subdomain><ms:severity>Error</ms:severity><ms:category>System</ms:category><ms:message>Missing SOA operation name header</ms:message></ms:error></ms:errorMessage>"}, @response=#<Net::HTTPInternalServerError 500 Internal Server Error readbody=true>, @headers={"server"=>["Apache-Coyote/1.1"], "x-ebay-soa-error-response"=>["TRUE"], "x-ebay-soa-request-id"=>["13b4e5b3-6e50-a395-b0f7-89c7ffffffc5!NO SERVICE!10.57.91.15![]"], "x-ebay-soa-message-protocol"=>["NONE"], "x-ebay-soa-response-data-format"=>["XML"], "x-ebay-soa-operation-name"=>["***null***"], "x-ebay-soa-service-name"=>["NO SERVICE"], "content-type"=>["text/xml;charset=UTF-8"], "date"=>["Thu, 29 Nov 2012 22:48:18 GMT"], "connection"=>["close"]}>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment