summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/OAuth2AuthorizationServerChannel.cs
diff options
context:
space:
mode:
Diffstat (limited to 'src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/OAuth2AuthorizationServerChannel.cs')
-rw-r--r--src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/OAuth2AuthorizationServerChannel.cs24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/OAuth2AuthorizationServerChannel.cs b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/OAuth2AuthorizationServerChannel.cs
index 249f5e7..609cedb 100644
--- a/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/OAuth2AuthorizationServerChannel.cs
+++ b/src/DotNetOpenAuth.OAuth2.AuthorizationServer/OAuth2/ChannelElements/OAuth2AuthorizationServerChannel.cs
@@ -7,7 +7,12 @@
namespace DotNetOpenAuth.OAuth2.ChannelElements {
using System;
using System.Collections.Generic;
+ using System.Net.Http;
+ using System.Net.Http.Headers;
using System.Net.Mime;
+ using System.Text;
+ using System.Threading;
+ using System.Threading.Tasks;
using System.Web;
using DotNetOpenAuth.Messaging;
using DotNetOpenAuth.OAuth2.AuthServer.Messages;
@@ -61,7 +66,7 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
/// The deserialized message parts, if found. Null otherwise.
/// </returns>
/// <exception cref="ProtocolException">Thrown when the response is not valid.</exception>
- protected override IDictionary<string, string> ReadFromResponseCore(IncomingWebResponse response) {
+ protected override Task<IDictionary<string, string>> ReadFromResponseCoreAsync(HttpResponseMessage response, CancellationToken cancellationToken) {
throw new NotImplementedException();
}
@@ -75,11 +80,11 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
/// <remarks>
/// This method implements spec OAuth V1.0 section 5.3.
/// </remarks>
- protected override OutgoingWebResponse PrepareDirectResponse(IProtocolMessage response) {
- var webResponse = new OutgoingWebResponse();
+ protected override HttpResponseMessage PrepareDirectResponse(IProtocolMessage response) {
+ var webResponse = new HttpResponseMessage();
ApplyMessageTemplate(response, webResponse);
string json = this.SerializeAsJson(response);
- webResponse.SetResponse(json, new ContentType(JsonEncoded));
+ webResponse.Content = new StringContent(json, Encoding.UTF8, JsonEncoded);
return webResponse;
}
@@ -87,12 +92,15 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
/// Gets the protocol message that may be embedded in the given HTTP request.
/// </summary>
/// <param name="request">The request to search for an embedded message.</param>
+ /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>
/// The deserialized message, if one is found. Null otherwise.
/// </returns>
- protected override IDirectedProtocolMessage ReadFromRequestCore(HttpRequestBase request) {
- if (!string.IsNullOrEmpty(request.Url.Fragment)) {
- var fields = HttpUtility.ParseQueryString(request.Url.Fragment.Substring(1)).ToDictionary();
+ protected override async Task<IDirectedProtocolMessage> ReadFromRequestCoreAsync(HttpRequestMessage request, CancellationToken cancellationToken) {
+ Requires.NotNull(request, "request");
+
+ if (!string.IsNullOrEmpty(request.RequestUri.Fragment)) {
+ var fields = HttpUtility.ParseQueryString(request.RequestUri.Fragment.Substring(1)).ToDictionary();
MessageReceivingEndpoint recipient;
try {
@@ -105,7 +113,7 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
return (IDirectedProtocolMessage)this.Receive(fields, recipient);
}
- return base.ReadFromRequestCore(request);
+ return await base.ReadFromRequestCoreAsync(request, cancellationToken);
}
/// <summary>