Beispiel #1
0
 internal void KeyExchangeComplete(ClientInfo ci)
 {
     // Key exchange is complete on this client. Client ready
     // handlers may still force a close of the connection
     if (ClientReady != null)
     {
         if (!ClientReady(this, ci))
         {
             ci.Close();
         }
     }
 }
Beispiel #2
0
        void SendResponse(ClientInfo ci, HttpRequest req, HttpResponse resp, bool close)
        {
            StringBuilder builder = new StringBuilder ();
            // Create Headers
            builder.Append ("HTTP/1.0 ");
            builder.Append (resp.ReturnCode);
            builder.Append (Responses [resp.ReturnCode]);
            builder.Append ("\r\nDate: ");
            builder.Append (DateTime.Now.ToString ("R"));
            builder.Append ("\r\nServer: UnityEmbedded/1.0 (iOS)");
            //builder.Append ("\r\nConnection: ");
            //builder.Append ((close ? "close" : "Keep-Alive"));

            if (resp.RawContent == null) {
                builder.Append ("\r\nContent-Length: ");
                builder.Append (resp.Content.Length);
            } else {
                builder.Append ("\r\nContent-Length: ");
                builder.Append (resp.RawContent.Length);
            }

            builder.Append ("\r\nContent-Encoding: utf-8");
            builder.Append ("\r\nContent-Type: ");

            builder.Append (resp.ContentType);

            // ADDING CUSTOM HEADERS(new feature)
            if (!CUSTOM_RESPONSE_HEADERS.StartsWith ("$"))
                builder.Append (CUSTOM_RESPONSE_HEADERS);

            if (req.Session != null) {
                builder.Append ("\r\nSet-Cookie: _sessid=");
                builder.Append (req.Session.ID);
                builder.Append ("; path=/");
            }

            foreach (DictionaryEntry de in resp.Header) {
                builder.Append ("\r\n");
                builder.Append (de.Key);
                builder.Append (": ");
                builder.Append (de.Value);
            }
            builder.Append ("\r\n\r\n");

            // Send Header
            ci.Send (builder.ToString ());

            // Send Body
            if (resp.RawContent != null) {
                ci.Send (resp.RawContent);
            } else {
                ci.Send (resp.Content);
            }

            // Close if not persistent connection
            if (close) {
                ci.Close ();
            }
        }
Beispiel #3
0
 internal void KeyExchangeComplete(ClientInfo ci)
 {
     // Key exchange is complete on this client. Client ready
     // handlers may still force a close of the connection
     if (ClientReady != null)
     if (!ClientReady (this, ci))
         ci.Close ();
 }
Beispiel #4
0
        void SendResponse(ClientInfo ci, HttpRequest req, HttpResponse resp, bool close)
        {
            StringBuilder builder = new StringBuilder();

            // Create Headers
            builder.Append("HTTP/1.0 ");
            builder.Append(resp.ReturnCode);
            builder.Append(Responses [resp.ReturnCode]);
            builder.Append("\r\nDate: ");
            builder.Append(DateTime.Now.ToString("R"));
            builder.Append("\r\nServer: UnityEmbedded/1.0 (iOS)");
            //builder.Append ("\r\nConnection: ");
            //builder.Append ((close ? "close" : "Keep-Alive"));

            if (resp.RawContent == null)
            {
                builder.Append("\r\nContent-Length: ");
                builder.Append(resp.Content.Length);
            }
            else
            {
                builder.Append("\r\nContent-Length: ");
                builder.Append(resp.RawContent.Length);
            }

            builder.Append("\r\nContent-Encoding: utf-8");
            builder.Append("\r\nContent-Type: ");

            builder.Append(resp.ContentType);

            // ADDING CUSTOM HEADERS(new feature)
            if (!CUSTOM_RESPONSE_HEADERS.StartsWith("$"))
            {
                builder.Append(CUSTOM_RESPONSE_HEADERS);
            }

            if (req.Session != null)
            {
                builder.Append("\r\nSet-Cookie: _sessid=");
                builder.Append(req.Session.ID);
                builder.Append("; path=/");
            }

            foreach (DictionaryEntry de in resp.Header)
            {
                builder.Append("\r\n");
                builder.Append(de.Key);
                builder.Append(": ");
                builder.Append(de.Value);
            }
            builder.Append("\r\n\r\n");

            // Send Header
            ci.Send(builder.ToString());

            // Send Body
            if (resp.RawContent != null)
            {
                ci.Send(resp.RawContent);
            }
            else
            {
                ci.Send(resp.Content);
            }

            // Close if not persistent connection
            if (close)
            {
                ci.Close();
            }
        }