Beispiel #1
0
        public string ProcessHeaders()
        {
            StringBuilder headerBuilder = new StringBuilder();

            headerBuilder.Append(ProtocolVersion.ToVersionString());
            headerBuilder.Append(' ');
            headerBuilder.Append(Status.ToStatusString());
            headerBuilder.Append(HeaderSeparator);

            foreach (KeyValuePair <string, string> header in Headers)
            {
                string key   = header.Key;
                string value = header.Value;

                if (key == HeaderNames.ContentLength && Status == HttpStatus.NoContent)
                {
                    value = "0";
                }

                headerBuilder.Append(key);
                headerBuilder.Append(": ");
                headerBuilder.Append(value);
                headerBuilder.Append(HeaderSeparator);
            }

            headerBuilder.Append(HeaderSeparator);

            return(headerBuilder.ToString());
        }