A class that represents the model for an HTTP header.
示例#1
0
        /// <summary>
        ///     Converts an enumerable list of <see cref="T:Stumps.Server.HttpHeader"/> objects into an 
        ///     array of <see cref="T:Stumps.Web.Models.HeaderModel"/> objects.
        /// </summary>
        /// <param name="headers">The enumerable list of <see cref="T:Stumps.Server.HttpHeader"/> objects.</param>
        /// <returns>An array of <see cref="T:Stumps.Web.Models.HeaderModel"/> objects.</returns>
        private HeaderModel[] CreateHeaderModel(IHttpHeaders headers)
        {
            var headerList = new List<HeaderModel>();

            foreach (var header in headers.HeaderNames)
            {
                var headerModel = new HeaderModel
                {
                    Name = header,
                    Value = headers[header]
                };

                headerList.Add(headerModel);
            }

            return headerList.ToArray();
        }
示例#2
0
        private HeaderModel[] CreateHeadersFromRules(StumpContract contract)
        {
            var models = new List<HeaderModel>();

            var rules = contract.Rules.FindRuleContractByName(typeof(HeaderRule).Name);

            foreach (var rule in rules)
            {
                var headerRule = ContractBindings.CreateRuleFromContract<HeaderRule>(rule);

                var model = new HeaderModel
                {
                    Name = headerRule.HeaderNameTextMatch,
                    Value = headerRule.HeaderValueTextMatch
                };

                models.Add(model);
            }

            return models.ToArray();
        }
示例#3
0
        /// <summary>
        ///     Generates the HTTP headers used by a <see cref="T:Stumps.IStumpsHttpContextPart"/>.
        /// </summary>
        /// <param name="part">The <see cref="T:Stumps.IStumpsHttpContextPart"/> used to generate headers.</param>
        /// <returns>An array of <see cref="Stumps.Web.Models.HeaderModel"/> objects.</returns>
        private HeaderModel[] GenerateHeaderModels(IStumpsHttpContextPart part)
        {
            var modelList = new List<HeaderModel>();

            foreach (var headerName in part.Headers.HeaderNames)
            {
                var modelHeader = new HeaderModel
                {
                    Name = headerName,
                    Value = part.Headers[headerName]
                };

                modelList.Add(modelHeader);
            }

            return modelList.ToArray();
        }