예제 #1
0
파일: Sockets.cs 프로젝트: petrind/SRTesis2
 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("ClientReady callback rejected connection");
 }
예제 #2
0
파일: HTTP.cs 프로젝트: martindobias/ScanIt
 void SendResponse(ClientInfo ci, HttpRequest req, HttpResponse resp, bool close)
 {
     #if DEBUG
     Console.WriteLine("Response: "+resp.ReturnCode + Responses[resp.ReturnCode]);
     #endif
     ByteBuilder bb = new ByteBuilder();
     bb.Add(Encoding.UTF8.GetBytes("HTTP/1.1 " + resp.ReturnCode + " " + Responses[resp.ReturnCode] +
             "\r\nDate: "+DateTime.Now.ToString("R")+
             "\r\nServer: RedCoronaEmbedded/1.0"+
             "\r\nConnection: "+(close ? "close" : "Keep-Alive")));
     bb.Add(Encoding.UTF8.GetBytes("\r\nContent-Encoding: " + (resp.Encoding == null ? "utf-8" : resp.Encoding)));
     if (resp.RawContent == null)
         bb.Add(Encoding.UTF8.GetBytes("\r\nContent-Length: " + resp.Content.Length));
     else
         bb.Add(Encoding.UTF8.GetBytes("\r\nContent-Length: " + resp.RawContent.Length));
     if(resp.ContentType != null)
         bb.Add(Encoding.UTF8.GetBytes("\r\nContent-Type: "+resp.ContentType));
     if(req.Session != null) bb.Add(Encoding.UTF8.GetBytes("\r\nSet-Cookie: _sessid="+req.Session.ID+"; path=/"));
     foreach(KeyValuePair<string, string> de in resp.Header) bb.Add(Encoding.UTF8.GetBytes("\r\n" + de.Key + ": " + de.Value));
     bb.Add(Encoding.UTF8.GetBytes("\r\n\r\n")); // End of header
     if(resp.RawContent != null) bb.Add(resp.RawContent);
     else bb.Add(Encoding.UTF8.GetBytes(resp.Content));
     ci.Send(bb.Read(0, bb.Length));
     #if DEBUG
     Console.WriteLine("** SENDING\n"+resp.Content);
     #endif
     if(close) ci.Close();
 }