44//
55// Author:
66// Gonzalo Paniagua Javier ([email protected] ) 7+ 78//
89// Copyright (c) 2005 Novell, Inc. (http://www.novell.com)
9- // Copyright (c) 2012-2013 sta.blockhead ([email protected] ) 10+ // Copyright (c) 2012-2013 sta.blockhead
1011//
1112// Permission is hereby granted, free of charge, to any person obtaining
1213// a copy of this software and associated documentation files (the
@@ -41,7 +42,7 @@ namespace WebSocketSharp.Net {
4142 /// </summary>
4243 public sealed class HttpListener : IDisposable {
4344
44- #region Fields
45+ #region Private Fields
4546
4647 AuthenticationSchemes auth_schemes ;
4748 AuthenticationSchemeSelector auth_selector ;
@@ -58,7 +59,7 @@ public sealed class HttpListener : IDisposable {
5859
5960 #endregion
6061
61- #region Constructor
62+ #region Public Constructors
6263
6364 /// <summary>
6465 /// Initializes a new instance of the <see cref="HttpListener"/> class.
@@ -75,7 +76,7 @@ public HttpListener ()
7576
7677 #endregion
7778
78- #region Properties
79+ #region Public Properties
7980
8081 /// <summary>
8182 /// Gets or sets the scheme used to authenticate the clients.
@@ -84,9 +85,15 @@ public HttpListener ()
8485 /// One of the <see cref="AuthenticationSchemes"/> values that indicates the scheme used to
8586 /// authenticate the clients. The default value is <see cref="AuthenticationSchemes.Anonymous"/>.
8687 /// </value>
88+ /// <exception cref="ObjectDisposedException">
89+ /// This object has been closed.
90+ /// </exception>
8791 public AuthenticationSchemes AuthenticationSchemes {
88- // TODO: Digest, NTLM and Negotiate require ControlPrincipal
89- get { return auth_schemes ; }
92+ // TODO: Digest, NTLM and Negotiate require ControlPrincipal
93+ get {
94+ CheckDisposed ( ) ;
95+ return auth_schemes ;
96+ }
9097 set {
9198 CheckDisposed ( ) ;
9299 auth_schemes = value ;
@@ -100,16 +107,36 @@ public AuthenticationSchemes AuthenticationSchemes {
100107 /// A <see cref="AuthenticationSchemeSelector"/> delegate that invokes the method(s) used to select
101108 /// an authentication scheme. The default value is <see langword="null"/>.
102109 /// </value>
110+ /// <exception cref="ObjectDisposedException">
111+ /// This object has been closed.
112+ /// </exception>
103113 public AuthenticationSchemeSelector AuthenticationSchemeSelectorDelegate {
104- get { return auth_selector ; }
114+ get {
115+ CheckDisposed ( ) ;
116+ return auth_selector ;
117+ }
105118 set {
106119 CheckDisposed ( ) ;
107120 auth_selector = value ;
108121 }
109122 }
110123
124+ /// <summary>
125+ /// Gets or sets a value indicating whether the <see cref="HttpListener"/> returns exceptions
126+ /// that occur when sending the response to the client.
127+ /// </summary>
128+ /// <value>
129+ /// <c>true</c> if does not return exceptions that occur when sending the response to the client;
130+ /// otherwise, <c>false</c>. The default value is <c>false</c>.
131+ /// </value>
132+ /// <exception cref="ObjectDisposedException">
133+ /// This object has been closed.
134+ /// </exception>
111135 public bool IgnoreWriteExceptions {
112- get { return ignore_write_exceptions ; }
136+ get {
137+ CheckDisposed ( ) ;
138+ return ignore_write_exceptions ;
139+ }
113140 set {
114141 CheckDisposed ( ) ;
115142 ignore_write_exceptions = value ;
@@ -142,6 +169,9 @@ public static bool IsSupported {
142169 /// <value>
143170 /// A <see cref="HttpListenerPrefixCollection"/> that contains the URI prefixes.
144171 /// </value>
172+ /// <exception cref="ObjectDisposedException">
173+ /// This object has been closed.
174+ /// </exception>
145175 public HttpListenerPrefixCollection Prefixes {
146176 get {
147177 CheckDisposed ( ) ;
@@ -155,18 +185,39 @@ public HttpListenerPrefixCollection Prefixes {
155185 /// <value>
156186 /// A <see cref="string"/> that contains the name of the realm.
157187 /// </value>
188+ /// <exception cref="ObjectDisposedException">
189+ /// This object has been closed.
190+ /// </exception>
158191 public string Realm {
159- // TODO: Use this
160- get { return realm ; }
192+ // TODO: Use this
193+ get {
194+ CheckDisposed ( ) ;
195+ return realm ;
196+ }
161197 set {
162198 CheckDisposed ( ) ;
163199 realm = value ;
164200 }
165201 }
166202
203+ /// <summary>
204+ /// Gets or sets a value indicating whether, when NTLM authentication is used,
205+ /// the authentication information of first request is used to authenticate
206+ /// additional requests on the same connection.
207+ /// </summary>
208+ /// <value>
209+ /// <c>true</c> if the authentication information of first request is used;
210+ /// otherwise, <c>false</c>. The default value is <c>false</c>.
211+ /// </value>
212+ /// <exception cref="ObjectDisposedException">
213+ /// This object has been closed.
214+ /// </exception>
167215 public bool UnsafeConnectionNtlmAuthentication {
168- // TODO: Support for NTLM needs some loving.
169- get { return unsafe_ntlm_auth ; }
216+ // TODO: Support for NTLM needs some loving.
217+ get {
218+ CheckDisposed ( ) ;
219+ return unsafe_ntlm_auth ;
220+ }
170221 set {
171222 CheckDisposed ( ) ;
172223 unsafe_ntlm_auth = value ;
@@ -331,22 +382,6 @@ internal void UnregisterContext (HttpListenerContext context)
331382
332383 #endregion
333384
334- #region Explicit Interface Implementation
335-
336- /// <summary>
337- /// Releases all resource used by the <see cref="HttpListener"/>.
338- /// </summary>
339- void IDisposable . Dispose ( )
340- {
341- if ( disposed )
342- return ;
343-
344- Close ( true ) ; // TODO: Should we force here or not?
345- disposed = true ;
346- }
347-
348- #endregion
349-
350385 #region Public Methods
351386
352387 /// <summary>
@@ -378,6 +413,9 @@ public void Abort ()
378413 /// <param name="state">
379414 /// An <see cref="object"/> that contains a user defined object to pass to the <paramref name="callback"/> delegate.
380415 /// </param>
416+ /// <exception cref="ObjectDisposedException">
417+ /// This object has been closed.
418+ /// </exception>
381419 /// <exception cref="InvalidOperationException">
382420 /// The <see cref="HttpListener"/> has not been started or is stopped currently.
383421 /// </exception>
@@ -429,6 +467,9 @@ public void Close ()
429467 /// <param name="asyncResult">
430468 /// An <see cref="IAsyncResult"/> obtained by calling the <see cref="BeginGetContext"/> method.
431469 /// </param>
470+ /// <exception cref="ObjectDisposedException">
471+ /// This object has been closed.
472+ /// </exception>
432473 /// <exception cref="ArgumentNullException">
433474 /// <paramref name="asyncResult"/> is <see langword="null"/>.
434475 /// </exception>
@@ -477,7 +518,18 @@ public HttpListenerContext EndGetContext (IAsyncResult asyncResult)
477518 /// A <see cref="HttpListenerContext"/> that contains a client's request information.
478519 /// </returns>
479520 /// <exception cref="InvalidOperationException">
521+ /// <para>
480522 /// The <see cref="HttpListener"/> does not have any URI prefixes to listen on.
523+ /// </para>
524+ /// <para>
525+ /// -or-
526+ /// </para>
527+ /// <para>
528+ /// The <see cref="HttpListener"/> has not been started or is stopped currently.
529+ /// </para>
530+ /// </exception>
531+ /// <exception cref="ObjectDisposedException">
532+ /// This object has been closed.
481533 /// </exception>
482534 public HttpListenerContext GetContext ( )
483535 {
@@ -493,6 +545,9 @@ public HttpListenerContext GetContext ()
493545 /// <summary>
494546 /// Starts to receive incoming requests.
495547 /// </summary>
548+ /// <exception cref="ObjectDisposedException">
549+ /// This object has been closed.
550+ /// </exception>
496551 public void Start ( )
497552 {
498553 CheckDisposed ( ) ;
@@ -506,6 +561,9 @@ public void Start ()
506561 /// <summary>
507562 /// Stops receiving incoming requests.
508563 /// </summary>
564+ /// <exception cref="ObjectDisposedException">
565+ /// This object has been closed.
566+ /// </exception>
509567 public void Stop ( )
510568 {
511569 CheckDisposed ( ) ;
@@ -518,5 +576,21 @@ public void Stop ()
518576 }
519577
520578 #endregion
579+
580+ #region Explicit Interface Implementation
581+
582+ /// <summary>
583+ /// Releases all resource used by the <see cref="HttpListener"/>.
584+ /// </summary>
585+ void IDisposable . Dispose ( )
586+ {
587+ if ( disposed )
588+ return ;
589+
590+ Close ( true ) ; // TODO: Should we force here or not?
591+ disposed = true ;
592+ }
593+
594+ #endregion
521595 }
522596}
0 commit comments