ClassBasePipe
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.
Definition
Namespace:Fiddler
Assembly:FiddlerCore.dll
Syntax:
public abstract class BasePipe
Inheritance: objectBasePipe
Derived Classes:
Inherited Members
Constructors
BasePipe(Socket, string)
Create a new pipe, an enhanced wrapper around a socket
Fields
SendLock
Used to ensure that send operations on the pipe are queued
_baseSocket
The base socket wrapped in this pipe
_httpsStream
The HTTPS stream wrapped around the base socket (SslStream on Windows/Linux or BcTlsConnection.AuthenticatedStream on MacOS)
_sPipeName
The display name of this Pipe. Use strings starting with "ClientPipe" for client pipes and "ServerPipe" for server pipes.
clientPipeName
The name that should be used for client pipes
iUseCount
The number of times that this Pipe has been used
serverPipeName
The name that should be used for client pipes
Properties
Address
Returns the remote address to which this Pipe is connected, or 0.0.0.0 on error.
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.
IsHTTP2
Returns true if the SslStream's negotiated protocol is h2
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.
Port
Return the Remote Port to which this socket is attached.
SecureProtocol
Returns the SSL/TLS protocol securing this connection
Declaration
public SslProtocols SecureProtocol { get; }
Property Value
TransmitDelay
Gets or sets the transmission delay on this Pipe, used for performance simulation purposes.
bIsSecured
Returns a bool indicating if the socket in this Pipe is CURRENTLY connected and wrapped in a SecureStream
Methods
EndAsync(ErrorCode, string)
Shutdown and close the socket inside this pipe. Eats exceptions.
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
The Socket object this Pipe wraps.
HasDataAvailable()
Poll the underlying socket for readable data (or closure/errors)
Declaration
public virtual bool HasDataAvailable()
Returns
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.
SendAsync(byte[])
Sends a byte array through this pipe
SendDataAsync(byte[], int, int, uint, bool)
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
arrData
byte[]
Array to send
responseOffset
The data offset in the array to send
responseLength
How many bytes of the array to send
streamId
The stream ID - omitted for http/1.1 pipes
final
True if this is the final data(body) to send through the pipe - not used for http/1.1 pipes
Returns
The size of the transferred data over the network in bytes
SendRequestHeadersAsync(HTTPRequestHeaders, uint, bool, string, bool?)
Send HTTP request headers through the pipe with additional options
Declaration
public Task<int> SendRequestHeadersAsync(HTTPRequestHeaders headers, uint newStreamId, bool includeProtocolInPath, string sVerbLineHost, bool? hasBody)
Parameters
headers
request headers
newStreamId
the stream ID to use when sending HTTP2 headers
includeProtocolInPath
TRUE if the SCHEME and HOST should be included in the HTTP REQUEST LINE
sVerbLineHost
the host to use in the HTTP REQUEST LINE
hasBody
bool?
HTTP2 only - True if there is a body ready to send after the headers
Returns
The size of the transferred data over the network in bytes
SendResponseHeadersAsync(HTTPResponseHeaders, uint?, bool?, bool, bool)
Send HTTP headers through a pipe
Declaration
public Task<int> SendResponseHeadersAsync(HTTPResponseHeaders headers, uint? streamId, bool? hasBody, bool ignoreTranslationErrors = false, bool trailersOnly = false)
Parameters
headers
response headers
streamId
uint?
HTTP2 only - the stream ID
hasBody
bool?
HTTP2 only - True if there is a body ready to send after the headers
ignoreTranslationErrors
Ignore possible errors that occur if headers are translated from HTTP/1.1 to HTTP/2
trailersOnly
Set to true only if this is a GRPC response that does not have response headers (e.g. error response)
Returns
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
True if a custom stream should be used instead of the .NET SslStream for TLS connections.
Events
OnConnectionClosed
Raised when the connection is closed