summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Core/Messaging/Channel.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2013-03-23 14:07:08 -0700
committerAndrew Arnott <andrewarnott@gmail.com>2013-03-23 14:07:08 -0700
commit28ecaad3e965105c0f32d43760f2f855504d2212 (patch)
tree95da7893f611fd8db25b40ef4173828ddb9b6b43 /src/DotNetOpenAuth.Core/Messaging/Channel.cs
parentbaef63e68ff40462a8be63b6fcb7ad6265b247b6 (diff)
downloadDotNetOpenAuth-28ecaad3e965105c0f32d43760f2f855504d2212.zip
DotNetOpenAuth-28ecaad3e965105c0f32d43760f2f855504d2212.tar.gz
DotNetOpenAuth-28ecaad3e965105c0f32d43760f2f855504d2212.tar.bz2
Fixes several more unit tests. 55 left
Diffstat (limited to 'src/DotNetOpenAuth.Core/Messaging/Channel.cs')
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/Channel.cs45
1 files changed, 14 insertions, 31 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/Channel.cs b/src/DotNetOpenAuth.Core/Messaging/Channel.cs
index 25ad84b..b65e2e3 100644
--- a/src/DotNetOpenAuth.Core/Messaging/Channel.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/Channel.cs
@@ -685,34 +685,29 @@ namespace DotNetOpenAuth.Messaging {
try {
using (var httpClient = this.HostFactories.CreateHttpClient()) {
using (var response = await httpClient.SendAsync(webRequest, cancellationToken)) {
- if (response.IsSuccessStatusCode) {
- if (response.Content == null) {
- return null;
- }
-
+ if (response.Content != null) {
var responseFields = await this.ReadFromResponseCoreAsync(response, cancellationToken);
- if (responseFields == null) {
- return null;
- }
+ if (responseFields != null) {
+ var responseMessage = this.MessageFactory.GetNewResponseMessage(request, responseFields);
+ if (responseMessage != null) {
+ this.OnReceivingDirectResponse(response, responseMessage);
- var responseMessage = this.MessageFactory.GetNewResponseMessage(request, responseFields);
- if (responseMessage == null) {
- return null;
- }
-
- this.OnReceivingDirectResponse(response, responseMessage);
+ var messageAccessor = this.MessageDescriptions.GetAccessor(responseMessage);
+ messageAccessor.Deserialize(responseFields);
- var messageAccessor = this.MessageDescriptions.GetAccessor(responseMessage);
- messageAccessor.Deserialize(responseFields);
+ return responseMessage;
+ }
+ }
+ }
- return responseMessage;
- } else {
+ if (!response.IsSuccessStatusCode) {
var errorContent = (response.Content != null) ? await response.Content.ReadAsStringAsync() : null;
Logger.Http.ErrorFormat(
"Error received in HTTP response: {0} {1}\n{2}", (int)response.StatusCode, response.ReasonPhrase, errorContent);
response.EnsureSuccessStatusCode(); // throw so we can wrap it in our catch block.
- throw Assumes.NotReachable();
}
+
+ return null;
}
}
} catch (HttpRequestException requestException) {
@@ -1339,18 +1334,6 @@ namespace DotNetOpenAuth.Messaging {
return -((int)protection1).CompareTo((int)protection2); // descending flag ordinal order
}
-#if CONTRACTS_FULL
- /// <summary>
- /// Verifies conditions that should be true for any valid state of this object.
- /// </summary>
- [SuppressMessage("Microsoft.Performance", "CA1822:MarkMembersAsStatic", Justification = "Called by code contracts.")]
- [SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode", Justification = "Called by code contracts.")]
- [ContractInvariantMethod]
- private void ObjectInvariant() {
- Contract.Invariant(this.MessageDescriptions != null);
- }
-#endif
-
/// <summary>
/// Verifies that all required message parts are initialized to values
/// prior to sending the message to a remote party.