summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ResourceServerChannel.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2012-02-16 08:59:44 -0800
committerAndrew Arnott <andrewarnott@gmail.com>2012-02-16 08:59:44 -0800
commit4ae2b7675f436906c19c91e3d9605eae247d37f1 (patch)
tree8d576cba7d20d9a4a1764735bfca487ab68e70d6 /src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ResourceServerChannel.cs
parent9869f80aa333eeab6e7d19bf116c3d4c4788e8ba (diff)
downloadDotNetOpenAuth-4ae2b7675f436906c19c91e3d9605eae247d37f1.zip
DotNetOpenAuth-4ae2b7675f436906c19c91e3d9605eae247d37f1.tar.gz
DotNetOpenAuth-4ae2b7675f436906c19c91e3d9605eae247d37f1.tar.bz2
Avoid a NullReferenceException is an OAuth 2 resource server's direct response message doesn't implement IHttpDirectResponse.
Diffstat (limited to 'src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ResourceServerChannel.cs')
-rw-r--r--src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ResourceServerChannel.cs10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ResourceServerChannel.cs b/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ResourceServerChannel.cs
index cc61d47..7ea6542 100644
--- a/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ResourceServerChannel.cs
+++ b/src/DotNetOpenAuth.OAuth2/OAuth2/ChannelElements/OAuth2ResourceServerChannel.cs
@@ -107,9 +107,13 @@ namespace DotNetOpenAuth.OAuth2.ChannelElements {
// First initialize based on the specifics within the message.
var httpResponse = response as IHttpDirectResponse;
- webResponse.Status = httpResponse != null ? httpResponse.HttpStatusCode : HttpStatusCode.Unauthorized;
- foreach (string headerName in httpResponse.Headers) {
- webResponse.Headers.Add(headerName, httpResponse.Headers[headerName]);
+ if (httpResponse != null) {
+ webResponse.Status = httpResponse.HttpStatusCode;
+ foreach (string headerName in httpResponse.Headers) {
+ webResponse.Headers.Add(headerName, httpResponse.Headers[headerName]);
+ }
+ } else {
+ webResponse.Status = HttpStatusCode.Unauthorized;
}
// Now serialize all the message parts into the WWW-Authenticate header.