コード例 #1
0
ファイル: ResponseProvider.cs プロジェクト: Tectonik/ExamS
        public HttpResponse GetResponse(string requestAsString)
        {
            HttpRequest request;
            string[] temp = requestAsString.Split(' ');
            try
            {
                var requestParser = new HttpRequest(temp[0], temp[1], temp[2]);
                request = requestParser.Parse(requestAsString, new HttpRequest(null, null, null));
            }
            catch (Exception ex)
            {
                return new HttpResponse(new Version(1, 1), HttpStatusCode.BadRequest, ex.Message);
            }

            HttpResponse response = this.Process(request);
            return response;
        }
コード例 #2
0
        public HttpResponse GetResponse(string requestAsString)
        {
            HttpRequest request;

            try
            {
                var requestParser = new HttpRequest("GET", "/", "1.1");
                request = requestParser.Parse(requestAsString);
            }
            catch (Exception ex)
            {
                return(new HttpResponse(new Version(1, 1), HttpStatusCode.BadRequest, ex.Message));
            }

            var response = this.Process(request);

            return(response);
        }
コード例 #3
0
        public HttpResponse GetResponse(string requestAsString)
        {
            HttpRequest request;
            try
            {
                var requestParts = requestAsString.Split(new[] { ' ', '\r', '\n' });

                var requestParser = new HttpRequest(requestParts[0], requestParts[1], requestParts[2]);
                request = requestParser.Parse(requestAsString);
            }
            catch (Exception ex)
            {
                return new HttpResponse(new Version(1, 1), HttpStatusCode.BadRequest, ex.Message);
            }

            var response = this.Process(request);
            return response;
        }
コード例 #4
0
        public HttpResponse GetResponse(string requestAsString)
        {
            HttpRequest request;

            try
            {
                var requestParser = new HttpRequest("GET", "/", "1.1");
                request = requestParser.Parse(requestAsString);
            }
            catch (Exception ex)
            {
                return new HttpResponse(new Version(1, 1), HttpStatusCode.BadRequest, ex.Message);
            }

            var response = this.Process(request);

            return response;
        }
コード例 #5
0
        public HttpResponse GetResponse(string requestAsString)
        {
            HttpRequest request;

            try
            {
                var requestParser = new HttpRequest();
                request = requestParser.Parse(requestAsString);
            }
            catch (NullReferenceException)
            {
                return(new HttpResponse(new Version(1, 1), HttpStatusCode.NotImplemented, "Request cannot be handled."));
            }
            catch (Exception ex)
            {
                return(new HttpResponse(new Version(1, 1), HttpStatusCode.BadRequest, ex.Message));
            }

            var response = this.Process(request);

            return(response);
        }