diff options
Diffstat (limited to 'src/DotNetOpenId.Test/Hosting')
-rw-r--r-- | src/DotNetOpenId.Test/Hosting/AspNetHost.cs | 13 | ||||
-rw-r--r-- | src/DotNetOpenId.Test/Hosting/EncodingInterceptor.cs | 30 | ||||
-rw-r--r-- | src/DotNetOpenId.Test/Hosting/HttpHost.cs | 15 |
3 files changed, 19 insertions, 39 deletions
diff --git a/src/DotNetOpenId.Test/Hosting/AspNetHost.cs b/src/DotNetOpenId.Test/Hosting/AspNetHost.cs index 844c040..47480f2 100644 --- a/src/DotNetOpenId.Test/Hosting/AspNetHost.cs +++ b/src/DotNetOpenId.Test/Hosting/AspNetHost.cs @@ -21,13 +21,9 @@ namespace DotNetOpenId.Test.Hosting { httpHost = HttpHost.CreateHost(this);
if (!UntrustedWebRequest.WhitelistHosts.Contains("localhost"))
UntrustedWebRequest.WhitelistHosts.Add("localhost");
- DotNetOpenId.Provider.SigningMessageEncoder.Signing += (s, e) => {
- if (MessageInterceptor != null) MessageInterceptor.OnSigningMessage(e.Message);
- };
}
public Uri BaseUri { get { return httpHost.BaseUri; } }
- public EncodingInterceptor MessageInterceptor { get; set; }
public static AspNetHost CreateHost(string webDirectory) {
AspNetHost host = (AspNetHost)ApplicationHost.
@@ -48,8 +44,13 @@ namespace DotNetOpenId.Test.Hosting { }
public void ProcessRequest(HttpListenerContext context) {
- using (TextWriter tw = new StreamWriter(context.Response.OutputStream)) {
- HttpRuntime.ProcessRequest(new TestingWorkerRequest(context, tw));
+ try {
+ using (TextWriter tw = new StreamWriter(context.Response.OutputStream)) {
+ HttpRuntime.ProcessRequest(new TestingWorkerRequest(context, tw));
+ }
+ } catch (Exception ex) {
+ TestSupport.Logger.Error("Exception in AspNetHost", ex);
+ throw;
}
}
diff --git a/src/DotNetOpenId.Test/Hosting/EncodingInterceptor.cs b/src/DotNetOpenId.Test/Hosting/EncodingInterceptor.cs deleted file mode 100644 index 0759ba2..0000000 --- a/src/DotNetOpenId.Test/Hosting/EncodingInterceptor.cs +++ /dev/null @@ -1,30 +0,0 @@ -using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using DotNetOpenId.Provider;
-using System.Diagnostics;
-
-namespace DotNetOpenId.Test.Hosting {
- /// <remarks>
- /// This should be instantiated in the test app domain,
- /// and passed to the ASP.NET host app domain.
- /// </remarks>
- public class EncodingInterceptor : MarshalByRefObject {
- /// <summary>
- /// Forwards a call from the ASP.NET host on to any interested test.
- /// </summary>
- /// <param name="message"></param>
- internal void OnSigningMessage(IEncodable message) {
- if (SigningMessage != null) {
- try {
- SigningMessage(message);
- } catch (Exception e) {
- Trace.TraceWarning("Unhandled exception in cross app-domain event handler: {0}", e);
- }
- }
- }
- internal delegate void InterceptorHandler(IEncodable message);
- internal InterceptorHandler SigningMessage;
- }
-}
diff --git a/src/DotNetOpenId.Test/Hosting/HttpHost.cs b/src/DotNetOpenId.Test/Hosting/HttpHost.cs index 44a7363..dc69848 100644 --- a/src/DotNetOpenId.Test/Hosting/HttpHost.cs +++ b/src/DotNetOpenId.Test/Hosting/HttpHost.cs @@ -67,9 +67,18 @@ namespace DotNetOpenId.Test.Hosting { using (StreamWriter sw = new StreamWriter(request.GetRequestStream()))
sw.Write(body);
}
- using (WebResponse response = request.GetResponse()) {
- using (StreamReader sr = new StreamReader(response.GetResponseStream()))
- return sr.ReadToEnd();
+ try {
+ using (WebResponse response = request.GetResponse()) {
+ using (StreamReader sr = new StreamReader(response.GetResponseStream()))
+ return sr.ReadToEnd();
+ }
+ } catch (WebException ex) {
+ TestSupport.Logger.Error("Exception in HttpHost", ex);
+ using (StreamReader sr = new StreamReader(ex.Response.GetResponseStream())) {
+ string streamContent = sr.ReadToEnd();
+ TestSupport.Logger.ErrorFormat("Error content stream follows: {0}", streamContent);
+ }
+ throw;
}
}
|