diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-26 11:19:06 -0700 |
---|---|---|
committer | Andrew Arnott <andrewarnott@gmail.com> | 2013-03-26 11:19:06 -0700 |
commit | 3d37ff45cab6838d80b22e6b782a0b9b4c2f4aeb (patch) | |
tree | c15816c3d7f6e74334553f2ff98605ce1c22c538 /src/DotNetOpenAuth.Test/Mocks/CoordinatingHttpRequestInfo.cs | |
parent | 5e9014f36b2d53b8e419918675df636540ea24e2 (diff) | |
parent | e6f7409f4caceb7bc2a5b4ddbcb1a4097af340f2 (diff) | |
download | DotNetOpenAuth-3d37ff45cab6838d80b22e6b782a0b9b4c2f4aeb.zip DotNetOpenAuth-3d37ff45cab6838d80b22e6b782a0b9b4c2f4aeb.tar.gz DotNetOpenAuth-3d37ff45cab6838d80b22e6b782a0b9b4c2f4aeb.tar.bz2 |
Move to HttpClient throughout library.
Diffstat (limited to 'src/DotNetOpenAuth.Test/Mocks/CoordinatingHttpRequestInfo.cs')
-rw-r--r-- | src/DotNetOpenAuth.Test/Mocks/CoordinatingHttpRequestInfo.cs | 109 |
1 files changed, 0 insertions, 109 deletions
diff --git a/src/DotNetOpenAuth.Test/Mocks/CoordinatingHttpRequestInfo.cs b/src/DotNetOpenAuth.Test/Mocks/CoordinatingHttpRequestInfo.cs deleted file mode 100644 index 497503c..0000000 --- a/src/DotNetOpenAuth.Test/Mocks/CoordinatingHttpRequestInfo.cs +++ /dev/null @@ -1,109 +0,0 @@ -//----------------------------------------------------------------------- -// <copyright file="CoordinatingHttpRequestInfo.cs" company="Outercurve Foundation"> -// Copyright (c) Outercurve Foundation. All rights reserved. -// </copyright> -//----------------------------------------------------------------------- - -namespace DotNetOpenAuth.Test.Mocks { - using System; - using System.Collections.Generic; - using System.Net; - using System.Web; - - using DotNetOpenAuth.Messaging; - using Validation; - - internal class CoordinatingHttpRequestInfo : HttpRequestInfo { - private readonly Channel channel; - - private readonly IDictionary<string, string> messageData; - - private readonly IMessageFactory messageFactory; - - private readonly MessageReceivingEndpoint recipient; - - private IDirectedProtocolMessage message; - - /// <summary> - /// Initializes a new instance of the <see cref="CoordinatingHttpRequestInfo"/> class - /// that will generate a message when the <see cref="Message"/> property getter is called. - /// </summary> - /// <param name="channel">The channel.</param> - /// <param name="messageFactory">The message factory.</param> - /// <param name="messageData">The message data.</param> - /// <param name="recipient">The recipient.</param> - /// <param name="cookies">Cookies included in the incoming request.</param> - internal CoordinatingHttpRequestInfo( - Channel channel, - IMessageFactory messageFactory, - IDictionary<string, string> messageData, - MessageReceivingEndpoint recipient, - HttpCookieCollection cookies) - : this(recipient, cookies) { - Requires.NotNull(channel, "channel"); - Requires.NotNull(messageFactory, "messageFactory"); - Requires.NotNull(messageData, "messageData"); - this.channel = channel; - this.messageData = messageData; - this.messageFactory = messageFactory; - } - - /// <summary> - /// Initializes a new instance of the <see cref="CoordinatingHttpRequestInfo"/> class - /// that will not generate any message. - /// </summary> - /// <param name="recipient">The recipient.</param> - /// <param name="cookies">Cookies included in the incoming request.</param> - internal CoordinatingHttpRequestInfo(MessageReceivingEndpoint recipient, HttpCookieCollection cookies) - : base(GetHttpVerb(recipient), recipient != null ? recipient.Location : new Uri("http://host/path"), cookies: cookies) { - this.recipient = recipient; - } - - /// <summary> - /// Initializes a new instance of the <see cref="CoordinatingHttpRequestInfo"/> class. - /// </summary> - /// <param name="message">The message being passed in through a mock transport. May be null.</param> - /// <param name="httpMethod">The HTTP method that the incoming request came in on, whether or not <paramref name="message"/> is null.</param> - internal CoordinatingHttpRequestInfo(IDirectedProtocolMessage message, HttpDeliveryMethods httpMethod) - : base(GetHttpVerb(httpMethod), message.Recipient) { - this.message = message; - } - - /// <summary> - /// Gets the message deserialized from the remote channel. - /// </summary> - internal IDirectedProtocolMessage Message { - get { - if (this.message == null && this.messageData != null) { - var message = this.messageFactory.GetNewRequestMessage(this.recipient, this.messageData); - if (message != null) { - this.channel.MessageDescriptions.GetAccessor(message).Deserialize(this.messageData); - this.message = message; - } - } - - return this.message; - } - } - - private static string GetHttpVerb(MessageReceivingEndpoint recipient) { - if (recipient == null) { - return "GET"; - } - - return GetHttpVerb(recipient.AllowedMethods); - } - - private static string GetHttpVerb(HttpDeliveryMethods httpMethod) { - if ((httpMethod & HttpDeliveryMethods.GetRequest) != 0) { - return "GET"; - } - - if ((httpMethod & HttpDeliveryMethods.PostRequest) != 0) { - return "POST"; - } - - throw new ArgumentOutOfRangeException(); - } - } -} |