Revision cd7c162f trunk/Pithos.Network/CloudFilesClient.cs
b/trunk/Pithos.Network/CloudFilesClient.cs | ||
---|---|---|
58 | 58 |
UserName = userName; |
59 | 59 |
ApiKey = apiKey; |
60 | 60 |
|
61 |
if (UsePithos) |
|
62 |
{ |
|
63 |
Token = ApiKey; |
|
64 |
string storageUrl = String.Format("{0}/{1}/{2}", AuthenticationUrl, VersionPath, UserName); |
|
65 |
StorageUrl = new Uri(storageUrl); |
|
66 |
} |
|
67 |
else |
|
68 |
{ |
|
69 | 61 |
|
70 |
string authUrl = String.Format("{0}/{1}", AuthenticationUrl, VersionPath);
|
|
71 |
var authClient = new PithosClient{BaseAddress= authUrl};
|
|
62 |
using (var authClient = new PithosClient{BaseAddress=AuthenticationUrl})
|
|
63 |
{
|
|
72 | 64 |
if (Proxy != null) |
73 | 65 |
authClient.Proxy = new WebProxy(Proxy); |
74 | 66 |
|
75 | 67 |
authClient.Headers.Add("X-Auth-User", UserName); |
76 | 68 |
authClient.Headers.Add("X-Auth-Key", ApiKey); |
77 | 69 |
|
78 |
var response = authClient.DownloadStringWithRetry("",3);
|
|
70 |
authClient.DownloadStringWithRetry(VersionPath, 3);
|
|
79 | 71 |
|
80 | 72 |
authClient.AssertStatusOK("Authentication failed"); |
81 | 73 |
|
82 |
string storageUrl = authClient.GetHeaderValue("X-Storage-Url");
|
|
74 |
var storageUrl = authClient.GetHeaderValue("X-Storage-Url");
|
|
83 | 75 |
if (String.IsNullOrWhiteSpace(storageUrl)) |
84 | 76 |
throw new InvalidOperationException("Failed to obtain storage url"); |
85 | 77 |
StorageUrl = new Uri(storageUrl); |
86 |
|
|
78 |
UriBuilder b; |
|
79 |
b.Scheme; |
|
87 | 80 |
var token = authClient.GetHeaderValue("X-Auth-Token"); |
88 | 81 |
if (String.IsNullOrWhiteSpace(token)) |
89 | 82 |
throw new InvalidOperationException("Failed to obtain token url"); |
Also available in: Unified diff