bittercoder/DevDefined.OAuth — pull request #18 by RaymondST (2011-11-15 00:07:15+00:00)
Title: Set timeout and long data string

Was getting WebExceptions due to timeouts when submitting large api requests to Xero and could not find any way to set the Timeout property on the HttpWebRequest so I added it and a extension method to set it.

It looks like you started using Uri.EscapeDataString since the last release (or at least the binary we were using) which throws exceptions for strings longer than 32766 (http://msdn.microsoft.com/en-us/library/system.uri.escapedatastring.aspx).

I tried to fix it by using HttpUtility.UrlEncode and fixing up the 3 differences (if compared without case, it uses + instead of %20, and hex encodes ' and ~, and uses lower case hex encoding instead of upper case).
The lower case hex encoding seems to upset Xero (get an OAuthException "Failed to validate signature" based off a WebException of 401).

I fixed it by splitting up the input string and passing the chunks to Uri.EscapeDataString instead as it does not change the behaviour of the current code but does allow it to handle large strings.

We use large strings so that we can save on Xero api calls so I would assume other people may also run into this problem.