Beispiel #1
0
        /// <summary>
        /// Translate and add HTTP/2 headers to HTTP/1.x headers.
        /// </summary>
        /// <param name="streamId">The stream associated with <paramref name="outputHeaders"/>.</param>
        /// <param name="inputHeaders">The HTTP/2 headers to convert.</param>
        /// <param name="outputHeaders">The object which will contain the resulting HTTP/1.x headers..</param>
        /// <param name="httpVersion">What HTTP/1.x version <paramref name="outputHeaders"/> should be treated as when doing the conversion.</param>
        /// <param name="isTrailer"><c>true</c> if <paramref name="outputHeaders"/> should be treated as trailing headers.
        /// <c>false</c> otherwise.</param>
        /// <param name="isRequest"><c>true</c> if the <paramref name="outputHeaders"/> will be used in a request message.
        /// <c>false</c> for response message.</param>
        /// <exception cref="Http2Exception">If not all HTTP/2 headers can be translated to HTTP/1.x.</exception>
        public static void AddHttp2ToHttpHeaders(int streamId, IHttp2Headers inputHeaders, HttpHeaders outputHeaders,
                                                 DotNettyHttpVersion httpVersion, bool isTrailer, bool isRequest)
        {
            Http2ToHttpHeaderTranslator translator = new Http2ToHttpHeaderTranslator(streamId, outputHeaders, isRequest);

            try
            {
                translator.TranslateHeaders(inputHeaders);
            }
            catch (Http2Exception)
            {
                throw;
            }
            catch (Exception t)
            {
                ThrowHelper.ThrowStreamError_Http2ToHttp1HeadersConversionError(streamId, t);
            }

            _ = outputHeaders.Remove(HttpHeaderNames.TransferEncoding);
            _ = outputHeaders.Remove(HttpHeaderNames.Trailer);
            if (!isTrailer)
            {
                _ = outputHeaders.SetInt(ExtensionHeaderNames.StreamId, streamId);
                HttpUtil.SetKeepAlive(outputHeaders, httpVersion, true);
            }
        }
Beispiel #2
0
 public DefaultHttpRequest(HttpVersion httpVersion, HttpMethod method, string uri)
     : this(httpVersion, method, uri, true)
 {
 }
Beispiel #3
0
 public DefaultFullHttpRequest(HttpVersion httpVersion, HttpMethod method, string uri, bool validateHeaders)
     : this(httpVersion, method, uri, ArrayPooled.Buffer(0), validateHeaders)
 {
 }
Beispiel #4
0
 public DefaultFullHttpRequest(HttpVersion httpVersion, HttpMethod method, string uri, IByteBuffer content)
     : this(httpVersion, method, uri, content, true)
 {
 }
Beispiel #5
0
 public DefaultFullHttpRequest(HttpVersion httpVersion, HttpMethod method, string uri)
     : this(httpVersion, method, uri, ArrayPooled.Buffer(0), true)
 {
 }
 public IHttpMessage SetProtocolVersion(HttpVersion value)
 {
     Contract.Requires(value != null);
     this.version = value;
     return(this);
 }
Beispiel #7
0
 protected sealed override IHttpMessage CreateMessage(AsciiString[] initialLine) =>
 new DefaultHttpResponse(
     HttpVersion.ValueOf(initialLine[0]),
     HttpResponseStatus.ValueOf(initialLine[1].ParseInt(), initialLine[2]), this.ValidateHeaders);
 protected DefaultHttpMessage(HttpVersion version) : this(version, true, false)
 {
 }
 public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status,
                                IByteBuffer content, bool validateHeaders)
     : this(version, status, content, validateHeaders, false)
 {
 }
Beispiel #10
0
 protected sealed override IHttpMessage CreateMessage(AsciiString[] initialLine) =>
 new DefaultHttpRequest(
     HttpVersion.ValueOf(initialLine[2]),
     HttpMethod.ValueOf(initialLine[0]), initialLine[1].ToString(), this.ValidateHeaders);
 public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, bool validateHeaders,
                                bool singleFieldHeaders)
     : this(version, status, ArrayPooled.Buffer(0), validateHeaders, singleFieldHeaders)
 {
 }
 public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, IByteBuffer content)
     : this(version, status, content, true, false)
 {
 }
 public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status)
     : this(version, status, ArrayPooled.Buffer(0), true, false)
 {
 }
 public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status, bool validateHeaders)
     : this(version, status, Unpooled.Buffer(0), validateHeaders, false)
 {
 }
 public DefaultFullHttpResponse(HttpVersion version, HttpResponseStatus status)
     : this(version, status, Unpooled.Buffer(0))
 {
 }