示例#1
0
        public Part(ArraySegment <byte> data, NameValueCollection headers)
        {
            if (data == null || headers == null)
            {
                throw new ArgumentNullException();
            }

            this.data    = data;
            this.bytes   = data;
            this.headers = headers;

            if (headers["content-disposition"] != null)
            {
                disposition = Disposition.Parse(headers["content-disposition"]);
            }
        }
示例#2
0
        //public Part(string data)
        //{
        //    if (data == null)
        //        throw new ArgumentNullException();

        //    this.data = Encoding.UTF8.GetBytes(data);
        //    this.start = 0;
        //    this.len = this.data.Length;
        //    this.headers = new NameValueCollection();
        //}

        public Part(string data, NameValueCollection headers)
        {
            if (data == null || headers == null)
            {
                throw new ArgumentNullException();
            }

            byte[] dataUtf8 = Encoding.UTF8.GetBytes(data);

            this.data    = new ArraySegment <byte>(dataUtf8);
            this.headers = headers;

            if (headers["content-disposition"] != null)
            {
                disposition = Disposition.Parse(headers["content-disposition"]);
            }
        }