Example #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();
        }
        public HttpMultiPartFormDataHandler(string boundary, Encoding encoding, IUploadedFileCreator file_creator)
        {
            this.boundary = "--" + boundary.TrimStart(quotation_mark).TrimEnd(quotation_mark);
            this.encoding = encoding;
            this.file_creator = file_creator;

            state = State.InBoundary;
        }
Example #3
0
        public HttpMultiPartFormDataHandler(string boundary, Encoding encoding, IUploadedFileCreator file_creator)
        {
            this.boundary     = "--" + boundary.TrimStart(quotation_mark).TrimEnd(quotation_mark);
            this.encoding     = encoding;
            this.file_creator = file_creator;

            state = State.InBoundary;
        }