summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2013-01-27 17:18:57 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2013-01-27 17:18:57 -0800
commit6d386076d8662e81c52b9c61f4f25132e5c380f5 (patch)
tree8af460538e05f506e72111beb114fa749be621c3 /src
parenta1dea3a8fed9581b85245421425849981e9d97c0 (diff)
downloadDotNetOpenAuth-6d386076d8662e81c52b9c61f4f25132e5c380f5.zip
DotNetOpenAuth-6d386076d8662e81c52b9c61f4f25132e5c380f5.tar.gz
DotNetOpenAuth-6d386076d8662e81c52b9c61f4f25132e5c380f5.tar.bz2
Finished fixing build breaks except in test projects.
Diffstat (limited to 'src')
-rw-r--r--src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs25
-rw-r--r--src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs5
-rw-r--r--src/DotNetOpenAuth.TestWeb/OpenIdProviderEndpoint.ashx58
-rw-r--r--src/DotNetOpenAuth.TestWeb/Web.config6
4 files changed, 56 insertions, 38 deletions
diff --git a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
index 947a971..eec7d1c 100644
--- a/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
+++ b/src/DotNetOpenAuth.Core/Messaging/MessagingUtilities.cs
@@ -1085,31 +1085,6 @@ namespace DotNetOpenAuth.Messaging {
}
/// <summary>
- /// Adds a set of HTTP headers to an <see cref="HttpResponse"/> instance,
- /// taking care to set some headers to the appropriate properties of
- /// <see cref="HttpResponse" />
- /// </summary>
- /// <param name="headers">The headers to add.</param>
- /// <param name="response">The <see cref="HttpListenerResponse"/> instance to set the appropriate values to.</param>
- internal static void ApplyHeadersToResponse(WebHeaderCollection headers, HttpListenerResponse response) {
- Requires.NotNull(headers, "headers");
- Requires.NotNull(response, "response");
-
- foreach (string headerName in headers) {
- switch (headerName) {
- case "Content-Type":
- response.ContentType = headers[HttpResponseHeader.ContentType];
- break;
-
- // Add more special cases here as necessary.
- default:
- response.AddHeader(headerName, headers[headerName]);
- break;
- }
- }
- }
-
- /// <summary>
/// Copies the contents of one stream to another.
/// </summary>
/// <param name="copyFrom">The stream to copy from, at the position where copying should begin.</param>
diff --git a/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs b/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs
index cf0f9ca..7bb6d5c 100644
--- a/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs
+++ b/src/DotNetOpenAuth.Test/Messaging/MessagingUtilitiesTests.cs
@@ -142,11 +142,6 @@ namespace DotNetOpenAuth.Test.Messaging {
}
[Test, ExpectedException(typeof(ArgumentNullException))]
- public void ApplyHeadersToResponseNullListenerResponse() {
- MessagingUtilities.ApplyHeadersToResponse(new WebHeaderCollection(), (HttpListenerResponse)null);
- }
-
- [Test, ExpectedException(typeof(ArgumentNullException))]
public void ApplyHeadersToResponseNullHeaders() {
MessagingUtilities.ApplyHeadersToResponse(null, new HttpResponseWrapper(new HttpResponse(new StringWriter())));
}
diff --git a/src/DotNetOpenAuth.TestWeb/OpenIdProviderEndpoint.ashx b/src/DotNetOpenAuth.TestWeb/OpenIdProviderEndpoint.ashx
index ca23eac..7225a01 100644
--- a/src/DotNetOpenAuth.TestWeb/OpenIdProviderEndpoint.ashx
+++ b/src/DotNetOpenAuth.TestWeb/OpenIdProviderEndpoint.ashx
@@ -1,23 +1,67 @@
<%@ WebHandler Language="C#" Class="OpenIdProviderEndpoint" %>
using System;
+using System.Threading;
+using System.Threading.Tasks;
using System.Web;
using DotNetOpenAuth.OpenId.Provider;
-public class OpenIdProviderEndpoint : IHttpHandler {
+using DotNetOpenAuth.Messaging;
+
+public class OpenIdProviderEndpoint : IHttpAsyncHandler {
+ public bool IsReusable {
+ get { return true; }
+ }
+
+ public IAsyncResult BeginProcessRequest(HttpContext context, System.AsyncCallback cb, object extraData) {
+ return ToApm(this.ProcessRequestAsync(context), cb, extraData);
+ }
+
+ public void EndProcessRequest(IAsyncResult result) {
+ ((Task)result).Wait(); // rethrows exceptions
+ }
+
public void ProcessRequest(HttpContext context) {
+ this.ProcessRequestAsync(context).GetAwaiter().GetResult();
+ }
+
+ private static Task ToApm(Task task, AsyncCallback callback, object state) {
+ if (task == null) {
+ throw new ArgumentNullException("task");
+ }
+
+ var tcs = new TaskCompletionSource<object>(state);
+ task.ContinueWith(
+ t => {
+ if (t.IsFaulted) {
+ tcs.TrySetException(t.Exception.InnerExceptions);
+ } else if (t.IsCanceled) {
+ tcs.TrySetCanceled();
+ } else {
+ tcs.TrySetResult(null);
+ }
+
+ if (callback != null) {
+ callback(tcs.Task);
+ }
+ },
+ CancellationToken.None,
+ TaskContinuationOptions.None,
+ TaskScheduler.Default);
+
+ return tcs.Task;
+ }
+
+ private async Task ProcessRequestAsync(HttpContext context) {
OpenIdProvider provider = new OpenIdProvider();
- IRequest request = provider.GetRequest();
+ IRequest request = await provider.GetRequestAsync(new HttpRequestWrapper(context.Request), context.Response.ClientDisconnectedToken);
if (request != null) {
if (!request.IsResponseReady) {
IAuthenticationRequest authRequest = (IAuthenticationRequest)request;
authRequest.IsAuthenticated = true;
}
- provider.Respond(request);
+ var response = await provider.PrepareResponseAsync(request, context.Response.ClientDisconnectedToken);
+ await response.SendAsync(new HttpResponseWrapper(context.Response), context.Response.ClientDisconnectedToken);
}
}
-
- public bool IsReusable {
- get { return true; }
- }
} \ No newline at end of file
diff --git a/src/DotNetOpenAuth.TestWeb/Web.config b/src/DotNetOpenAuth.TestWeb/Web.config
index 8c78f44..36968e4 100644
--- a/src/DotNetOpenAuth.TestWeb/Web.config
+++ b/src/DotNetOpenAuth.TestWeb/Web.config
@@ -25,7 +25,11 @@
affects performance, set this value to true only
during development.
-->
- <compilation debug="true" targetFramework="4.5"/>
+ <compilation debug="true" targetFramework="4.5">
+ <assemblies>
+ <add assembly="System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
+ </assemblies>
+ </compilation>
<!--
The <authentication> section enables configuration
of the security authentication mode used by