Esempio n. 1
0
            static Http2ToHttpHeaderTranslator()
            {
                RequestHeaderTranslations  = new CharSequenceMap <AsciiString>();
                ResponseHeaderTranslations = new CharSequenceMap <AsciiString>();

                _ = ResponseHeaderTranslations.Add(PseudoHeaderName.Authority.Value, HttpHeaderNames.Host);
                _ = ResponseHeaderTranslations.Add(PseudoHeaderName.Scheme.Value, ExtensionHeaderNames.Scheme);
                _ = RequestHeaderTranslations.Add(ResponseHeaderTranslations);
                _ = ResponseHeaderTranslations.Add(PseudoHeaderName.Path.Value, ExtensionHeaderNames.Path);
            }
Esempio n. 2
0
        private static CharSequenceMap <AsciiString> ToLowercaseMap(IEnumerable <ICharSequence> values, int arraySizeHint)
        {
            var valueConverter = UnsupportedValueConverter <AsciiString> .Instance;
            var result         = new CharSequenceMap <AsciiString>(true, valueConverter, arraySizeHint);

            foreach (var item in values)
            {
                AsciiString lowerCased = AsciiString.Of(item).ToLowerCase();
                try
                {
                    int index = lowerCased.ForEachByte(ByteProcessor.FindComma);
                    if (index != -1)
                    {
                        int start = 0;
                        do
                        {
                            _     = result.Add(lowerCased.SubSequence(start, index, false).Trim(), AsciiString.Empty);
                            start = index + 1;
                        } while (start < lowerCased.Count &&
                                 (index = lowerCased.ForEachByte(start, lowerCased.Count - start, ByteProcessor.FindComma)) != -1);
                        _ = result.Add(lowerCased.SubSequence(start, lowerCased.Count, false).Trim(), AsciiString.Empty);
                    }
                    else
                    {
                        _ = result.Add(lowerCased.Trim(), AsciiString.Empty);
                    }
                }
                catch (Exception)
                {
                    // This is not expect to happen because FIND_COMMA never throws but must be caught
                    // because of the ByteProcessor interface.
                    ThrowHelper.ThrowInvalidOperationException();
                }
            }

            return(result);
        }
Esempio n. 3
0
        static PseudoHeaderName()
        {
            Method    = new PseudoHeaderName(":method", true);
            Scheme    = new PseudoHeaderName(":scheme", true);
            Authority = new PseudoHeaderName(":authority", true);
            Path      = new PseudoHeaderName(":path", true);
            Status    = new PseudoHeaderName(":status", false);
            All       = new PseudoHeaderName[] { Method, Scheme, Authority, Path, Status };

            PseudoHeaders = new CharSequenceMap <PseudoHeaderName>();
            foreach (PseudoHeaderName pseudoHeader in All)
            {
                _ = PseudoHeaders.Add(pseudoHeader._value, pseudoHeader);
            }
        }