Exemplo n.º 1
0
        /* Helper function */

        private void TunnelChunkedDataTo(SocketState dest, MessagePacketHandler mph)
        {
            // (RFC 2616, sections 3.6.1, 19.4.6)
            while (true)
            {
                string chunk_header = ReadAsciiLine();
                if (chunk_header.Length == 0)
                {
                    throw new HttpProtocolBroken("Expected chunk header missing");
                }
                int    sc        = chunk_header.IndexOfAny(c_ChunkSizeEnd);
                string hexa_size = sc > -1
                                       ? chunk_header.Substring(0, sc)
                                       : chunk_header;
                uint size;
                try {
                    size = Convert.ToUInt32(hexa_size, 16);
                }
                catch {
                    string s = chunk_header.Length > 20
                                   ? (chunk_header.Substring(0, 17) + "...")
                                   : chunk_header;
                    throw new HttpProtocolBroken(
                              "Could not parse chunk size in: " + s);
                }

                if (dest != null)
                {
                    dest.WriteAsciiLine(chunk_header);
                }
                if (size == 0)
                {
                    break;
                }
                TunnelDataTo(mph, size);
                // Read/write one more CRLF
                string new_line = ReadAsciiLine();
                Debug.Assert(new_line.Length == 0);
                if (dest != null)
                {
                    dest.WriteAsciiLine(new_line);
                }
            }
            string line;

            do
            {
                // Tunnel any trailing entity headers
                line = ReadAsciiLine();
                if (dest != null)
                {
                    dest.WriteAsciiLine(line);
                }
            } while (line.Length != 0);
        }
Exemplo n.º 2
0
 internal void SendTo(SocketState hs)
 {
     hs.WriteAsciiLine(HeadersInOrder);
     // Note: HeadersInOrder contains one trailing newline, so
     // WriteAsciiLine() will send two newlines (which is what we
     // want).
 }
Exemplo n.º 3
0
 internal void SendTo(SocketState hs)
 {
     hs.WriteAsciiLine(RequestLine);
 }
Exemplo n.º 4
0
 internal void SendTo(SocketState hs)
 {
     hs.WriteAsciiLine(StatusLine);
 }
Exemplo n.º 5
0
        /* Helper function */
        private void TunnelChunkedDataTo(SocketState dest, MessagePacketHandler mph)
        {
            // (RFC 2616, sections 3.6.1, 19.4.6)
            while (true) {
                string chunk_header = ReadAsciiLine();
                if (chunk_header.Length == 0) {
                    throw new HttpProtocolBroken("Expected chunk header missing");
                }
                int sc = chunk_header.IndexOfAny(c_ChunkSizeEnd);
                string hexa_size = sc > -1
                                       ? chunk_header.Substring(0, sc)
                                       : chunk_header;
                uint size;
                try {
                    size = Convert.ToUInt32(hexa_size, 16);
                }
                catch {
                    string s = chunk_header.Length > 20
                                   ? (chunk_header.Substring(0, 17) + "...")
                                   : chunk_header;
                    throw new HttpProtocolBroken(
                        "Could not parse chunk size in: " + s);
                }

                if (dest != null) {
                    dest.WriteAsciiLine(chunk_header);
                }
                if (size == 0) {
                    break;
                }
                TunnelDataTo(mph, size);
                // Read/write one more CRLF
                string new_line = ReadAsciiLine();
                Debug.Assert(new_line.Length == 0);
                if (dest != null) {
                    dest.WriteAsciiLine(new_line);
                }
            }
            string line;
            do {
                // Tunnel any trailing entity headers
                line = ReadAsciiLine();
                if (dest != null) {
                    dest.WriteAsciiLine(line);
                }
            } while (line.Length != 0);
        }
Exemplo n.º 6
0
 internal void SendTo(SocketState hs)
 {
     hs.WriteAsciiLine(RequestLine);
 }
Exemplo n.º 7
0
 internal void SendTo(SocketState hs)
 {
     hs.WriteAsciiLine(StatusLine);
 }