summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-01-26 07:55:50 -0800
committerAndrew <andrewarnott@gmail.com>2009-01-26 16:51:36 -0800
commitb8c94f9de8f2eb93629cef20e546dfa4a9e06611 (patch)
tree5cb84332f874f6dbe72da15f67bc4762f5136748 /src
parent7903b1475d8872d6e884d7ad3be0e64f3e9c4c21 (diff)
downloadDotNetOpenAuth-b8c94f9de8f2eb93629cef20e546dfa4a9e06611.zip
DotNetOpenAuth-b8c94f9de8f2eb93629cef20e546dfa4a9e06611.tar.gz
DotNetOpenAuth-b8c94f9de8f2eb93629cef20e546dfa4a9e06611.tar.bz2
Added HTTP cache control to Channel, with a default to ignore cache for direct requests.
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth/Messaging/Channel.cs22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/DotNetOpenAuth/Messaging/Channel.cs b/src/DotNetOpenAuth/Messaging/Channel.cs
index 4c07f80..e70e5d6 100644
--- a/src/DotNetOpenAuth/Messaging/Channel.cs
+++ b/src/DotNetOpenAuth/Messaging/Channel.cs
@@ -14,6 +14,7 @@ namespace DotNetOpenAuth.Messaging {
using System.IO;
using System.Linq;
using System.Net;
+ using System.Net.Cache;
using System.Text;
using System.Threading;
using System.Web;
@@ -73,6 +74,11 @@ namespace DotNetOpenAuth.Messaging {
private List<IChannelBindingElement> incomingBindingElements = new List<IChannelBindingElement>();
/// <summary>
+ /// Backing store for the <see cref="CachePolicy"/> property.
+ /// </summary>
+ private RequestCachePolicy cachePolicy = new HttpRequestCachePolicy(HttpRequestCacheLevel.NoCacheNoStore);
+
+ /// <summary>
/// Initializes a new instance of the <see cref="Channel"/> class.
/// </summary>
/// <param name="messageTypeProvider">
@@ -139,6 +145,21 @@ namespace DotNetOpenAuth.Messaging {
}
/// <summary>
+ /// Gets or sets the cache policy to use for direct message requests.
+ /// </summary>
+ /// <value>Default is <see cref="HttpRequestCacheLevel.NoCacheNoStore"/>.</value>
+ protected RequestCachePolicy CachePolicy {
+ get {
+ return this.cachePolicy;
+ }
+
+ set {
+ ErrorUtilities.VerifyArgumentNotNull(value, "value");
+ this.cachePolicy = value;
+ }
+ }
+
+ /// <summary>
/// Sends an indirect message (either a request or response)
/// or direct message response for transmission to a remote party
/// and ends execution on the current page or handler.
@@ -645,6 +666,7 @@ namespace DotNetOpenAuth.Messaging {
var fields = serializer.Serialize(requestMessage);
HttpWebRequest httpRequest = (HttpWebRequest)WebRequest.Create(requestMessage.Recipient);
+ httpRequest.CachePolicy = this.CachePolicy;
httpRequest.Method = "POST";
httpRequest.ContentType = "application/x-www-form-urlencoded";
httpRequest.Headers[HttpRequestHeader.ContentEncoding] = PostEntityEncoding.WebName;