summaryrefslogtreecommitdiffstats
path: root/samples/OpenIdOfflineProvider/HttpHost.cs
diff options
context:
space:
mode:
Diffstat (limited to 'samples/OpenIdOfflineProvider/HttpHost.cs')
-rw-r--r--samples/OpenIdOfflineProvider/HttpHost.cs54
1 files changed, 49 insertions, 5 deletions
diff --git a/samples/OpenIdOfflineProvider/HttpHost.cs b/samples/OpenIdOfflineProvider/HttpHost.cs
index 0c810bf..390275a 100644
--- a/samples/OpenIdOfflineProvider/HttpHost.cs
+++ b/samples/OpenIdOfflineProvider/HttpHost.cs
@@ -6,23 +6,42 @@
namespace DotNetOpenAuth.OpenIdOfflineProvider {
using System;
+ using System.Diagnostics.Contracts;
using System.Globalization;
using System.IO;
using System.Net;
using System.Threading;
- using DotNetOpenAuth.OpenId.Provider;
- using System.Diagnostics.Contracts;
using DotNetOpenAuth.Messaging;
+ using DotNetOpenAuth.OpenId.Provider;
+ /// <summary>
+ /// An HTTP Listener that dispatches incoming requests for handling.
+ /// </summary>
internal class HttpHost : IDisposable {
+ /// <summary>
+ /// The HttpListener that waits for incoming requests.
+ /// </summary>
private readonly HttpListener listener;
+
+ /// <summary>
+ /// The thread that listens for incoming HTTP requests and dispatches them
+ /// to the <see cref="handler"/>.
+ /// </summary>
private Thread listenerThread;
+
+ /// <summary>
+ /// The handler for incoming HTTP requests.
+ /// </summary>
private RequestHandler handler;
+ /// <summary>
+ /// Initializes a new instance of the <see cref="HttpHost"/> class.
+ /// </summary>
+ /// <param name="handler">The handler for incoming HTTP requests.</param>
private HttpHost(RequestHandler handler) {
Contract.Requires(handler != null);
- this.Port = 59687;
+ this.Port = 45235;
this.handler = handler;
Random r = new Random();
tryAgain:
@@ -42,14 +61,29 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider {
this.listenerThread.Start();
}
+ /// <summary>
+ /// The request handler delegate.
+ /// </summary>
+ /// <param name="context">Information on the incoming HTTP request.</param>
+ internal delegate void RequestHandler(HttpListenerContext context);
+
+ /// <summary>
+ /// Gets the port that HTTP requests are being listened for on.
+ /// </summary>
public int Port { get; private set; }
+ /// <summary>
+ /// Gets the base URI for all incoming web requests that will be received.
+ /// </summary>
public Uri BaseUri {
get { return new Uri("http://localhost:" + this.Port.ToString() + "/"); }
}
- internal delegate void RequestHandler(HttpListenerContext context);
-
+ /// <summary>
+ /// Creates the HTTP host.
+ /// </summary>
+ /// <param name="handler">The handler for incoming HTTP requests.</param>
+ /// <returns>The instantiated host.</returns>
public static HttpHost CreateHost(RequestHandler handler) {
Contract.Requires(handler != null);
Contract.Ensures(Contract.Result<HttpHost>() != null);
@@ -59,11 +93,18 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider {
#region IDisposable Members
+ /// <summary>
+ /// Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
+ /// </summary>
public void Dispose() {
this.Dispose(true);
GC.SuppressFinalize(this);
}
+ /// <summary>
+ /// Releases unmanaged and - optionally - managed resources
+ /// </summary>
+ /// <param name="disposing"><c>true</c> to release both managed and unmanaged resources; <c>false</c> to release only unmanaged resources.</param>
protected virtual void Dispose(bool disposing) {
if (disposing) {
this.listener.Close();
@@ -74,6 +115,9 @@ namespace DotNetOpenAuth.OpenIdOfflineProvider {
#endregion
+ /// <summary>
+ /// The HTTP listener thread body.
+ /// </summary>
private void ProcessRequests() {
Contract.Requires(this.listener != null);