示例#1
0
        public HttpRequest(IHttpTransaction transaction, HttpHeaders headers, string method, string resource, bool support_1_1)
        {
            Transaction = transaction;
            Headers = headers;
            Method = method;
            ResourceUri = resource;
            Http_1_1_Supported = support_1_1;

            SetEncoding ();
            SetPathAndQuery ();
        }
示例#2
0
        public HttpResponse(IHttpTransaction transaction, Encoding encoding)
        {
            Transaction = transaction;
            Encoding = encoding;

            StatusCode = 200;

            WriteHeaders = true;
            WriteStatusLine = true;

            Headers = new HttpHeaders ();
            SetStandardHeaders ();
        }
示例#3
0
        public HttpResponse(IHttpTransaction transaction, Encoding encoding)
        {
            Transaction = transaction;
            Encoding = encoding;

            StatusCode = 200;

            WriteHeaders = true;
            WriteStatusLine = true;

            Headers = new HttpHeaders ();
            Stream = new HttpResponseStream ();
            Cookies = new Dictionary<string, HttpCookie> ();

            SetStandardHeaders ();
        }
示例#4
0
        public HttpRequest(IHttpTransaction transaction, HttpHeaders headers, string method, string resource, bool support_1_1)
        {
            Transaction = transaction;
            Headers = headers;
            Method = method;
            ResourceUri = resource;
            Http_1_1_Supported = support_1_1;

            Data = new DataDictionary ();
            UriData = new DataDictionary ();
            QueryData = new DataDictionary ();
            PostData = new DataDictionary ();

            Data.Children.Add (UriData);
            Data.Children.Add (QueryData);
            Data.Children.Add (PostData);

            SetEncoding ();
            SetPathAndQuery ();
        }
示例#5
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);
        }
示例#6
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);
        }