Revision 72174cd5 trunk/Pithos.Network/CloudFilesClient.cs
b/trunk/Pithos.Network/CloudFilesClient.cs | ||
---|---|---|
1035 | 1035 |
client.Headers[HttpRequestHeader.ContentType] = "application/octet-stream"; |
1036 | 1036 |
var jsonHash = hash.ToJson(); |
1037 | 1037 |
var uploadTask=client.UploadStringTask(uri, "PUT", jsonHash); |
1038 |
|
|
1038 |
if (Log.IsDebugEnabled) |
|
1039 |
Log.DebugFormat("Hashes:\r\n{0}", jsonHash); |
|
1039 | 1040 |
return uploadTask.ContinueWith(t => |
1040 | 1041 |
{ |
1041 | 1042 |
|
... | ... | |
1059 | 1060 |
{ |
1060 | 1061 |
//In case of 409 the missing parts will be in the response content |
1061 | 1062 |
using (var stream = response.GetResponseStream()) |
1062 |
using(var reader=new StreamReader(stream))
|
|
1063 |
using(var reader=stream.GetLoggedReader(Log))
|
|
1063 | 1064 |
{ |
1064 |
Debug.Assert(stream.Position == 0); |
|
1065 | 1065 |
//We used to have to cleanup the content before returning it because it contains |
1066 | 1066 |
//error content after the list of hashes |
1067 | 1067 |
// |
... | ... | |
1070 | 1070 |
|
1071 | 1071 |
var serializer = new JsonSerializer(); |
1072 | 1072 |
serializer.Error += (sender, args) => Log.ErrorFormat("Deserialization error at [{0}] [{1}]", args.ErrorContext.Error, args.ErrorContext.Member); |
1073 |
if (Log.IsDebugEnabled) |
|
1074 |
{ |
|
1075 |
var body=reader.ReadToEnd(); |
|
1076 |
Log.DebugFormat("JSON response: {0}",body); |
|
1077 |
using (var strReader = new StringReader(body)) |
|
1078 |
{ |
|
1079 |
var hashes = (List<string>)serializer.Deserialize(strReader, typeof(List<string>)); |
|
1080 |
return hashes; |
|
1081 |
} |
|
1082 |
} |
|
1083 |
else |
|
1084 |
{ |
|
1085 |
var hashes = (List<string>)serializer.Deserialize(reader, typeof(List<string>)); |
|
1086 |
return hashes; |
|
1087 |
} |
|
1073 |
var hashes = (List<string>)serializer.Deserialize(reader, typeof(List<string>)); |
|
1074 |
return hashes; |
|
1088 | 1075 |
} |
1089 | 1076 |
} |
1090 | 1077 |
//Any other status code is unexpected and the exception should be rethrown |
1078 |
Log.LogError(response); |
|
1091 | 1079 |
throw ex; |
1092 | 1080 |
|
1093 | 1081 |
} |
... | ... | |
1099 | 1087 |
|
1100 | 1088 |
} |
1101 | 1089 |
|
1090 |
|
|
1102 | 1091 |
public Task<byte[]> GetBlock(string account, string container, Uri relativeUrl, long start, long? end) |
1103 | 1092 |
{ |
1104 | 1093 |
if (String.IsNullOrWhiteSpace(Token)) |
Also available in: Unified diff