コード例 #1
0
 internal void SendTo(HttpSocket hs)
 {
     hs.WriteAsciiLine(HeadersInOrder);
     // Note: HeadersInOrder contains one trailing newline, so
     // WriteAsciiLine() will send two newlines (which is what we
     // want).
 }
コード例 #2
0
        /* Helper function */
        void TunnelChunkedDataTo(HttpSocket 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;
                if (sc > -1)
                {
                    // We have chunk extensions: ignore them
                    hexa_size = chunk_header.Substring(0, sc);
                }
                else
                {
                    hexa_size = 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();
                System.Diagnostics.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);
        }
コード例 #3
0
 internal void SendTo(HttpSocket hs)
 {
     hs.WriteAsciiLine(StatusLine);
 }
コード例 #4
0
 internal void SendTo(HttpSocket hs)
 {
     hs.WriteAsciiLine(RequestLine);
 }