private GetRawValue ( MimeKit.FormatOptions format ) : byte[] | ||
format | MimeKit.FormatOptions | |
Результат | byte[] |
static void DkimWriteHeaderSimple (FormatOptions options, Stream stream, Header header) { var rawValue = header.GetRawValue (options); stream.Write (header.RawField, 0, header.RawField.Length); stream.Write (new [] { (byte) ':' }, 0, 1); stream.Write (rawValue, 0, rawValue.Length); }
static void DkimWriteHeaderSimple (FormatOptions options, Stream stream, Header header, bool isDkimSignature) { var rawValue = header.GetRawValue (options); int rawLength = rawValue.Length; if (isDkimSignature && rawLength > 0) { if (rawValue[rawLength - 1] == (byte) '\n') { rawLength--; if (rawLength > 0 && rawValue[rawLength - 1] == (byte) '\r') rawLength--; } } stream.Write (header.RawField, 0, header.RawField.Length); stream.Write (new [] { (byte) ':' }, 0, 1); stream.Write (rawValue, 0, rawLength); }
static void DkimWriteHeaderRelaxed (FormatOptions options, Stream stream, Header header) { var name = Encoding.ASCII.GetBytes (header.Field.ToLowerInvariant ()); var rawValue = header.GetRawValue (options); int index = 0; stream.Write (name, 0, name.Length); stream.WriteByte ((byte) ':'); // look for the first non-whitespace character while (index < rawValue.Length && rawValue[index].IsBlank ()) index++; while (index < rawValue.Length) { int startIndex = index; int endIndex, nextLine; // look for the first non-whitespace character while (index < rawValue.Length && rawValue[index].IsBlank ()) index++; // look for the end of the line endIndex = index; while (endIndex < rawValue.Length && rawValue[endIndex] != (byte) '\n') endIndex++; nextLine = endIndex + 1; if (endIndex > index && rawValue[endIndex - 1] == (byte) '\r') endIndex--; if (index > startIndex) stream.WriteByte ((byte) ' '); while (index < endIndex) { startIndex = index; while (index < endIndex && !rawValue[index].IsBlank ()) index++; stream.Write (rawValue, startIndex, index - startIndex); startIndex = index; while (index < endIndex && rawValue[index].IsBlank ()) index++; if (index > startIndex) stream.WriteByte ((byte) ' '); } index = nextLine; } stream.Write (options.NewLineBytes, 0, options.NewLineBytes.Length); }
static void DkimWriteHeaderRelaxed (FormatOptions options, Stream stream, Header header, bool isDkimSignature) { // o Convert all header field names (not the header field values) to // lowercase. For example, convert "SUBJect: AbC" to "subject: AbC". var name = Encoding.ASCII.GetBytes (header.Field.ToLowerInvariant ()); var rawValue = header.GetRawValue (options); int index = 0; // o Delete any WSP characters remaining before and after the colon // separating the header field name from the header field value. The // colon separator MUST be retained. stream.Write (name, 0, name.Length); stream.WriteByte ((byte) ':'); // trim leading whitespace... while (index < rawValue.Length && rawValue[index].IsWhitespace ()) index++; while (index < rawValue.Length) { int startIndex = index; // look for the first non-whitespace character while (index < rawValue.Length && rawValue[index].IsWhitespace ()) index++; // o Delete all WSP characters at the end of each unfolded header field // value. if (index >= rawValue.Length) break; // o Convert all sequences of one or more WSP characters to a single SP // character. WSP characters here include those before and after a // line folding boundary. if (index > startIndex) stream.WriteByte ((byte) ' '); startIndex = index; while (index < rawValue.Length && !rawValue[index].IsWhitespace ()) index++; if (index > startIndex) stream.Write (rawValue, startIndex, index - startIndex); } if (!isDkimSignature) stream.Write (options.NewLineBytes, 0, options.NewLineBytes.Length); }