Class BasePipe
Abstract base class for the ClientPipe and ServerPipe classes. A Pipe represents a connection to either the client or the server, optionally encrypted using SSL/TLS.
Inheritance
Namespace: Fiddler
Assembly: FiddlerCore.dll
Syntax
public abstract class BasePipe : Object
Constructors
BasePipe(Socket, String)
Create a new pipe, an enhanced wrapper around a socket
Declaration
public BasePipe(Socket oSocket, string sName)
Parameters
System. Socket which this pipe wraps |
System. Identification string used for debugging purposes |
Fields
_baseSocket
The base socket wrapped in this pipe
Declaration
protected Socket _baseSocket
Field Value
System.
|
_httpsStream
The HTTPS stream wrapped around the base socket (SslStream on Windows/Linux or BcTlsConnection.AuthenticatedStream on MacOS)
Declaration
protected Stream _httpsStream
Field Value
System.
|
_sPipeName
The display name of this Pipe. Use strings starting with "ClientPipe" for client pipes and "ServerPipe" for server pipes.
Declaration
protected string _sPipeName
Field Value
System.
|
clientPipeName
The name that should be used for client pipes
Declaration
public const string clientPipeName = "ClientPipe"
Field Value
System.
|
iUseCount
The number of times that this Pipe has been used
Declaration
protected uint iUseCount
Field Value
System.
|
SendLock
Used to ensure that send operations on the pipe are queued
Declaration
protected readonly SemaphoreSlim SendLock
Field Value
System.
|
serverPipeName
The name that should be used for client pipes
Declaration
public const string serverPipeName = "ServerPipe"
Field Value
System.
|
Properties
Address
Returns the remote address to which this Pipe is connected, or 0.0.0.0 on error.
Declaration
public IPAddress Address { get; }
Property Value
System.
|
bIsSecured
Returns a bool indicating if the socket in this Pipe is CURRENTLY connected and wrapped in a SecureStream
Declaration
public bool bIsSecured { get; }
Property Value
System.
|
Connected
Return the Connected status of the base socket. WARNING: This doesn't work as you might expect; you can see Connected == false when a READ timed out but a WRITE will succeed.
Declaration
public bool Connected { get; }
Property Value
System.
|
IsHTTP2
Returns true if the SslStream's negotiated protocol is h2
Declaration
public bool IsHTTP2 { get; }
Property Value
System.
|
LocalPort
Return the Local Port to which the base socket is attached. Note: May return a misleading port if the ISA Firewall Client is in use.
Declaration
public int LocalPort { get; }
Property Value
System.
|
Port
Return the Remote Port to which this socket is attached.
Declaration
public int Port { get; }
Property Value
System.
|
SecureProtocol
Returns the SSL/TLS protocol securing this connection
Declaration
public SslProtocols SecureProtocol { get; }
Property Value
System.
|
TransmitDelay
Gets or sets the transmission delay on this Pipe, used for performance simulation purposes.
Declaration
public int TransmitDelay { get; set; }
Property Value
System.
|
Methods
EndAsync(ErrorCode, String)
Shutdown and close the socket inside this pipe. Eats exceptions.
Declaration
public Task EndAsync(ErrorCode errorCode, string debugData = "")
Parameters
Http2.
|
System.
|
Returns
System.
|
EndWithRST()
Abruptly closes the socket by sending a RST packet
Declaration
public void EndWithRST()
GetRawSocket()
Return the raw socket this pipe wraps. Avoid calling this method if at all possible.
Declaration
public Socket GetRawSocket()
Returns
System. The Socket object this Pipe wraps. |
HasDataAvailable()
Poll the underlying socket for readable data (or closure/errors)
Declaration
public virtual bool HasDataAvailable()
Returns
System. TRUE if this Pipe requires attention |
InitializeHTTP2PipeAsync()
HTTP2 connections must be initialized by receiving and sending specific headers and settings frames. This happens only once per established connection.
Declaration
public Task InitializeHTTP2PipeAsync()
Returns
System.
|
SendAsync(Byte[])
Sends a byte array through this pipe
Declaration
public Task SendAsync(byte[] oBytes)
Parameters
System. The bytes |
Returns
System.
|
SendDataAsync(Byte[], Int32, Int32, UInt32, Boolean)
Send a byte array through this pipe, taking into account the protocol used (http/1.1 or http/2)
Declaration
public Task<int> SendDataAsync(byte[] arrData, int responseOffset, int responseLength, uint streamId, bool final = true)
Parameters
System. Array to send |
System. The data offset in the array to send |
System. How many bytes of the array to send |
System. The stream ID - omitted for http/1.1 pipes |
System. True if this is the final data(body) to send through the pipe - not used for http/1.1 pipes |
Returns
System. The size of the transferred data over the network in bytes |
SendRequestHeadersAsync(HTTPRequestHeaders, UInt32, Boolean, String, Nullable<Boolean>)
Send HTTP request headers through the pipe with additional options
Declaration
public Task<int> SendRequestHeadersAsync(HTTPRequestHeaders headers, uint newStreamId, bool includeProtocolInPath, string sVerbLineHost, Nullable<bool> hasBody)
Parameters
HTTPRequest request headers |
System. the stream ID to use when sending HTTP2 headers |
System. TRUE if the SCHEME and HOST should be included in the HTTP REQUEST LINE |
System. the host to use in the HTTP REQUEST LINE |
System. HTTP2 only - True if there is a body ready to send after the headers |
Returns
System. The size of the transferred data over the network in bytes |
SendResponseHeadersAsync(HTTPResponseHeaders, Nullable<UInt32>, Nullable<Boolean>, Boolean, Boolean)
Send HTTP headers through a pipe
Declaration
public Task<int> SendResponseHeadersAsync(HTTPResponseHeaders headers, Nullable<uint> streamId, Nullable<bool> hasBody, bool ignoreTranslationErrors = false, bool trailersOnly = false)
Parameters
HTTPResponse response headers |
System. HTTP2 only - the stream ID |
System. HTTP2 only - True if there is a body ready to send after the headers |
System. Ignore possible errors that occur if headers are translated from HTTP/1.1 to HTTP/2 |
System. Set to true only if this is a GRPC response that does not have response headers (e.g. error response) |
Returns
System. The size of the transferred data over the network in bytes |
UseCustomTlsProvider()
On Mac OS a SslStream cannot authenticate as a TLS server, so we need to use another TLS stream implementation. On Mac OS, SslStream does not support TLS 1.3 as client, so we need to use another TLS stream implementation.
Declaration
protected bool UseCustomTlsProvider()
Returns
System. True if a custom stream should be used instead of the .NET SslStream for TLS connections. |
Events
OnConnectionClosed
Raised when the connection is closed
Declaration
public event EventHandler OnConnectionClosed
Event Type
System.
|