Beispiel #1
0
 /// <exception cref="System.IO.IOException"></exception>
 private static void WriteField(MinimalField field, OutputStream @out)
 {
     WriteBytes(field.GetName(), @out);
     WriteBytes(FieldSep, @out);
     WriteBytes(field.GetBody(), @out);
     WriteBytes(CrLf, @out);
 }
		/// <exception cref="System.IO.IOException"></exception>
		private static void WriteField(MinimalField field, OutputStream @out)
		{
			WriteBytes(field.GetName(), @out);
			WriteBytes(FieldSep, @out);
			WriteBytes(field.GetBody(), @out);
			WriteBytes(CrLf, @out);
		}
Beispiel #3
0
        /// <exception cref="System.IO.IOException"></exception>
        private void DoWriteTo(HttpMultipartMode mode, OutputStream @out, bool writeContent
                               )
        {
            ByteArrayBuffer boundary = Encode(this.charset, GetBoundary());

            foreach (FormBodyPart part in this.parts)
            {
                WriteBytes(TwoDashes, @out);
                WriteBytes(boundary, @out);
                WriteBytes(CrLf, @out);
                Header header = part.GetHeader();
                switch (mode)
                {
                case HttpMultipartMode.Strict:
                {
                    foreach (MinimalField field in header)
                    {
                        WriteField(field, @out);
                    }
                    break;
                }

                case HttpMultipartMode.BrowserCompatible:
                {
                    // Only write Content-Disposition
                    // Use content charset
                    MinimalField cd = part.GetHeader().GetField(MIME.ContentDisposition);
                    WriteField(cd, this.charset, @out);
                    string filename = part.GetBody().GetFilename();
                    if (filename != null)
                    {
                        MinimalField ct = part.GetHeader().GetField(MIME.ContentType);
                        WriteField(ct, this.charset, @out);
                    }
                    break;
                }
                }
                WriteBytes(CrLf, @out);
                if (writeContent)
                {
                    part.GetBody().WriteTo(@out);
                }
                WriteBytes(CrLf, @out);
            }
            WriteBytes(TwoDashes, @out);
            WriteBytes(boundary, @out);
            WriteBytes(TwoDashes, @out);
            WriteBytes(CrLf, @out);
        }