summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Test
diff options
context:
space:
mode:
authorAndrew Arnott <andrewarnott@gmail.com>2009-01-12 08:44:53 -0800
committerAndrew <andrewarnott@gmail.com>2009-01-12 08:44:53 -0800
commit5a8a7e76d9f8d57e295c83905a2e5c5ef2348077 (patch)
treeb72dcc4aa93c824a8ca2101b04b9ec1f90016e63 /src/DotNetOpenAuth.Test
parent8b3de8d84b982547f634643b243fd92746d2b980 (diff)
downloadDotNetOpenAuth-5a8a7e76d9f8d57e295c83905a2e5c5ef2348077.zip
DotNetOpenAuth-5a8a7e76d9f8d57e295c83905a2e5c5ef2348077.tar.gz
DotNetOpenAuth-5a8a7e76d9f8d57e295c83905a2e5c5ef2348077.tar.bz2
Fixed the channel's POST entity writing.
The HTTP Content-Length was being set to the number of characters in the response instead of the number of bytes.
Diffstat (limited to 'src/DotNetOpenAuth.Test')
-rw-r--r--src/DotNetOpenAuth.Test/Mocks/TestWebRequestHandler.cs26
1 files changed, 19 insertions, 7 deletions
diff --git a/src/DotNetOpenAuth.Test/Mocks/TestWebRequestHandler.cs b/src/DotNetOpenAuth.Test/Mocks/TestWebRequestHandler.cs
index e655238..88777b7 100644
--- a/src/DotNetOpenAuth.Test/Mocks/TestWebRequestHandler.cs
+++ b/src/DotNetOpenAuth.Test/Mocks/TestWebRequestHandler.cs
@@ -13,7 +13,7 @@ namespace DotNetOpenAuth.Test.Mocks {
using DotNetOpenAuth.OAuth.ChannelElements;
internal class TestWebRequestHandler : IDirectSslWebRequestHandler {
- private StringBuilder postEntity;
+ private Stream postEntity;
/// <summary>
/// Gets or sets the callback used to provide the mock response for the mock request.
@@ -28,7 +28,14 @@ namespace DotNetOpenAuth.Test.Mocks {
if (this.postEntity == null) {
return null;
}
- return new MemoryStream(Encoding.UTF8.GetBytes(this.postEntity.ToString()));
+
+ Stream result = new MemoryStream();
+ long originalPosition = this.postEntity.Position;
+ this.postEntity.Position = 0;
+ this.postEntity.CopyTo(result);
+ this.postEntity.Position = originalPosition;
+ result.Position = 0;
+ return result;
}
}
@@ -37,7 +44,12 @@ namespace DotNetOpenAuth.Test.Mocks {
/// </summary>
internal string RequestEntityAsString {
get {
- return this.postEntity != null ? this.postEntity.ToString() : null;
+ if (this.postEntity == null) {
+ return null;
+ }
+
+ StreamReader reader = new StreamReader(this.RequestEntityStream);
+ return reader.ReadToEnd();
}
}
@@ -50,9 +62,9 @@ namespace DotNetOpenAuth.Test.Mocks {
/// <returns>
/// The writer the caller should write out the entity data to.
/// </returns>
- public TextWriter GetRequestStream(HttpWebRequest request) {
- this.postEntity = new StringBuilder();
- return new StringWriter(this.postEntity);
+ public Stream GetRequestStream(HttpWebRequest request) {
+ this.postEntity = new MemoryStream();
+ return this.postEntity;
}
/// <summary>
@@ -75,7 +87,7 @@ namespace DotNetOpenAuth.Test.Mocks {
#region IDirectSslWebRequestHandler Members
- public TextWriter GetRequestStream(HttpWebRequest request, bool requireSsl) {
+ public Stream GetRequestStream(HttpWebRequest request, bool requireSsl) {
ErrorUtilities.VerifyProtocol(!requireSsl || request.RequestUri.Scheme == Uri.UriSchemeHttps, "disallowed request");
return this.GetRequestStream(request);
}