Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

previous fix didn't work, perhaps this one will.

  • Loading branch information...
commit de0c711abfda666d6bea28fd5316c52a7d20f5e8 1 parent b182167
Owen Evans authored
Showing with 33 additions and 33 deletions.
  1. +33 −33 Core/OAuth.Web/OAuthTokenResponse.cs
66 Core/OAuth.Web/OAuthTokenResponse.cs
View
@@ -1,47 +1,47 @@
-using System;
+using System.Collections.Specialized;
using System.IO;
using System.Net;
namespace OAuth.Web
{
- public class OAuthTokenResponse
- {
- public OAuthTokenResponse(WebResponse httpWebResponse)
+ public class OAuthTokenResponse
{
- string tokenString;
- using(var stream = httpWebResponse.GetResponseStream())
+ public OAuthTokenResponse(WebResponse httpWebResponse)
{
- var reader = new StreamReader(stream);
- tokenString = reader.ReadToEnd();
- reader.Close();
- }
- if(!string.IsNullOrEmpty(tokenString))
- {
- var parts = tokenString.Split('&');
- if(parts.Length>2)
- {
- var token = new OAuthToken();
- foreach(var part in parts)
+ using (var stream = httpWebResponse.GetResponseStream())
+ {
+ var reader = new StreamReader(stream);
+ ResponseBody = reader.ReadToEnd();
+ reader.Close();
+ }
+
+ if (string.IsNullOrEmpty(ResponseBody))
+ {
+ return;
+ }
+
+ Items = new NameValueCollection();
+
+ foreach (string item in ResponseBody.Split('&'))
{
- var tokenparts = part.Split('=');
- if(tokenparts.Length==2)
+ if (item.IndexOf('=') > -1)
{
- if(tokenparts[0].Equals("oauth_token",StringComparison.OrdinalIgnoreCase))
- {
- token.Token = tokenparts[1];
- }
- else if (tokenparts[0].Equals("oauth_token_secret", StringComparison.OrdinalIgnoreCase))
- {
- token.TokenSecret = tokenparts[1];
- }
+ string[] temp = item.Split('=');
+ Items.Add(temp[0], temp[1]);
+ }
+ else
+ {
+ Items.Add(item, string.Empty);
}
-
}
-
+
+ Token = new OAuthToken() { Token = Items["oauth_token"], TokenSecret = Items["oauth_token_secret"] };
}
- }
- }
- public OAuthToken Token { get; set; }
- }
+ public string ResponseBody { get; private set; }
+
+ public NameValueCollection Items { get; private set; }
+
+ public OAuthToken Token { get; private set; }
+ }
}
Please sign in to comment.
Something went wrong with that request. Please try again.