예제 #1
0
 internal HttpResponse(HttpRequest request)
 {
     _request = request;
     _outStream = new MemoryStream();
     string encoding = "ascii";
     _enc = Encoding.ASCII;
     if (request.Headers.CharSet != null)
     {
         switch (request.Headers.CharSet.ToLower())
         {
             case "utf-7":
                 encoding = "utf-7";
                 _enc = Encoding.UTF7;
                 break;
             case "utf-8":
                 encoding = "utf-8";
                 _enc = Encoding.UTF8;
                 break;
             case "utf-32":
                 encoding = "utf-32";
                 _enc = Encoding.UTF32;
                 break;
         }
     }
     _responseWriter = new HttpStreamWriter(_outStream,_enc);
     _responseHeaders = new HeaderCollection();
     _responseHeaders["Server"] = Messages.Current["Org.Reddragonit.EmbeddedWebServer.DefaultHeaders.Server"];
     _responseHeaders.CharSet = encoding;
     _responseStatus = HttpStatusCodes.OK;
     _responseCookie = new CookieCollection();
     _isResponseSent = false;
 }
예제 #2
0
 internal void StartRequest(long id,string[] words,HttpConnection connection,ref HttpParser parser)
 {
     _id = id;
     _method = words[0].ToUpper();
     _path = words[1];
     _version = words[2];
     _mreParameters = new ManualResetEvent(false);
     _connection = connection;
     _contentBuffer = new MemoryStream();
     _requestTimeout = _requestStart.AddMilliseconds(int.MaxValue);
     _headers = new HeaderCollection();
     _requestStart = DateTime.Now;
     _parser = parser;
     _response = new HttpResponse(this);
     parser.RequestHeaderLineRecieved = _RequestHeaderLineReceived;
     parser.RequestHeaderComplete = _RequestHeaderComplete;
     parser.RequestBodyBytesRecieved = _RequestBodyBytesReceived;
     parser.RequestComplete = _RequestComplete;
 }