Example #1
0
        //use for encoding headers
        internal IEncodableStream GetEncoderForHeader(Encoding encoding, bool useBase64Encoding, int headerTextLength)
        {
            byte[] header = CreateHeader(encoding, useBase64Encoding);
            byte[] footer = CreateFooter();

            WriteStateInfoBase writeState;
            if (useBase64Encoding)
            {
                writeState = new Base64WriteStateInfo(InitialBufferSize, header, footer, DefaultMaxLineLength, headerTextLength);
                return new Base64Stream((Base64WriteStateInfo)writeState);
            }

            writeState = new WriteStateInfoBase(InitialBufferSize, header, footer, DefaultMaxLineLength, headerTextLength);
            return new QEncodedStream(writeState);
        }
        //use for encoding headers
        internal IEncodableStream GetEncoderForHeader(Encoding encoding, bool useBase64Encoding, int headerTextLength)
        {
            byte[] header = CreateHeader(encoding, useBase64Encoding);
            byte[] footer = CreateFooter();

            WriteStateInfoBase writeState;

            if (useBase64Encoding)
            {
                writeState = new Base64WriteStateInfo(InitialBufferSize, header, footer, DefaultMaxLineLength, headerTextLength);
                return(new Base64Stream((Base64WriteStateInfo)writeState));
            }

            writeState = new WriteStateInfoBase(InitialBufferSize, header, footer, DefaultMaxLineLength, headerTextLength);
            return(new QEncodedStream(writeState));
        }
Example #3
0
 internal QEncodedStream(WriteStateInfoBase wsi) : base(new MemoryStream())
 {
     _writeState = wsi;
 }
 internal QEncodedStream(WriteStateInfoBase wsi)
 {
     this.writeState = wsi;
 }
Example #5
0
 internal QEncodedStream(WriteStateInfoBase wsi) : base(new MemoryStream())
 {
     _writeState = wsi;
 }
Example #6
0
        public int EncodeBytes(byte[] buffer, int offset, int count)
        {
            this.writeState.CurrentLineLength += this.writeState.HeaderLength + this.writeState.MimeHeaderLength;
            this.writeState.AppendHeader();
            int index = offset;

            while (index < (count + offset))
            {
                if ((((this.lineLength != -1) && ((this.WriteState.CurrentLineLength + 5) >= this.lineLength)) && (((buffer[index] == 0x20) || (buffer[index] == 9)) || ((buffer[index] == 13) || (buffer[index] == 10)))) || ((this.WriteState.CurrentLineLength + this.writeState.FooterLength) >= this.lineLength))
                {
                    int num2;
                    int num3;
                    int num4;
                    if ((this.WriteState.Buffer.Length - this.WriteState.Length) < this.WriteState.FooterLength)
                    {
                        this.WriteState.ResizeBuffer();
                    }
                    this.WriteState.AppendFooter();
                    WriteStateInfoBase writeState = this.WriteState;
                    writeState.Length            = (num2 = writeState.Length) + 1;
                    this.WriteState.Buffer[num2] = 13;
                    WriteStateInfoBase base2 = this.WriteState;
                    base2.Length = (num3 = base2.Length) + 1;
                    this.WriteState.Buffer[num3] = 10;
                    WriteStateInfoBase base3 = this.WriteState;
                    base3.Length = (num4 = base3.Length) + 1;
                    this.WriteState.Buffer[num4] = 0x20;
                    this.WriteState.AppendHeader();
                    this.WriteState.CurrentLineLength = this.WriteState.HeaderLength;
                }
                if ((this.WriteState.CurrentLineLength == 0) && (buffer[index] == 0x2e))
                {
                    int num5;
                    WriteStateInfoBase base4 = this.WriteState;
                    base4.Length = (num5 = base4.Length) + 1;
                    this.WriteState.Buffer[num5] = 0x2e;
                }
                if (((buffer[index] == 13) && ((index + 1) < (count + offset))) && (buffer[index + 1] == 10))
                {
                    int num6;
                    int num7;
                    int num8;
                    int num9;
                    int num10;
                    int num11;
                    if ((this.WriteState.Buffer.Length - this.WriteState.Length) < 6)
                    {
                        this.WriteState.ResizeBuffer();
                    }
                    index++;
                    WriteStateInfoBase base5 = this.WriteState;
                    base5.Length = (num6 = base5.Length) + 1;
                    this.WriteState.Buffer[num6] = 0x3d;
                    WriteStateInfoBase base6 = this.WriteState;
                    base6.Length = (num7 = base6.Length) + 1;
                    this.WriteState.Buffer[num7] = 0x30;
                    WriteStateInfoBase base7 = this.WriteState;
                    base7.Length = (num8 = base7.Length) + 1;
                    this.WriteState.Buffer[num8] = 0x44;
                    WriteStateInfoBase base8 = this.WriteState;
                    base8.Length = (num9 = base8.Length) + 1;
                    this.WriteState.Buffer[num9] = 0x3d;
                    WriteStateInfoBase base9 = this.WriteState;
                    base9.Length = (num10 = base9.Length) + 1;
                    this.WriteState.Buffer[num10] = 0x30;
                    WriteStateInfoBase base10 = this.WriteState;
                    base10.Length = (num11 = base10.Length) + 1;
                    this.WriteState.Buffer[num11] = 0x41;
                    WriteStateInfoBase base11 = this.WriteState;
                    base11.CurrentLineLength += 6;
                }
                else if (((buffer[index] < 0x20) && (buffer[index] != 9)) || ((buffer[index] == 0x3d) || (buffer[index] > 0x7e)))
                {
                    int num12;
                    int num13;
                    int num14;
                    if ((this.WriteState.Buffer.Length - this.WriteState.Length) < 3)
                    {
                        this.WriteState.ResizeBuffer();
                    }
                    WriteStateInfoBase base12 = this.WriteState;
                    base12.CurrentLineLength += 3;
                    WriteStateInfoBase base13 = this.WriteState;
                    base13.Length = (num12 = base13.Length) + 1;
                    this.WriteState.Buffer[num12] = 0x3d;
                    WriteStateInfoBase base14 = this.WriteState;
                    base14.Length = (num13 = base14.Length) + 1;
                    this.WriteState.Buffer[num13] = hexEncodeMap[buffer[index] >> 4];
                    WriteStateInfoBase base15 = this.WriteState;
                    base15.Length = (num14 = base15.Length) + 1;
                    this.WriteState.Buffer[num14] = hexEncodeMap[buffer[index] & 15];
                }
                else if (buffer[index] == 0x20)
                {
                    int num15;
                    if ((this.WriteState.Buffer.Length - this.WriteState.Length) < 1)
                    {
                        this.WriteState.ResizeBuffer();
                    }
                    WriteStateInfoBase base16 = this.WriteState;
                    base16.CurrentLineLength++;
                    WriteStateInfoBase base17 = this.WriteState;
                    base17.Length = (num15 = base17.Length) + 1;
                    this.WriteState.Buffer[num15] = 0x5f;
                }
                else
                {
                    int num16;
                    if ((this.WriteState.Buffer.Length - this.WriteState.Length) < 1)
                    {
                        this.WriteState.ResizeBuffer();
                    }
                    WriteStateInfoBase base18 = this.WriteState;
                    base18.CurrentLineLength++;
                    WriteStateInfoBase base19 = this.WriteState;
                    base19.Length = (num16 = base19.Length) + 1;
                    this.WriteState.Buffer[num16] = buffer[index];
                }
                index++;
            }
            this.WriteState.AppendFooter();
            return(index - offset);
        }
Example #7
0
 internal QEncodedStream(WriteStateInfoBase wsi)
 {
     this.writeState = wsi;
 }