Class
Session

The Session object manages the complete HTTP session including the UI listitem, the ServerChatter, and the ClientChatter.

Definition

Namespace:Fiddler

Assembly:FiddlerCore.dll

Syntax:

cs-api-definition
public class Session

Inheritance: objectSession

Inherited Members object.GetType()object.MemberwiseClone()object.Equals(object)object.Equals(object, object)object.ReferenceEquals(object, object)object.GetHashCode()

Constructors

Session(HTTPRequestHeaders, byte[], bool)

Initialize a new session from a given request headers and body request builder data. Note: No Session ID is assigned here.

Declaration

cs-api-definition
public Session(HTTPRequestHeaders oRequestHeaders, byte[] arrRequestBody, bool skipNewSessionEvent = false)

Parameters

oRequestHeaders

HTTPRequestHeaders

NB: If you're copying an existing request, use oRequestHeaders.Clone()

arrRequestBody

byte[]

The bytes of the request's body

skipNewSessionEvent

bool

If True, the 'Session.SessionCreated' event will not be raised for the new session.

Session(Session)

Declaration

cs-api-definition
public Session(Session toDeepCopy)

Parameters

toDeepCopy

Session

Session to clone into a new Session instance

Session(byte[], byte[], SessionFlags, bool)

Create a Session object from two byte[] representing request and response. This is used when loading a Session Archive Zip.

Declaration

cs-api-definition
public Session(byte[] arrRequest, byte[] arrResponse, SessionFlags oSF, bool skipNewSessionEvent)

Parameters

arrRequest

byte[]

The client data bytes

arrResponse

byte[]

The server data bytes

oSF

SessionFlags

SessionFlags for this session

skipNewSessionEvent

bool

Specifies if the Session.SessionCreated event should be raised of not.

Session(byte[], byte[], bool)

Create a Session object from two byte[] representing request and response.

Declaration

cs-api-definition
public Session(byte[] arrRequest, byte[] arrResponse, bool skipNewSessionEvent = false)

Parameters

arrRequest

byte[]

The client data bytes

arrResponse

byte[]

The server data bytes

skipNewSessionEvent

bool

Specifies if the Session.SessionCreated event should be raised of not.

Fields

Metrics

Metrics for timings and sizes stored as this Session progresses

Declaration

cs-api-definition
public SessionMetrics Metrics

Field Value

SessionMetrics

ViewItem

Not used in Fiddler Core - holds the list view item object in Fiddler Classic

Declaration

cs-api-definition
public object ViewItem

Field Value

object

__oTunnel

Used if the Session is bound to a WebSocket or CONNECTTunnel

Declaration

cs-api-definition
public ITunnel __oTunnel

Field Value

ITunnel

bBufferResponse

Should response be buffered for tampering.

Declaration

cs-api-definition
public bool bBufferResponse

Field Value

bool

Remarks

ARCH: This should have been a property instead of a field, so we could throw an InvalidStateException if code tries to manipulate this value after the response has begun

m_clientIP

IP Address of the client for this session.

Declaration

cs-api-definition
[CodeDescription("IP Address of the client for this session.")]
public string m_clientIP

Field Value

string

m_clientPort

Client port attached to Fiddler.

Declaration

cs-api-definition
[CodeDescription("Client port attached to Fiddler.")]
public int m_clientPort

Field Value

int

m_hostIP

IP Address of the server for this session.

Declaration

cs-api-definition
[CodeDescription("IP Address of the server for this session.")]
public string m_hostIP

Field Value

string

oFlags

Fiddler-internal flags set on the Session.

Declaration

cs-api-definition
[CodeDescription("Fiddler-internal flags set on the session.")]
public readonly StringDictionary oFlags

Field Value

StringDictionary

Remarks

TODO: ARCH: This shouldn't be exposed directly; it should be wrapped by a ReaderWriterLockSlim to prevent exceptions while enumerating the flags for storage, etc

oRequest

Object representing the HTTP Request.

Declaration

cs-api-definition
[CodeDescription("Object representing the HTTP Request.")]
public ClientChatter oRequest

Field Value

ClientChatter

requestBodyBytes

Contains the bytes of the request body.

Declaration

cs-api-definition
[CodeDescription("Contains the bytes of the request body.")]
public byte[] requestBodyBytes

Field Value

byte[]

responseBodyBytes

Contains the bytes of the response body.

Declaration

cs-api-definition
[CodeDescription("Contains the bytes of the response body.")]
public byte[] responseBodyBytes

Field Value

byte[]

Properties

BitFlags

Bitflags of commonly-queried session attributes

Declaration

cs-api-definition
public SessionFlags BitFlags { get; }

Property Value

SessionFlags

CertificateChainErrors

Stores a list of errors for each Element of the Certificate Chain First element in the list is the Server certificate and each following element follows the certificate chain (the last element should be the CA certificate)

Declaration

cs-api-definition
public List<List<X509ChainStatus>> CertificateChainErrors { get; set; }

Property Value

List<List<X509ChainStatus>>

ConnectedState

Connection state of the current session

Declaration

cs-api-definition
[CodeDescription("Connection state of the current session.")]
public SessionConnectedState ConnectedState { get; }

Property Value

SessionConnectedState

FormattedClientSslVersion

Returns the formatted SSL Version between Fiddler and the client.

Declaration

cs-api-definition
[CodeDescription("Returns the formatted SSL Version between Fiddler and the client.")]
public string FormattedClientSslVersion { get; }

Property Value

string

FormattedServerSslVersion

Returns the formatted SSL Version between Fiddler and the server.

Declaration

cs-api-definition
[CodeDescription("Returns the formatted SSL Version between Fiddler and the server.")]
public string FormattedServerSslVersion { get; }

Property Value

string

FormattedSslVersion

Returns the formatted SSL Version

Declaration

cs-api-definition
[CodeDescription("Returns the formatted SSL Version")]
public string FormattedSslVersion { get; }

Property Value

string

IsWebSocketSession

Returns TRUE if the session request or response contains a websocket upgrade header

Declaration

cs-api-definition
public bool IsWebSocketSession { get; }

Property Value

bool

LocalProcess

Get the Process Info of the application which made this request, or String.Empty if it is not known

Declaration

cs-api-definition
[CodeDescription("Get the Process Info the application which made this request, or String.Empty if it cannot be determined.")]
public string LocalProcess { get; }

Property Value

string

LocalProcessID

Get the process ID of the application which made this request, or 0 if it cannot be determined.

Declaration

cs-api-definition
[CodeDescription("Get the process ID of the application which made this request, or 0 if it cannot be determined.")]
public int LocalProcessID { get; }

Property Value

int

PathAndQuery

Returns the path and query part of the URL. (For a CONNECT request, returns the host:port to be connected.)

Declaration

cs-api-definition
[CodeDescription("Returns the path and query part of the URL. (For a CONNECT request, returns the host:port to be connected.)")]
public string PathAndQuery { get; set; }

Property Value

string

RemoteDeviceId

Extracts the remote device identifier from URL or host name

Declaration

cs-api-definition
public string RemoteDeviceId { get; }

Property Value

string

RequestBody

Gets or Sets the HTTP Request body bytes. Setter adjusts Content-Length header, and removes Transfer-Encoding and Content-Encoding headers. Setter DOES NOT CLONE the passed array. Setter will throw if the Request object does not exist for some reason. Use utilSetRequestBody(sStr) to ensure proper character encoding if you need to use a string.

Declaration

cs-api-definition
[CodeDescription("Gets or Sets the Request body bytes; Setter fixes up headers.")]
public byte[] RequestBody { get; set; }

Property Value

byte[]

RequestHeaders

Gets Request Headers, or empty headers if headers do not exist

Declaration

cs-api-definition
[CodeDescription("Gets Request Headers, or empty headers if headers do not exist")]
public HTTPRequestHeaders RequestHeaders { get; }

Property Value

HTTPRequestHeaders

RequestHeadersFlat

Gets Request Headers including pseudo headers, or empty headers if headers do not exist

Declaration

cs-api-definition
[CodeDescription("Gets Request Headers including pseudo headers, or empty headers if headers do not exist")]
public List<HTTPHeaderItem> RequestHeadersFlat { get; }

Property Value

List<HTTPHeaderItem>

RequestMethod

Gets or Sets the request's Method (e.g. GET, POST, etc).

Declaration

cs-api-definition
[CodeDescription("Gets or Sets the request's Method (e.g. GET, POST, etc).")]
public string RequestMethod { get; set; }

Property Value

string

ResponseBody

Gets or Sets the HTTP Response body bytes. Setter adjusts Content-Length header, and removes Transfer-Encoding and Content-Encoding headers. Setter DOES NOT CLONE the passed array. Setter will throw if the Response object has not yet been created. (See utilCreateResponseAndBypassServer) Use utilSetResponseBody(sStr) to ensure proper character encoding if you need to use a string.

Declaration

cs-api-definition
[CodeDescription("Gets or Sets the Response body bytes; Setter fixes up headers.")]
public byte[] ResponseBody { get; set; }

Property Value

byte[]

ResponseHeaders

Gets Response Headers, or empty headers if headers do not exist

Declaration

cs-api-definition
[CodeDescription("Gets Response Headers, or empty headers if headers do not exist")]
public HTTPResponseHeaders ResponseHeaders { get; }

Property Value

HTTPResponseHeaders

ResponseHeadersFlat

Gets Response Headers including pseudo headers, or empty headers if headers do not exist

Declaration

cs-api-definition
[CodeDescription("Gets Response Headers including pseudo headers, or empty headers if headers do not exist")]
public List<HTTPHeaderItem> ResponseHeadersFlat { get; }

Property Value

List<HTTPHeaderItem>

ResponseTrailers

Gets Response Trailers, or empty headers if trailers do not exist

Declaration

cs-api-definition
[CodeDescription("Gets Response Trailers, or empty headers if trailers do not exist")]
public HTTPResponseHeaders ResponseTrailers { get; }

Property Value

HTTPResponseHeaders

SuggestedFilename

Gets a path-less filename suitable for saving the Response entity. Uses Content-Disposition if available.

Declaration

cs-api-definition
[CodeDescription("Gets a path-less filename suitable for saving the Response entity. Uses Content-Disposition if available.")]
public string SuggestedFilename { get; }

Property Value

string

Tag

A common use for the Tag property is to store data that is closely associated with the Session. It is NOT marshalled during drag/drop and is NOT serialized to a SAZ file.

Declaration

cs-api-definition
public object Tag { get; set; }

Property Value

object

TunnelEgressByteCount

If this session is a Tunnel, returns number of bytes sent from the Client to the Server

Declaration

cs-api-definition
public long TunnelEgressByteCount { get; }

Property Value

long

TunnelIngressByteCount

If this session is a Tunnel, returns number of bytes sent from the Server to the Client

Declaration

cs-api-definition
public long TunnelIngressByteCount { get; }

Property Value

long

TunnelIsOpen

If this session is a Tunnel, and the tunnel's IsOpen property is TRUE, returns TRUE. Otherwise returns FALSE.

Declaration

cs-api-definition
public bool TunnelIsOpen { get; }

Property Value

bool

UiSharedId

The ID, which will be displayed in the UI

Declaration

cs-api-definition
public int UiSharedId { get; set; }

Property Value

int

bHasGRPCMessages

Checks whether this is a GRPCTunnel, and if so, whether it has logged any parsed messages.

Declaration

cs-api-definition
public bool bHasGRPCMessages { get; }

Property Value

bool

bHasResponse

Returns TRUE if this session's State > ReadingResponse, and oResponse, oResponse.headers, and responseBodyBytes are all non-null. Note that bHasResponse returns FALSE if the session is currently reading, even if a body was copied using the COMETPeek feature

Declaration

cs-api-definition
[CodeDescription("Returns TRUE if this session state>ReadingResponse and oResponse not null.")]
public bool bHasResponse { get; }

Property Value

bool

bHasWebSocketMessages

Checks whether this is a WebSocket, and if so, whether it has logged any parsed messages.

Declaration

cs-api-definition
public bool bHasWebSocketMessages { get; }

Property Value

bool

bypassGateway

Set to true in OnBeforeRequest if this request should bypass the gateway

Declaration

cs-api-definition
[CodeDescription("Set to true in OnBeforeRequest if this request should bypass the gateway")]
public bool bypassGateway { get; set; }

Property Value

bool

clientIP

Returns the Address used by the client to communicate to Fiddler.

Declaration

cs-api-definition
[CodeDescription("Returns the Address used by the client to communicate to Fiddler.")]
public string clientIP { get; }

Property Value

string

clientPort

Returns the port used by the client to communicate to Fiddler.

Declaration

cs-api-definition
[CodeDescription("Returns the port used by the client to communicate to Fiddler.")]
public int clientPort { get; }

Property Value

int

fullUrl

Retrieves the complete URI, including protocol/scheme, in the form http://www.host.com/filepath?query. Or sets the complete URI, adjusting the UriScheme and/or Host.

Declaration

cs-api-definition
[CodeDescription("Retrieves the complete URI, including protocol/scheme, in the form http://www.host.com/filepath?query.")]
public string fullUrl { get; set; }

Property Value

string

host

DNS Name of the host server targeted by this request. May include IPv6 literal brackets. NB: a port# may be included.

Declaration

cs-api-definition
[CodeDescription("Gets/Sets the host to which this request is targeted. MAY include IPv6 literal brackets. MAY include a trailing port#.")]
public string host { get; set; }

Property Value

string

hostname

DNS Name of the host server (no port) targeted by this request. Will include IPv6-literal brackets for IPv6-literal addresses

Declaration

cs-api-definition
[CodeDescription("Gets/Sets the hostname to which this request is targeted; does NOT include any port# but will include IPv6-literal brackets for IPv6 literals.")]
public string hostname { get; set; }

Property Value

string

id

Returns the sequential number of this session. Note, by default numbering is restarted at zero when the session list is cleared.

Declaration

cs-api-definition
[CodeDescription("Returns the sequential number of this request.")]
public int id { get; }

Property Value

int

isFTP

When true, this session was conducted using the FTP protocol.

Declaration

cs-api-definition
[CodeDescription("When true, this session was conducted using the FTP protocol.")]
public bool isFTP { get; }

Property Value

bool

isHTTP2

When true, this session was conducted using the HTTP2 protocol.

Declaration

cs-api-definition
[CodeDescription("When true, this session was conducted using the HTTP2 protocol.")]
public bool isHTTP2 { get; }

Property Value

bool

isHTTPS

When true, this session was conducted using the HTTPS protocol.

Declaration

cs-api-definition
[CodeDescription("When true, this session was conducted using the HTTPS protocol.")]
public bool isHTTPS { get; }

Property Value

bool

isTunnel

Returns True if this is a HTTP CONNECT tunnel.

Declaration

cs-api-definition
public bool isTunnel { get; }

Property Value

bool

oResponse

Object representing the HTTP Response.

Declaration

cs-api-definition
[CodeDescription("Object representing the HTTP Response.")]
public ServerChatter oResponse { get; set; }

Property Value

ServerChatter

port

Returns the server port to which this request is targeted.

Declaration

cs-api-definition
[CodeDescription("Returns the server port to which this request is targeted.")]
public int port { get; set; }

Property Value

int

responseCode

Gets or Sets the HTTP Status code of the server's response

Declaration

cs-api-definition
[CodeDescription("Gets or Sets the HTTP Status code of the server's response")]
public int responseCode { get; set; }

Property Value

int

state

State of session. Note Side-Effects: If setting to .Aborted, calls FinishUISession. If setting to/from a Tamper state, calls RefreshMyInspectors

Declaration

cs-api-definition
[CodeDescription("Enumerated state of the current session.")]
public SessionStates state { get; set; }

Property Value

SessionStates

this[string, string]

Indexer property into SESSION flags, REQUEST headers, and RESPONSE headers. e.g. oSession["Request", "Host"] returns string value for the Request host header. If null, returns String.Empty

Declaration

cs-api-definition
[CodeDescription("Indexer property into SESSION flags, REQUEST headers, and RESPONSE headers. e.g. oSession[\"Request\", \"Host\"] returns string value for the Request host header. If null, returns String.Empty")]
public string this[string sCollection, string sName] { get; }

Parameters

sCollection

string

SESSION, REQUEST or RESPONSE

sName

string

The name of the flag or header

Property Value

string

String value or String.Empty

this[string]

Simple indexer into the Session's oFlags object; returns null if flag is not present.

Declaration

cs-api-definition
[CodeDescription("Indexer property into session flags collection. oSession[\"Flagname\"] returns string value (or null if missing!).")]
public string this[string sFlag] { get; set; }

Parameters

sFlag

string

Property Value

string

Returns the string value if the specified flag is present, or null if it is not.

url

Gets or sets the URL (without protocol) being requested from the server, in the form www.host.com/filepath?query.

Declaration

cs-api-definition
[CodeDescription("Gets or sets the URL (without protocol) being requested from the server, in the form www.host.com/filepath?query.")]
public string url { get; set; }

Property Value

string

Methods

AbortAsync()

Closes both client and server pipes and moves state to Aborted; unpauses thread if paused.

Declaration

cs-api-definition
public Task AbortAsync()

Returns

Task

BuildFromData(bool, HTTPRequestHeaders, byte[], HTTPResponseHeaders, byte[], SessionFlags)

Factory constructor

Declaration

cs-api-definition
public static Session BuildFromData(bool bClone, HTTPRequestHeaders headersRequest, byte[] arrRequestBody, HTTPResponseHeaders headersResponse, byte[] arrResponseBody, SessionFlags oSF)

Parameters

bClone

bool

headersRequest

HTTPRequestHeaders

arrRequestBody

byte[]

headersResponse

HTTPResponseHeaders

arrResponseBody

byte[]

oSF

SessionFlags

Returns

Session

COMETPeek()

Call this function while in the "reading response" state to update the responseBodyBytes array with the partially read response.

Declaration

cs-api-definition
public bool COMETPeek()

Returns

bool

TRUE if the peek succeeded; FALSE if not in the ReadingResponse state

GetRedirectTargetURL()

Returns the fully-qualified URL to which this Session's response points, or null. This method is needed because many servers (illegally) return a relative url in HTTP/3xx Location response headers.

Declaration

cs-api-definition
public string GetRedirectTargetURL()

Returns

string

null, or Target URL. Note, you may want to call Utilities.TrimAfter(sTarget, '#'); on the response

GetRedirectTargetURL(string, string)

Gets a redirect-target from a base URI and a Location header

Declaration

cs-api-definition
public static string GetRedirectTargetURL(string sBase, string sLocation)

Parameters

sBase

string

sLocation

string

Returns

string

null, or Target URL. Note, you may want to call Utilities.TrimAfter(sTarget, '#');

GetRequestBodyAsBytes()

Return a byte array generated from the request body, decoding it.

Declaration

cs-api-definition
[CodeDescription("Return a byte array generated from the request body, decoding it.")]
public byte[] GetRequestBodyAsBytes()

Returns

byte[]

A byte array containing the request body.

GetRequestBodyAsString()

Return a string generated from the request body, decoding it and converting from a codepage if needed. Throws on errors.

Declaration

cs-api-definition
[CodeDescription("Return a string generated from the request body, decoding it and converting from a codepage if needed. Possibly expensive due to decompression and will throw on malformed content. Throws on errors.")]
public string GetRequestBodyAsString()

Returns

string

A string containing the request body.

GetRequestBodyEncoding()

Find the text encoding of the request WARNING: Will not decompress body to scan for indications of the character set

Declaration

cs-api-definition
[CodeDescription("Returns the Encoding of the requestBodyBytes")]
public Encoding GetRequestBodyEncoding()

Returns

Encoding

Returns the Encoding of the requestBodyBytes

GetResponseBodyAsBytes()

Return a byte array generated from the response body, decoding it.

Declaration

cs-api-definition
[CodeDescription("Return a byte array generated from the response body, decoding it.")]
public byte[] GetResponseBodyAsBytes()

Returns

byte[]

A byte array containing the response body.

GetResponseBodyAsString()

Return a string generated from the response body, decoding it and converting from a codepage if needed. Throws on errors.

Declaration

cs-api-definition
[CodeDescription("Return a string generated from the response body, decoding it and converting from a codepage if needed. Possibly expensive due to decompression and will throw on malformed content. Throws on errors.")]
public string GetResponseBodyAsString()

Returns

string

A string containing the response body.

GetResponseBodyEncoding()

Find the text encoding of the response WARNING: Will not decompress body to scan for indications of the character set

Declaration

cs-api-definition
[CodeDescription("Returns the Encoding of the responseBodyBytes")]
public Encoding GetResponseBodyEncoding()

Returns

Encoding

The Encoding of the responseBodyBytes

HTTPMethodIs(string)

Returns TRUE if the Session's HTTP Method is available and matches the target method.

Declaration

cs-api-definition
[CodeDescription("Returns TRUE if the Session's HTTP Method is available and matches the target method.")]
public bool HTTPMethodIs(string sTestFor)

Parameters

sTestFor

string

The target HTTP Method being compared.

Returns

bool

true, if the method is specified and matches sTestFor (case-insensitive); otherwise false.

HostnameIs(string)

Returns TRUE if the Session's target hostname (no port) matches sTestHost (case-insensitively).

Declaration

cs-api-definition
[CodeDescription("Returns TRUE if the Session's target hostname (no port) matches sTestHost (case-insensitively).")]
public bool HostnameIs(string sTestHost)

Parameters

sTestHost

string

The host to which this session's host should be compared.

Returns

bool

True if this session is targeted to the specified host.

Ignore()

Set the SessionFlags.Ignore bit for this Session, also configuring it to stream, drop read data, and bypass event handlers. For a CONNECT Tunnel, traffic will be blindly shuffled back and forth. Session will be hidden.

Declaration

cs-api-definition
[CodeDescription("Sets the SessionFlags.Ignore bit for this Session, hiding it and ignoring its traffic.")]
public void Ignore()

LoadMetadata(Stream, bool)

Read metadata about this session from a stream. NB: Closes the Stream when done.

Declaration

cs-api-definition
public bool LoadMetadata(Stream strmMetadata, bool skipOriginalIdComment = false)

Parameters

strmMetadata

Stream

The stream of XML text from which session metadata will be loaded.

skipOriginalIdComment

bool

Specifies if the sessions without comments should ge their original Id as an auto-generated comment of not.

Returns

bool

True if the Metadata was successfully loaded; False if any exceptions were trapped.

LoadRequestBodyFromFile(string)

Replace HTTP request body using the specified file.

Declaration

cs-api-definition
[CodeDescription("Replace HTTP request headers and body using the specified file.")]
public bool LoadRequestBodyFromFile(string sFilename)

Parameters

sFilename

string

The file containing the request

Returns

bool

True if the file was successfully loaded as the request body

LoadResponseFromFileAsync(string)

Replace HTTP response headers and body using the specified file.

Declaration

cs-api-definition
[CodeDescription("Replace HTTP response headers and body using the specified file.")]
public Task<bool> LoadResponseFromFileAsync(string sFilename)

Parameters

sFilename

string

The file containing the response.

Returns

Task<bool>

True if the file was successfully loaded.

LoadResponseFromStreamAsync(Stream, string)

Replace HTTP response headers and body using the specified stream.

Declaration

cs-api-definition
public Task<bool> LoadResponseFromStreamAsync(Stream strmResponse, string sOptionalContentTypeHint)

Parameters

strmResponse

Stream

The stream containing the response.

sOptionalContentTypeHint

string

Optional content type for the stream data to set in the headers.

Returns

Task<bool>

True if the Stream was successfully loaded.

PoisonClientPipe()

Ensures that, after the response is complete, the client socket is closed and not reused. Does NOT (and must not) close the pipe.

Declaration

cs-api-definition
public void PoisonClientPipe()

PoisonServerPipe()

Prevents the server pipe from this session from being pooled for reuse

Declaration

cs-api-definition
public void PoisonServerPipe()

SaveMetadata(string)

Writes this session's metadata to a file.

Declaration

cs-api-definition
public bool SaveMetadata(string sFilename)

Parameters

sFilename

string

The name of the file to which the metadata should be saved in XML format.

Returns

bool

True if the file was successfully written.

SaveResponse(string, bool)

Saves the response (headers and body) to a file

Declaration

cs-api-definition
public void SaveResponse(string sFilename, bool bHeadersOnly)

Parameters

sFilename

string

The File to write

bHeadersOnly

bool

TRUE if only heaers should be written

ThreadResume()

This method resumes the Session's thread in response to "Continue" commands from the UI

Declaration

cs-api-definition
public void ThreadResume()

ToHTMLFragment(bool)

Returns HTML representing the Session. Call Utilities.StringToCF_HTML on the result of this function before placing it on the clipboard.

Declaration

cs-api-definition
public string ToHTMLFragment(bool HeadersOnly)

Parameters

HeadersOnly

bool

TRUE if only the headers should be copied.

Returns

string

A HTML-formatted fragment representing the current session.

ToString()

Store this session's request and response to a string.

Declaration

cs-api-definition
public override string ToString()

Returns

string

A string containing the content of the request and response.

Overrides object.ToString()

ToString(bool)

Store this session's request and response to a string.

Declaration

cs-api-definition
public string ToString(bool HeadersOnly)

Parameters

HeadersOnly

bool

If true, return only the request and response headers

Returns

string

String representing this session

UNSTABLE_SetBitFlag(SessionFlags, bool)

DO NOT USE. TEMPORARY WHILE REFACTORING VISIBILITY OF MEMBERS

Declaration

cs-api-definition
public void UNSTABLE_SetBitFlag(SessionFlags FlagsToSet, bool b)

Parameters

FlagsToSet

SessionFlags

b

bool

WriteMetadataToStream(Stream)

Write the metadata about this Session to a stream. The Stream is left open!

Declaration

cs-api-definition
public void WriteMetadataToStream(Stream strmMetadata)

Parameters

strmMetadata

Stream

The Stream to write to

WriteRequestToStream(bool, bool, Stream)

Write the session's Request to the specified stream

Declaration

cs-api-definition
public bool WriteRequestToStream(bool bHeadersOnly, bool bIncludeProtocolAndHostWithPath, Stream oFS)

Parameters

bHeadersOnly

bool

TRUE if only the headers should be be written

bIncludeProtocolAndHostWithPath

bool

TRUE if the Scheme and Host should be written in the Request Line

oFS

Stream

The Stream to which the request should be written

Returns

bool

True if the request was written to the stream. False if the request headers do not exist. Throws on other stream errors.

WriteRequestToStream(bool, bool, bool, Stream)

Write the session's Request to the specified stream

Declaration

cs-api-definition
public bool WriteRequestToStream(bool bHeadersOnly, bool bIncludeProtocolAndHostWithPath, bool bEncodeIfBinary, Stream oFS)

Parameters

bHeadersOnly

bool

TRUE if only the headers should be be written

bIncludeProtocolAndHostWithPath

bool

TRUE if the Scheme and Host should be written in the Request Line

bEncodeIfBinary

bool

TRUE if binary bodies should be encoded in base64 for text-safe transport (e.g. used by Composer drag/drop)

oFS

Stream

The Stream to which the request should be written

Returns

bool

True if the request was written to the stream. False if the request headers do not exist. Throws on other stream errors.

WriteResponseToStream(Stream, bool)

Write the session's Response to the specified stream

Declaration

cs-api-definition
public bool WriteResponseToStream(Stream oFS, bool bHeadersOnly)

Parameters

oFS

Stream

The stream to which the response should be written

bHeadersOnly

bool

TRUE if only the headers should be written

Returns

bool

TRUE if the response was written to the stream. False if the response headers do not exist. Throws on other stream errors.

WriteToStream(Stream, bool)

Write the session to the specified stream

Declaration

cs-api-definition
[CodeDescription("Write the session (or session headers) to the specified stream")]
public bool WriteToStream(Stream oFS, bool bHeadersOnly)

Parameters

oFS

Stream

The stream to which the session should be written

bHeadersOnly

bool

TRUE if only the request and response headers should be written

Returns

bool

False on any exceptions; True otherwise

isAnyFlagSet(SessionFlags)

Test the session's BitFlags

Declaration

cs-api-definition
public bool isAnyFlagSet(SessionFlags FlagsToTest)

Parameters

FlagsToTest

SessionFlags

One or more (OR'd) SessionFlags

Returns

bool

TRUE if ANY of specified flag(s) are set

isFlagSet(SessionFlags)

Test the session's BitFlags

Declaration

cs-api-definition
public bool isFlagSet(SessionFlags FlagsToTest)

Parameters

FlagsToTest

SessionFlags

One or more (OR'd) SessionFlags

Returns

bool

TRUE if ALL specified flag(s) are set

uriContains(string)

Returns true if the absolute request URI contains the specified string. Case-insensitive.

Declaration

cs-api-definition
[CodeDescription("Returns true if request URI contains the specified string. Case-insensitive.")]
public bool uriContains(string sLookfor)

Parameters

sLookfor

string

Case-insensitive string to find

Returns

bool

TRUE if the URI contains the string

utilAssignResponse(HTTPResponseHeaders, byte[])

Copy an existing response to this Session, bypassing the server if not already contacted

Declaration

cs-api-definition
[CodeDescription("Copy an existing response to this Session, bypassing the server if not already contacted")]
public void utilAssignResponse(HTTPResponseHeaders oRH, byte[] arrBody)

Parameters

oRH

HTTPResponseHeaders

The response headers

arrBody

byte[]

The response body

utilAssignResponse(Session)

Copy an existing Session's response to this Session, bypassing the server if not already contacted.

Declaration

cs-api-definition
[CodeDescription("Copy an existing Session's response to this Session, bypassing the server if not already contacted")]
public void utilAssignResponse(Session oFromSession)

Parameters

oFromSession

Session

The existing session to copy the response from.

utilBZIP2Response()

Use BZIP2 to compress the response body. Throws exceptions to caller.

Declaration

cs-api-definition
[CodeDescription("Use BZIP2 to compress the response body. Throws exceptions to caller.")]
public bool utilBZIP2Response()

Returns

bool

TRUE if compression succeeded

utilChunkResponse(int)

Introduces HTTP Chunked encoding on the response body

Declaration

cs-api-definition
[CodeDescription("Apply Transfer-Encoding: chunked to the response, if possible.")]
public bool utilChunkResponse(int iSuggestedChunkCount)

Parameters

iSuggestedChunkCount

int

The number of chunks to try to create

Returns

bool

TRUE if the chunking could be performed.

utilCreateResponseAndBypassServerAsync()

Call inside OnBeforeRequest to create a response object and bypass the server.

Declaration

cs-api-definition
[CodeDescription("Call inside OnBeforeRequest to create a Response object and bypass the server.")]
public Task utilCreateResponseAndBypassServerAsync()

Returns

Task

utilDecodeRequest()

Removes chunking and HTTP Compression from the Request. Adds or updates Content-Length header.

Declaration

cs-api-definition
[CodeDescription("Removes chunking and HTTP Compression from the Request. Adds or updates Content-Length header.")]
public bool utilDecodeRequest()

Returns

bool

Returns TRUE if the request was decoded; returns FALSE on failure, or if request didn't have headers that showed encoding.

utilDecodeRequest(bool)

Decode request body in place and delete encoding headers from the request headers.

Declaration

cs-api-definition
public bool utilDecodeRequest(bool bSilent)

Parameters

bSilent

bool

True to log/report any exceptions during decoding.

Returns

bool

True if request body was decoded, false if nothing to decode or decoding failed.

utilDecodeResponse()

Removes chunking and HTTP Compression from the Response. Adds or updates Content-Length header.

Declaration

cs-api-definition
[CodeDescription("Removes chunking and HTTP Compression from the response. Adds or updates Content-Length header.")]
public bool utilDecodeResponse()

Returns

bool

Returns TRUE if the response was decoded; returns FALSE on failure, or if response didn't have headers that showed encoding.

utilDecodeResponse(bool)

Removes chunking and HTTP Compression from the Response. Adds or updates Content-Length header.

Declaration

cs-api-definition
public bool utilDecodeResponse(bool bSilent)

Parameters

bSilent

bool

TRUE if error messages should be suppressed. False otherwise.

Returns

bool

TRUE if the decoding was successsful.

utilDeflateResponse()

Use DEFLATE to compress the response body. Throws exceptions to caller.

Declaration

cs-api-definition
[CodeDescription("Use DEFLATE to compress the response body. Throws exceptions to caller.")]
public bool utilDeflateResponse()

Returns

bool

TRUE if compression succeeded

utilFindInRequest(string, bool)

Find a string in the request body. Return its index, or -1.

Declaration

cs-api-definition
[CodeDescription("Find a string in the request body. Return its index or -1.")]
public int utilFindInRequest(string sSearchFor, bool bCaseSensitive)

Parameters

sSearchFor

string

Term to search for

bCaseSensitive

bool

Require case-sensitive match?

Returns

int

Location of sSearchFor,or -1

utilFindInResponse(string, bool)

Find a string in the response body. Return its index, or -1.

Declaration

cs-api-definition
[CodeDescription("Find a string in the response body. Return its index or -1. Note, you should call utilDecodeResponse first!")]
public int utilFindInResponse(string sSearchFor, bool bCaseSensitive)

Parameters

sSearchFor

string

Term to search for

bCaseSensitive

bool

Require case-sensitive match?

Returns

int

Location of sSearchFor,or -1

utilGZIPRequest()

Use GZIP to compress the request body. Throws exceptions to caller.

Declaration

cs-api-definition
[CodeDescription("Use GZIP to compress the request body. Throws exceptions to caller.")]
public bool utilGZIPRequest()

Returns

bool

TRUE if compression succeeded

utilGZIPResponse()

Use GZIP to compress the response body. Throws exceptions to caller.

Declaration

cs-api-definition
[CodeDescription("Use GZIP to compress the response body. Throws exceptions to caller.")]
public bool utilGZIPResponse()

Returns

bool

TRUE if compression succeeded

utilPrependToResponseBody(string)

Add a string to the top of the response body, updating Content-Length. (Call utilDecodeResponse first!)

Declaration

cs-api-definition
[CodeDescription("Prepend a string to the response body. Updates Content-Length header. Note, you should call utilDecodeResponse first!")]
public void utilPrependToResponseBody(string sString)

Parameters

sString

string

The string to prepend

utilReplaceInRequest(string, string)

Perform a string replacement on the request body. Adjusts the Content-Length header if needed.

Declaration

cs-api-definition
[CodeDescription("Perform a case-sensitive string replacement on the request body (not URL!). Updates Content-Length header. Returns TRUE if replacements occur.")]
public bool utilReplaceInRequest(string sSearchFor, string sReplaceWith)

Parameters

sSearchFor

string

The case-sensitive string to search for.

sReplaceWith

string

The text to replace.

Returns

bool

TRUE if one or more replacements occurred.

utilReplaceInResponse(string, string)

Perform a string replacement on the response body (potentially multiple times). Adjust the Content-Length header if needed.

Declaration

cs-api-definition
[CodeDescription("Perform a case-sensitive string replacement on the response body. Updates Content-Length header. Note, you should call utilDecodeResponse first!  Returns TRUE if replacements occur.")]
public bool utilReplaceInResponse(string sSearchFor, string sReplaceWith)

Parameters

sSearchFor

string

String to find (case-sensitive)

sReplaceWith

string

String to use to replace

Returns

bool

TRUE if replacements occurred

utilReplaceOnceInResponse(string, string, bool)

Perform a one-time string replacement on the response body. Adjust the Content-Length header if needed.

Declaration

cs-api-definition
[CodeDescription("Perform a single case-sensitive string replacement on the response body. Updates Content-Length header. Note, you should call utilDecodeResponse first! Returns TRUE if replacements occur.")]
public bool utilReplaceOnceInResponse(string sSearchFor, string sReplaceWith, bool bCaseSensitive)

Parameters

sSearchFor

string

String to find (case-sensitive)

sReplaceWith

string

String to use to replace

bCaseSensitive

bool

TRUE for Case-Sensitive

Returns

bool

TRUE if a replacement occurred

utilReplaceRegexInResponse(string, string)

Perform a regex-based string replacement on the response body. Adjusts the Content-Length header if needed.

Declaration

cs-api-definition
[CodeDescription("Perform a regex-based replacement on the response body. Specify RegEx Options via leading Inline Flags, e.g. (?im) for case-Insensitive Multi-line. Updates Content-Length header. Note, you should call utilDecodeResponse first!  Returns TRUE if replacements occur.")]
public bool utilReplaceRegexInResponse(string sSearchForRegEx, string sReplaceWithExpression)

Parameters

sSearchForRegEx

string

The regular expression used to search the body. Specify RegEx Options via leading Inline Flags, e.g. (?im) for case-Insensitive Multi-line.

sReplaceWithExpression

string

The text or expression used to replace

Returns

bool

TRUE if replacements occured

utilSetRequestBody(string)

Replaces the request body with sString. Sets Content-Length header and removes Transfer-Encoding/Content-Encoding.

Declaration

cs-api-definition
[CodeDescription("Replaces the request body with sString. Sets Content-Length header & removes Transfer-Encoding/Content-Encoding")]
public void utilSetRequestBody(string sString)

Parameters

sString

string

The desired request Body as a string

utilSetResponseBody(string)

Replaces the response body with sString. Sets Content-Length header and removes Transfer-Encoding/Content-Encoding

Declaration

cs-api-definition
[CodeDescription("Replaces the response body with sString. Sets Content-Length header & removes Transfer-Encoding/Content-Encoding")]
public void utilSetResponseBody(string sString)

Parameters

sString

string

The desired response Body as a string

Events

OnCompleteTransaction

Raised once when the session is finished (state>=Done)

Declaration

cs-api-definition
public event EventHandler<EventArgs> OnCompleteTransaction

Event Value

EventHandler<EventArgs>

OnContinueTransaction

This event fires if this Session automatically yields a new one, for instance, if Fiddler is configured to automatically follow redirects or perform multi-leg authentication (X-AutoAuth).

Declaration

cs-api-definition
public event EventHandler<ContinueTransactionEventArgs> OnContinueTransaction

Event Value

EventHandler<ContinueTransactionEventArgs>

OnStateChanged

This event fires at any time the session's State changes. Use with caution due to the potential for performance impact.

Declaration

cs-api-definition
public event EventHandler<StateChangeEventArgs> OnStateChanged

Event Value

EventHandler<StateChangeEventArgs>

SessionCreated

This event fires when new session is created.

Declaration

cs-api-definition
public static event EventHandler<Session> SessionCreated

Event Value

EventHandler<Session>

Extension Methods

In this article
DefinitionConstructorsSession(HTTPRequestHeaders, byte[], bool)Session(Session)Session(byte[], byte[], SessionFlags, bool)Session(byte[], byte[], bool)FieldsMetricsViewItem__oTunnelbBufferResponsem_clientIPm_clientPortm_hostIPoFlagsoRequestrequestBodyBytesresponseBodyBytesPropertiesBitFlagsCertificateChainErrorsConnectedStateFormattedClientSslVersionFormattedServerSslVersionFormattedSslVersionIsWebSocketSessionLocalProcessLocalProcessIDPathAndQueryRemoteDeviceIdRequestBodyRequestHeadersRequestHeadersFlatRequestMethodResponseBodyResponseHeadersResponseHeadersFlatResponseTrailersSuggestedFilenameTagTunnelEgressByteCountTunnelIngressByteCountTunnelIsOpenUiSharedIdbHasGRPCMessagesbHasResponsebHasWebSocketMessagesbypassGatewayclientIPclientPortfullUrlhosthostnameidisFTPisHTTP2isHTTPSisTunneloResponseportresponseCodestatethis[string, string]this[string]urlMethodsAbortAsync()BuildFromData(bool, HTTPRequestHeaders, byte[], HTTPResponseHeaders, byte[], SessionFlags)COMETPeek()GetRedirectTargetURL()GetRedirectTargetURL(string, string)GetRequestBodyAsBytes()GetRequestBodyAsString()GetRequestBodyEncoding()GetResponseBodyAsBytes()GetResponseBodyAsString()GetResponseBodyEncoding()HTTPMethodIs(string)HostnameIs(string)Ignore()LoadMetadata(Stream, bool)LoadRequestBodyFromFile(string)LoadResponseFromFileAsync(string)LoadResponseFromStreamAsync(Stream, string)PoisonClientPipe()PoisonServerPipe()SaveMetadata(string)SaveResponse(string, bool)ThreadResume()ToHTMLFragment(bool)ToString()ToString(bool)UNSTABLE_SetBitFlag(SessionFlags, bool)WriteMetadataToStream(Stream)WriteRequestToStream(bool, bool, Stream)WriteRequestToStream(bool, bool, bool, Stream)WriteResponseToStream(Stream, bool)WriteToStream(Stream, bool)isAnyFlagSet(SessionFlags)isFlagSet(SessionFlags)uriContains(string)utilAssignResponse(HTTPResponseHeaders, byte[])utilAssignResponse(Session)utilBZIP2Response()utilChunkResponse(int)utilCreateResponseAndBypassServerAsync()utilDecodeRequest()utilDecodeRequest(bool)utilDecodeResponse()utilDecodeResponse(bool)utilDeflateResponse()utilFindInRequest(string, bool)utilFindInResponse(string, bool)utilGZIPRequest()utilGZIPResponse()utilPrependToResponseBody(string)utilReplaceInRequest(string, string)utilReplaceInResponse(string, string)utilReplaceOnceInResponse(string, string, bool)utilReplaceRegexInResponse(string, string)utilSetRequestBody(string)utilSetResponseBody(string)EventsOnCompleteTransactionOnContinueTransactionOnStateChangedSessionCreatedExtension Methods
Not finding the help you need?
Contact Support