Esempio n. 1
0
 private void AppendGivenHeaderFields(StringBuilder builder, IEnumerable <string> headerNames)
 {
     foreach (var headerName in headerNames)
     {
         builder.AppendFormat("{0}: {1}\r\n", Codec.GetFieldName(headerName), HeaderFields[headerName]);
     }
 }
Esempio n. 2
0
        public string GetHeaderString()
        {
            var str = new StringBuilder();

            // Add the content-type. Default is text/plain.
            str.Append(this.ContentType.ToString()).Append("\r\n");

            // Add the content-disposition if specified.
            if (this.ContentDisposition.Disposition.Length > 0)
            {
                str.Append(this.ContentDisposition.ToString()).Append("\r\n");
            }

            // Add other header fields.
            foreach (string key in this.HeaderFields.AllKeys)
            {
                // We already have content-type and disposition.
                if (!key.Equals("content-type") && !key.Equals("content-disposition"))
                {
                    str.AppendFormat("{0}: {1}\r\n", Codec.GetFieldName(key), this.HeaderFields[key]);
                }
            }

            return(string.Format("{0}\r\n", str.ToString().Trim('\r', '\n')));
        }
Esempio n. 3
0
        public string GetHeaderString()
        {
            string str = string.Empty;

            // Add the content-type. Default is text/plain.
            str += this.ContentType.ToString() + "\r\n";

            // Add the content-disposition if specified.
            if (this.ContentDisposition.Disposition.Length > 0)
            {
                str += this.ContentDisposition.ToString() + "\r\n";
            }

            // Add other header fields.
            foreach (string key in this.HeaderFields.AllKeys)
            {
                // We already have content-type and disposition.
                if (!key.Equals("content-type") && !key.Equals("content-disposition"))
                {
                    str += Codec.GetFieldName(key) + ": " + this.HeaderFields[key] + "\r\n";
                }
            }

            return(str.Trim('\r', '\n') + "\r\n");
        }
Esempio n. 4
0
        private void AppendContentEncoding(StringBuilder builder, bool forceBase64Encoding)
        {
            var headerValue = forceBase64Encoding ? "base64" : HeaderFields["content-transfer-encoding"];

            builder.AppendFormat("{0}: {1}\r\n", Codec.GetFieldName("content-transfer-encoding"), headerValue);
        }