Merge pull request #981 from methane/websocket
[mono.git] / mcs / class / System / System.Net / HttpConnection.cs
index a34f19024c80761d1d16660ed488d4b62bd8ee33..d554309b695de23d85e86e7df53800aa518248c3 100644 (file)
 
 #if SECURITY_DEP
 
+#if MONOTOUCH || MONODROID
+using Mono.Security.Protocol.Tls;
+#else
 extern alias MonoSecurity;
+using MonoSecurity::Mono.Security.Protocol.Tls;
+#endif
 
 using System.IO;
 using System.Net.Sockets;
@@ -38,7 +43,6 @@ using System.Text;
 using System.Threading;
 using System.Security.Cryptography;
 using System.Security.Cryptography.X509Certificates;
-using MonoSecurity::Mono.Security.Protocol.Tls;
 
 namespace System.Net {
        sealed class HttpConnection
@@ -205,6 +209,17 @@ namespace System.Net {
                        return o_stream;
                }
 
+               internal Socket Hijack (out ArraySegment<byte> buffered)
+               {
+                       // TODO: disable normal request/response.
+                       buffered = new ArraySegment<byte> (ms.GetBuffer(), position, (int)ms.Length - position);
+                       RemoveConnection ();
+                       var s = sock;
+                       sock = null;
+                       o_stream = null;
+                       return s;
+               }
+
                static void OnRead (IAsyncResult ares)
                {
                        HttpConnection cnc = (HttpConnection) ares.AsyncState;