// Compare to Http1Connection.OnStartLine protected override bool TryParseRequest(ReadResult result, out bool endConnection) { // We don't need any of the parameters because we don't implement BeginRead to actually // do the reading from a pipeline, nor do we use endConnection to report connection-level errors. endConnection = !TryValidatePseudoHeaders(); // Suppress pseudo headers from the public headers collection. HttpRequestHeaders.ClearPseudoRequestHeaders(); return(true); }
// Compare to Http1Connection.OnStartLine protected override bool TryParseRequest(ReadResult result, out bool endConnection) { // We don't need any of the parameters because we don't implement BeginRead to actually // do the reading from a pipeline, nor do we use endConnection to report connection-level errors. endConnection = !TryValidatePseudoHeaders(); // Suppress pseudo headers from the public headers collection. HttpRequestHeaders.ClearPseudoRequestHeaders(); // Cookies should be merged into a single string separated by "; " // https://datatracker.ietf.org/doc/html/rfc7540#section-8.1.2.5 HttpRequestHeaders.MergeCookies(); return(true); }
public void ClearPseudoRequestHeadersPlusResetClearsHeaderReferenceValue() { const BindingFlags privateFlags = BindingFlags.NonPublic | BindingFlags.Instance; HttpRequestHeaders headers = new HttpRequestHeaders(reuseHeaderValues: false); headers.HeaderMethod = "GET"; headers.ClearPseudoRequestHeaders(); headers.Reset(); // Hacky but required because header references is private. var headerReferences = typeof(HttpRequestHeaders).GetField("_headers", privateFlags).GetValue(headers); var methodValue = (StringValues)headerReferences.GetType().GetField("_Method").GetValue(headerReferences); Assert.Equal(StringValues.Empty, methodValue); }