title: How can I avoid auth and time issues using Paypal's Adaptive Payments API with Ruby?
body: <p>I'm running into multiple issues trying to access Paypal's Adaptive Payment API from Ruby.</p>
  
  <p>The main issue I ran into initially was that Paypal requires their HTTP headers to be in all caps but Net::HTTP does not preserve the case of HTTP headers (it stores them 'downcased' and then outputs them 'capitalized' -- so if you set the header 'X-PAYPAL-SECURITY-USERID' it is stored as 'x-paypal-security-userid' and output as 'X-Paypal-Security-Userid').</p>
  
  <p>I was getting "500000 Internal Server" errors when I tried to use the API with these mis-cased headers.</p>
  
  <p>So I monkeypatched Net::HTTP to preserve the case of the headers. But now I am getting timeout exceptions:</p>
  
  <pre><code>Timeout::Error (execution expired):
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/timeout.rb:60:in `rbuf_fill'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:132:in `rbuf_fill'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/protocol.rb:104:in `read_all'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:2220:in `read_body_0'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:2173:in `read_body'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:2198:in `body'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:2137:in `reading_body'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:1052:in `request'
  /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/net/http.rb:543:in `start'
  </code></pre>
  
  <p>So, back to my original question: Is anyone successfully accessing the adaptive payments API using Ruby? If so, what's your secret?</p>