Пример #1
0
 private void FlushHeader()
 {
     headerValueWritten = false;
     if (lastHeader == null)
         return;
     if (lastHeader.HeaderId == HeaderId.MimeVersion && partDepth == 1)
         foundMimeVersion = true;
     else if (lastHeader.HeaderId == HeaderId.ContentTransferEncoding) {
         var data = lastHeader.Value;
         if (data != null)
             contentTransferEncoding = MimePart.GetEncodingType(new MimeString(data));
     } else if (lastHeader.HeaderId == HeaderId.ContentType) {
         var contentTypeHeader = lastHeader as ContentTypeHeader;
         if (contentTypeHeader.IsMultipart) {
             currentPart.IsMultipart = true;
             currentPart.Boundary = contentTypeHeader["boundary"].RawValue;
         } else
             currentPart.IsMultipart = false;
         currentPart.HasContentType = true;
     }
     lastHeader.WriteTo(shimStream, encodingOptions);
     lastHeader = null;
 }
Пример #2
0
 private void WriteHeader(Header header)
 {
     switch (state) {
         case MimeWriteState.Initial:
         case MimeWriteState.Complete:
         case MimeWriteState.PartContent:
         case MimeWriteState.EndPart:
             throw new System.InvalidOperationException(Resources.Strings.CannotWriteHeadersHere);
         default:
             state = MimeWriteState.Headers;
             this.FlushHeader();
             lastHeader = header;
             break;
     }
 }
Пример #3
0
 public void WriteHeaderValue(System.DateTime value)
 {
     this.AssertOpen();
     if (headerValueWritten)
         throw new System.InvalidOperationException(Resources.Strings.CannotWriteHeaderValueMoreThanOnce);
     if (lastHeader == null)
         throw new System.InvalidOperationException(Resources.Strings.CannotWriteHeaderValueHere);
     headerValueWritten = true;
     var timeZoneOffset = System.TimeSpan.Zero;
     var utcDateTime = value.ToUniversalTime();
     if (value.Kind != System.DateTimeKind.Utc)
         timeZoneOffset = System.TimeZoneInfo.Local.GetUtcOffset(value);
     Header.WriteName(shimStream, lastHeader.Name, ref scratchBuffer);
     var currentLineLength = new MimeStringLength(0);
     DateHeader.WriteDateHeaderValue(shimStream, utcDateTime, timeZoneOffset, ref currentLineLength);
     lastHeader = null;
 }