| | | 1 | | // Licensed to the .NET Foundation under one or more agreements. |
| | | 2 | | // The .NET Foundation licenses this file to you under the MIT license. |
| | | 3 | | |
| | | 4 | | using System.Diagnostics.CodeAnalysis; |
| | | 5 | | using System.Diagnostics.Tracing; |
| | | 6 | | using System.IO; |
| | | 7 | | |
| | | 8 | | namespace System.Net.Http |
| | | 9 | | { |
| | | 10 | | /// <summary> |
| | | 11 | | /// Represents the context passed to the PlaintextStreamFilter for a SocketsHttpHandler instance. |
| | | 12 | | /// </summary> |
| | | 13 | | public sealed class SocketsHttpPlaintextStreamFilterContext |
| | | 14 | | { |
| | | 15 | | private readonly Stream _plaintextStream; |
| | | 16 | | private readonly Version _negotiatedHttpVersion; |
| | | 17 | | private readonly HttpRequestMessage _initialRequestMessage; |
| | | 18 | | private readonly long _connectionId; |
| | | 19 | | |
| | 0 | 20 | | internal SocketsHttpPlaintextStreamFilterContext(Stream plaintextStream, Version negotiatedHttpVersion, HttpRequ |
| | 0 | 21 | | { |
| | 0 | 22 | | _plaintextStream = plaintextStream; |
| | 0 | 23 | | _negotiatedHttpVersion = negotiatedHttpVersion; |
| | 0 | 24 | | _initialRequestMessage = initialRequestMessage; |
| | 0 | 25 | | _connectionId = connectionId; |
| | 0 | 26 | | } |
| | | 27 | | |
| | | 28 | | /// <summary> |
| | | 29 | | /// The plaintext Stream that will be used for HTTP protocol requests and responses. |
| | | 30 | | /// </summary> |
| | 0 | 31 | | public Stream PlaintextStream => _plaintextStream; |
| | | 32 | | |
| | | 33 | | /// <summary> |
| | | 34 | | /// The version of HTTP in use for this stream. |
| | | 35 | | /// </summary> |
| | 0 | 36 | | public Version NegotiatedHttpVersion => _negotiatedHttpVersion; |
| | | 37 | | |
| | | 38 | | /// <summary> |
| | | 39 | | /// The initial HttpRequestMessage that is causing the stream to be used. |
| | | 40 | | /// </summary> |
| | 0 | 41 | | public HttpRequestMessage InitialRequestMessage => _initialRequestMessage; |
| | | 42 | | |
| | | 43 | | /// <summary> |
| | | 44 | | /// The identifier of the connection whose stream is being filtered. This matches the connection id reported |
| | | 45 | | /// through <see cref="EventSource"/> telemetry for that connection. For a direct connection it also matches the |
| | | 46 | | /// <see cref="SocketsHttpConnectionContext.ConnectionId"/> surfaced to |
| | | 47 | | /// <see cref="SocketsHttpHandler.ConnectCallback"/>, the |
| | | 48 | | /// <see cref="SocketsHttpConnectionEvictionContext.ConnectionId"/> passed to |
| | | 49 | | /// <see cref="SocketsHttpHandler.ShouldEvictConnection"/>, and the <see cref="HttpRequestMessage.ConnectionId"/ |
| | | 50 | | /// stamped on requests sent over the connection. It can be used to associate caller state with the connection |
| | | 51 | | /// and to correlate it with the requests it serves. |
| | | 52 | | /// </summary> |
| | | 53 | | /// <remarks> |
| | | 54 | | /// For an HTTP CONNECT proxy tunnel the filter runs once per hop: on the CONNECT hop this is the transport |
| | | 55 | | /// connection's id (the one the <see cref="SocketsHttpHandler.ConnectCallback"/> observed), and on the |
| | | 56 | | /// tunneled hop it is the tunneled connection's id (the one passed to |
| | | 57 | | /// <see cref="SocketsHttpHandler.ShouldEvictConnection"/> and stamped on requests). |
| | | 58 | | /// </remarks> |
| | | 59 | | [Experimental(Experimentals.SocketsHttpHandlerExperimentalDiagId, UrlFormat = Experimentals.SharedUrlFormat)] |
| | 0 | 60 | | public long ConnectionId => _connectionId; |
| | | 61 | | } |
| | | 62 | | } |
| | | 63 | | |