Ejemplo n.º 1
0
        private void CreateBodyHandler()
        {
            string ct;

            if (!Headers.TryGetValue("Content-Type", out ct))
            {
                body_handler = new HttpBufferedBodyHandler();
                return;
            }

            if (ct.StartsWith("application/x-www-form-urlencoded", StringComparison.InvariantCultureIgnoreCase))
            {
                body_handler = new HttpFormDataHandler();
                return;
            }

            if (ct.StartsWith("multipart/form-data", StringComparison.InvariantCultureIgnoreCase))
            {
                string boundary = ParseBoundary(ct);
                IUploadedFileCreator file_creator = GetFileCreator();

                body_handler = new HttpMultiPartFormDataHandler(boundary, ContentEncoding, file_creator);
                return;
            }

            body_handler = new HttpBufferedBodyHandler();
        }
Ejemplo n.º 2
0
 protected virtual void OnFinishedReading(HttpParser parser)
 {
     if (body_handler != null)
     {
         body_handler.Finish(this);
         body_handler = null;
     }
 }
Ejemplo n.º 3
0
        private void CreateBodyHandler()
        {
            string ct = Request.Headers ["Content-Type"];

            if (ct != null && ct.StartsWith ("application/x-www-form-urlencoded", StringComparison.InvariantCultureIgnoreCase)) {
                body_handler = new HttpFormDataHandler ();
                return;
            }

            if (ct != null && ct.StartsWith ("multipart/form-data", StringComparison.InvariantCultureIgnoreCase)) {
                string boundary = ParseBoundary (ct);
                IUploadedFileCreator file_creator = GetFileCreator ();

                body_handler = new HttpMultiPartFormDataHandler (boundary, Request.ContentEncoding, file_creator);
                return;
            }
        }
Ejemplo n.º 4
0
        private void OnFinishedReading()
        {
            if (body_handler != null) {
                body_handler.Finish (this);
                body_handler = null;
            }

            try {
                Response = new HttpResponse (this, IOStream);

                Server.RunTransaction (this);
            } catch (Exception e) {
                Console.WriteLine ("Exception while running transaction");
                Console.WriteLine (e);
            }
        }