[System]: WebRequest.GetSystemProxy(): Return custom proxy for monodroid.
[mono.git] / mcs / class / System / System.Net / ListenerAsyncResult.cs
index c6b65e68c5b5ecb7456708bef95e9adbaa8ef79b..88f75e88a9941e4c7457f763497bc9f04416d6b7 100644 (file)
@@ -28,7 +28,7 @@
 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 //
 
-#if NET_2_0 && SECURITY_DEP
+#if SECURITY_DEP
 
 using System.Threading;
 namespace System.Net {
@@ -42,6 +42,8 @@ namespace System.Net {
                HttpListenerContext context;
                object locker = new object ();
                ListenerAsyncResult forward;
+               internal bool EndCalled;
+               internal bool InGet;
 
                public ListenerAsyncResult (AsyncCallback cb, object state)
                {
@@ -49,14 +51,15 @@ namespace System.Net {
                        this.state = state;
                }
 
-               internal void Complete (string error)
+               internal void Complete (Exception exc)
                {
                        if (forward != null) {
-                               forward.Complete (error);
+                               forward.Complete (exc);
                                return;
                        }
-                       //FIXME: error_code?
-                       exception = new HttpListenerException (0, error);
+                       exception = exc;
+                       if (InGet && (exc is ObjectDisposedException))
+                               exception = new HttpListenerException (500, "Listener closed");
                        lock (locker) {
                                completed = true;
                                if (handle != null)
@@ -109,11 +112,13 @@ namespace System.Net {
                                        ListenerAsyncResult next = forward;
                                        for (int i = 0; next.forward != null; i++) {
                                                if (i > 20)
-                                                       Complete ("Too many authentication errors");
+                                                       Complete (new HttpListenerException (400, "Too many authentication errors"));
                                                next = next.forward;
                                        }
                                } else {
                                        completed = true;
+                    this.synch = false;
+
                                        if (handle != null)
                                                handle.Set ();