private bool ParseStatusLine()
            {
                if (_bodyOnly)
                {
                    _version = Version.Http1_1;
                    _status  = Response.ResponseStatus.Ok;
                    NextStep();
                    return(false);
                }

                _continuation = false;
                var maybeLine = NextLine(false, "Response status line is required.");

                if (!maybeLine.IsPresent)
                {
                    return(true);
                }

                var line       = maybeLine.Get();
                var spaceIndex = line.IndexOf(' ');

                try
                {
                    _version = Version.From(line.Substring(0, spaceIndex).Trim());
                    _status  = line.Substring(spaceIndex + 1).Trim().ConvertToResponseStatus();

                    return(NextStep());
                }
                catch (Exception ex)
                {
                    throw new ArgumentException($"Response status line parsing exception:{ex.Message}", ex);
                }
            }
Exemple #2
0
 private ObjectResponse(Version version,
                        Response.ResponseStatus status,
                        Headers <ResponseHeader> headers,
                        T entity)
 {
     _version = version;
     _status  = status;
     _headers = headers;
     _entity  = entity;
 }
Exemple #3
0
            private void Reset()
            {
                // DO NOT RESET: (1) contentQueue, (2) position, (3) responseText, (4) headers, (5) fullResponses

                _body             = null;
                _contentLength    = 0;
                _continuation     = false;
                _outOfContentTime = DateTime.MinValue;
                _status           = 0;
                _version          = null;
            }
Exemple #4
0
            private void ParseStatusLine()
            {
                _continuation = false;
                var line       = NextLine(false, "Response status line is required.");
                var spaceIndex = line.IndexOf(' ');

                try
                {
                    _version = Version.From(line.Substring(0, spaceIndex).Trim());
                    _status  = line.Substring(spaceIndex + 1).Trim().ConvertToResponseStatus();

                    NextStep();
                }
                catch (Exception ex)
                {
                    throw new ArgumentException($"Response status line parsing exception:{ex.Message}", ex);
                }
            }
Exemple #5
0
        public static string GetDescription(this Response.ResponseStatus status)
        {
            var type       = typeof(Response.ResponseStatus);
            var memberInfo = type.GetMember(status.ToString());

            if (memberInfo != null && memberInfo.Length > 0)
            {
                object[] attrs = memberInfo[0].GetCustomAttributes(typeof(DescriptionAttribute), false);

                if (attrs != null && attrs.Length > 0)
                {
                    //Pull out the description value
                    return(((DescriptionAttribute)attrs[0]).Description);
                }
            }
            //If we have no description attribute, just return the ToString of the enum
            return(status.ToString());
        }
Exemple #6
0
 public static IObjectResponse Of <TR>(
     Response.ResponseStatus status,
     TR entity)
 => new ObjectResponse <TR>(Version.Http1_1, status, Headers.Empty <ResponseHeader>(), entity);
Exemple #7
0
 public static IObjectResponse Of <TR>(
     Version version,
     Response.ResponseStatus status,
     Headers <ResponseHeader> headers,
     TR entity)
 => new ObjectResponse <TR>(version, status, headers, entity);
Exemple #8
0
 public static IErrorHandler HandleAllWith(Response.ResponseStatus status)
 => new ErrorHandlerImpl(err => Response.Of(status));