summaryrefslogtreecommitdiffstats
path: root/src/DotNetOAuth/OAuth/ChannelElements/StandardWebRequestHandler.cs
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2008-11-03 17:22:00 -0800
committerAndrew <andrewarnott@gmail.com>2008-11-04 08:12:52 -0800
commit462e19abd9034c11a12cad30e9899740f2bef8ff (patch)
treee08667f1d69249f8daa6c348a919bd0fd5434415 /src/DotNetOAuth/OAuth/ChannelElements/StandardWebRequestHandler.cs
parent6a79be0eca3929d8fb4e797799dac8d6f7875475 (diff)
downloadDotNetOpenAuth-462e19abd9034c11a12cad30e9899740f2bef8ff.zip
DotNetOpenAuth-462e19abd9034c11a12cad30e9899740f2bef8ff.tar.gz
DotNetOpenAuth-462e19abd9034c11a12cad30e9899740f2bef8ff.tar.bz2
Changed namepace and project names in preparation for merge with DotNetOpenId.
Diffstat (limited to 'src/DotNetOAuth/OAuth/ChannelElements/StandardWebRequestHandler.cs')
-rw-r--r--src/DotNetOAuth/OAuth/ChannelElements/StandardWebRequestHandler.cs70
1 files changed, 0 insertions, 70 deletions
diff --git a/src/DotNetOAuth/OAuth/ChannelElements/StandardWebRequestHandler.cs b/src/DotNetOAuth/OAuth/ChannelElements/StandardWebRequestHandler.cs
deleted file mode 100644
index 12fcd28..0000000
--- a/src/DotNetOAuth/OAuth/ChannelElements/StandardWebRequestHandler.cs
+++ /dev/null
@@ -1,70 +0,0 @@
-//-----------------------------------------------------------------------
-// <copyright file="StandardWebRequestHandler.cs" company="Andrew Arnott">
-// Copyright (c) Andrew Arnott. All rights reserved.
-// </copyright>
-//-----------------------------------------------------------------------
-
-namespace DotNetOAuth.OAuth.ChannelElements {
- using System;
- using System.IO;
- using System.Net;
- using DotNetOAuth.Messaging;
-
- /// <summary>
- /// The default handler for transmitting <see cref="HttpWebRequest"/> instances
- /// and returning the responses.
- /// </summary>
- internal class StandardWebRequestHandler : IWebRequestHandler {
- #region IWebRequestHandler Members
-
- /// <summary>
- /// Prepares a POST <see cref="HttpWebRequest"/> and returns the request stream
- /// for writing out the POST entity data.
- /// </summary>
- /// <param name="request">The <see cref="HttpWebRequest"/> that should contain the entity.</param>
- /// <returns>The stream the caller should write out the entity data to.</returns>
- public TextWriter GetRequestStream(HttpWebRequest request) {
- if (request == null) {
- throw new ArgumentNullException("request");
- }
-
- try {
- return new StreamWriter(request.GetRequestStream());
- } catch (WebException ex) {
- throw new ProtocolException(MessagingStrings.ErrorInRequestReplyMessage, ex);
- }
- }
-
- /// <summary>
- /// Processes an <see cref="HttpWebRequest"/> and converts the
- /// <see cref="HttpWebResponse"/> to a <see cref="Response"/> instance.
- /// </summary>
- /// <param name="request">The <see cref="HttpWebRequest"/> to handle.</param>
- /// <returns>An instance of <see cref="Response"/> describing the response.</returns>
- public Response GetResponse(HttpWebRequest request) {
- if (request == null) {
- throw new ArgumentNullException("request");
- }
-
- try {
- Logger.DebugFormat("HTTP {0} {1}", request.Method, request.RequestUri);
- using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) {
- return new Response(response);
- }
- } catch (WebException ex) {
- if (Logger.IsErrorEnabled) {
- if (ex.Response != null) {
- using (var reader = new StreamReader(ex.Response.GetResponseStream())) {
- Logger.ErrorFormat("WebException from {0}: {1}", ex.Response.ResponseUri, reader.ReadToEnd());
- }
- } else {
- Logger.ErrorFormat("WebException {1} from {0}, no response available.", request.RequestUri, ex.Status);
- }
- }
- throw new ProtocolException(MessagingStrings.ErrorInRequestReplyMessage, ex);
- }
- }
-
- #endregion
- }
-}