Esempio n. 1
0
        private void OnHeaders(IOStream stream, byte [] data)
        {
            string h = Encoding.ASCII.GetString (data);
            StringReader reader = new StringReader (h);

            string verb;
            string path;
            string version;

            string line = reader.ReadLine ();
            ParseStartLine (line, out verb, out path, out version);

            HttpHeaders headers = new HttpHeaders ();
            headers.Parse (reader);

            Request = new HttpRequest (this, headers, verb, path, Version_1_1_Supported (version));
            Response = new HttpResponse (this, Encoding.ASCII);

            if (headers.ContentLength != null && headers.ContentLength > 0) {
                stream.ReadBytes ((int) headers.ContentLength, OnBody);
                return;
            }

            Server.IOLoop.QueueTransaction (this);
        }
Esempio n. 2
0
        private void OnHeaders(IOStream stream, byte [] data)
        {
            string h = Encoding.ASCII.GetString (data);
            StringReader reader = new StringReader (h);

            string verb;
            string path;
            string version;

            string line = reader.ReadLine ();
            ParseStartLine (line, out verb, out path, out version);

            HttpHeaders headers = new HttpHeaders ();
            headers.Parse (reader);

            Request = new HttpRequest (this, headers, verb, path, Version_1_1_Supported (version));
            Response = new HttpResponse (this, Encoding.ASCII);

            if (headers.ContentLength != null && headers.ContentLength > 0) {
                    long cl = (long) headers.ContentLength;
                if (cl < MAX_BUFFERED_CONTENT_LENGTH) {
                    HandleBody ();
                    return;
                } else {
                    HandleLargeBody ();
                    return;
                }
            }

            stream.DisableReading ();
            Server.RunTransaction (this);
        }