if (secure == false) {
stream = new NetworkStream (sock, false);
} else {
+#if EMBEDDED_IN_1_0
+ throw new NotImplementedException ();
+#else
SslServerStream ssl_stream = new SslServerStream (new NetworkStream (sock, false), cert, false, false);
ssl_stream.PrivateKeyCertSelectionDelegate += OnPVKSelection;
stream = ssl_stream;
+#endif
}
Init ();
}
{
if (buffer == null)
buffer = new byte [BufferSize];
- stream.BeginRead (buffer, 0, BufferSize, OnRead, this);
+ try {
+ stream.BeginRead (buffer, 0, BufferSize, OnRead, this);
+ } catch {
+ sock.Close (); // stream disposed
+ }
}
public RequestStream GetRequestStream (bool chunked, long contentlength)
nread = stream.EndRead (ares);
ms.Write (buffer, 0, nread);
} catch (Exception e) {
- Console.WriteLine (e);
+ //Console.WriteLine (e);
if (ms.Length > 0)
SendError ();
sock.Close ();
return;
}
- Socket s = sock;
- sock = null;
- try {
- s.Shutdown (SocketShutdown.Both);
- } finally {
- s.Close ();
+ if (context.Response.Headers ["connection"] == "close") {
+ Socket s = sock;
+ sock = null;
+ try {
+ s.Shutdown (SocketShutdown.Both);
+ } finally {
+ s.Close ();
+ }
+ } else {
+ Init ();
+ BeginReadRequest ();
+ return;
}
+
if (context_bound)
epl.UnbindContext (context);
}