public void SetHeader(string header)
        {
            var splitIndex  = header.IndexOf(':');
            var headerKey   = header.Substring(0, splitIndex);
            var headerValue = header.Substring(splitIndex + 1).TrimStart(' ');

            if (headerKey.Trim().ToLower().Equals("content-type"))
            {
                ContentType = new ContentType();
                var contentTypes = headerValue.Split('/'); //sample data "multipart/form-data; boundary=---------------------------2261521032598"

                ContentType.MainContentType = contentTypes[0].GetContentTypeMain();
                if (ContentType.MainContentType == EnumMainContentType.MultiPart)
                {
                    var subcontentData = contentTypes[1].Split(';');
                    ContentType.SubContentType = subcontentData[0].GetContentTypeSub();

                    var boundaryData = subcontentData[1].Split('=');
                    Boundary = boundaryData[1].TrimStart('-');//only remove the --'s because there is a \r\n on the other side of the number that is needed...
                }
                else
                {
                    ContentType.SubContentType = contentTypes[1].GetContentTypeSub();
                }
            }
            Headers.AddValue(headerKey, headerValue);
        }
示例#2
0
        public void SetHeader(string header)
        {
            var splitIndex = header.IndexOf(':');

            Headers.AddValue(header.Substring(0, splitIndex), header.Substring(splitIndex + 1).Trim());
        }