diff options
author | Andrew Arnott <andrewarnott@gmail.com> | 2008-09-27 07:40:58 -0700 |
---|---|---|
committer | Andrew <andrewarnott@gmail.com> | 2008-09-27 07:40:58 -0700 |
commit | faa8a59cf77470e092ce9c2fe99f9ed7432567b3 (patch) | |
tree | 272e2d32d34c3b83829df0452241a68435a29d59 /src/DotNetOAuth/Messaging/MessagingUtilities.cs | |
parent | d5e2339b50047e961a661f03d882dd555c45fd74 (diff) | |
download | DotNetOpenAuth-faa8a59cf77470e092ce9c2fe99f9ed7432567b3.zip DotNetOpenAuth-faa8a59cf77470e092ce9c2fe99f9ed7432567b3.tar.gz DotNetOpenAuth-faa8a59cf77470e092ce9c2fe99f9ed7432567b3.tar.bz2 |
Added final protected resource request to Appendix scenario test.
Diffstat (limited to 'src/DotNetOAuth/Messaging/MessagingUtilities.cs')
-rw-r--r-- | src/DotNetOAuth/Messaging/MessagingUtilities.cs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/DotNetOAuth/Messaging/MessagingUtilities.cs b/src/DotNetOAuth/Messaging/MessagingUtilities.cs index 7c95696..88aea0c 100644 --- a/src/DotNetOAuth/Messaging/MessagingUtilities.cs +++ b/src/DotNetOAuth/Messaging/MessagingUtilities.cs @@ -8,6 +8,7 @@ namespace DotNetOAuth.Messaging { using System;
using System.Collections.Generic;
using System.Collections.Specialized;
+ using System.IO;
using System.Linq;
using System.Net;
using System.Text;
@@ -46,6 +47,36 @@ namespace DotNetOAuth.Messaging { }
/// <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>
+ /// <param name="copyTo">The stream to copy to, at the position where bytes should be written.</param>
+ /// <remarks>
+ /// Copying begins at the streams' current positions.
+ /// The positions are NOT reset after copying is complete.
+ /// </remarks>
+ internal static void CopyTo(this Stream copyFrom, Stream copyTo) {
+ if (copyFrom == null) {
+ throw new ArgumentNullException("copyFrom");
+ }
+ if (copyTo == null) {
+ throw new ArgumentNullException("copyTo");
+ }
+ if (!copyFrom.CanRead) {
+ throw new ArgumentException(MessagingStrings.StreamUnreadable, "copyFrom");
+ }
+ if (!copyTo.CanWrite) {
+ throw new ArgumentException(MessagingStrings.StreamUnwritable, "copyTo");
+ }
+
+ byte[] buffer = new byte[1024];
+ int readBytes;
+ while ((readBytes = copyFrom.Read(buffer, 0, 1024)) > 0) {
+ copyTo.Write(buffer, 0, readBytes);
+ }
+ }
+
+ /// <summary>
/// Concatenates a list of name-value pairs as key=value&key=value,
/// taking care to properly encode each key and value for URL
/// transmission. No ? is prefixed to the string.
|