title: RestSharp Redirection and Authentication 401
body: <p>I am trying to make a REST request to a Neo4j instance hosted via heroku. The server is setup with Basic Authentication.</p>
  
  <p>This is the url I was provided with from Heroku (<strong>notice the trailing slash</strong>): <a href="http://username:password@instance.hosted.neo4j.org:123/db/data" rel="nofollow">http://username:password@instance.hosted.neo4j.org:123/db/data</a><strong>/</strong></p>
  
  <p>I'm using RestSharp to connect to this instance. However, RestSharp will remove the trailing slash. <a href="https://github.com/restsharp/RestSharp/blob/master/RestSharp/RestClient.cs#L271" rel="nofollow">Code</a>. The resulting url becomes: <a href="http://username:password@instance.hosted.neo4j.org:123/db/data" rel="nofollow">http://username:password@instance.hosted.neo4j.org:123/db/data</a></p>
  
  <p>This results in a <code>HTTP 301</code> to (<strong>notice the trailing slash</strong>): <a href="http://username:password@instance.hosted.neo4j.org:123/db/data/" rel="nofollow">http://username:password@instance.hosted.neo4j.org:123/db/data/</a></p>
  
  <p>The problem is that the Authorization Header is not persisted across redirects <a href="http://msdn.microsoft.com/en-us/library/system.net.httpwebrequest.allowautoredirect.aspx" rel="nofollow">MSDN</a>. This redirect results in <code>HTTP 401</code>.</p>
  
  <p>Are there any obvious ways around this? I've tried the following:</p>
  
  <ul>
  <li>Provide 2 trailing slashes <code>/db/data//</code> so RestSharp only removed one slash but leaves one remaining. This doesn't work as other requests have invalid formats: <code>/db/data//query/stuff</code></li>
  <li>Use <code>CredentialCache</code> class. This works but results in 2 requests per action (One for the 401 challenge, another one for the response)</li>
  <li><code>IAuthenticationModlue</code> - Found minimal info on this in MSDN but after trying a custom class, this will still result in the double hop issue noted previously.</li>
  <li><s>Change the initial rest request to be <code>new RestRequest("/", Method.GET);</code> instead of <code>new RestRequest("", Method.GET);</code> - the only probelm is I don't want to modify the Open Source project that is in between my app and RestSharp for my specific needs.</s> RestSharp removes all ending slashes</li>
  </ul>