title: I'm accessing a secure site with httr but I get a server error whenever it isn't the first request
body: <p>As the title says the site in question is secure and I can't share my credentials but here's the outline of events.</p>
  
  <p>The way the site security works is you send a POST to one url with user/pass and then it sends back a token.  All requests then need to carry that token in their headers to work.  I can get that to work once.  On the first request after the login step I get the results I want.  All subsequent requests result in a http 500 error of "Internal Server Error".  Of course, in a perfect world, I could go to the server and get logs to see more verbosely what is going on.  However, they aren't so accommodating on my planet so I'm left scratching my head.</p>
  
  <p>Just to clarify I can send the exact same request the second time and I get the aforementioned error.  So far my work around is to <code>detach</code> <code>httr</code> and then re<code>library(httr)</code> to start over.  This doesn't seem like it's the best approach for this problem.</p>
  
  <p>I'm guessing that the problem has to do with how <code>httr</code> reuses the same handle but I don't know what info is changing between the two requests.</p>
  
  <p>In pseudo code let's say I do</p>
  
  <pre><code>resp&lt;-POST('https://my.site.com/login', add_headers(.headers=c('user'='me', 'pass'='blah'))
  mytoken&lt;-content(resp)$token
  qry&lt;-POST('https://my.site.com/soap/qry', add_headers(.headers=c('token'=mytoken)),body=myxmlstring)
  #qry will have status 200 and the content I expect
  #If I run the same POST command again
  qry2&lt;-POST('https://my.site.com/soap/qry', add_headers(.headers=c('token'=mytoken)),body=myxmlstring) 
  #qry2 will be status code 500
  #if I do
  detach("package:httr", unload=TRUE)
  library(httr)
  #and then do the commands again from the top then it will work again.
  </code></pre>
  
  <p>Ideally, there'd be a parameter I can add to POST which will make each POST completely independent of the last.  Short of that I'd be happy with something that makes more sense than detaching and reattaching the package itself.</p>