Click or drag to resize
Utilities Class
Holds a variety of useful functions used in Fiddler and its addons.
Inheritance Hierarchy
SystemObject
  FiddlerUtilities

Namespace: Fiddler
Assembly: FiddlerCore4 (in FiddlerCore4.dll) Version: 4.6.2.0
Syntax
public static class Utilities

The Utilities type exposes the following members.

Methods
  NameDescription
Public methodStatic memberareOriginsEquivalent
Returns TRUE if two ORIGIN (scheme+host+port) values are functionally equivalent.
Public methodStatic memberBrotliExpand
Public methodStatic memberByteArrayToHexView(Byte, Int32)
Pretty-print a Hex view of a byte array. Slow.
Public methodStatic memberByteArrayToHexView(Byte, Int32, Int32)
Pretty-print a Hex view of a byte array. Slow.
Public methodStatic memberByteArrayToHexView(Byte, Int32, Int32, Boolean)
Pretty-print a Hex view of a byte array. Slow.
Public methodStatic memberByteArrayToHexView(Byte, Int32, Int32, Int32, Boolean)
Public methodStatic memberByteArrayToString
Print an byte array to a hex string. Slow.
Public methodStatic memberbzip2Compress
Compress a byte[] using the bzip2 algorithm
Public methodStatic memberbzip2Expand(Byte)
Decompress an array compressed using bzip2
Public methodStatic memberbzip2Expand(Byte, Boolean)
Decompress an array compressed using bzip2
Public methodStatic memberCollapsePath
Convert a full path into one that uses environment variables
Public methodStatic memberCompactPath
Shrinks a path string to fit within a certain number of characters, replacing segments with ellipses if needed.
Public methodStatic memberCompareVersions
Typically, a version number is displayed as "major number.minor number.build number.private part number".
Public methodStatic memberContentTypeForFilename
Return the content type of a target file, or application/octet-stream if unknown.
Public methodStatic memberCopyToClipboard(String)
Copy a string to the clipboard, notifying the user of any exceptions
Public methodStatic memberCopyToClipboard(DataObject)
Copy an object to the clipboard, notifying the user of any exceptions
Public methodStatic memberCrackHostAndPort
This function cracks the Hostname/Port combo, removing IPV6 brackets if needed
Public methodStatic memberDeflaterCompress
Compress a byte array using RFC1951 DEFLATE
Public methodStatic memberDeflaterExpand(Byte)
Decompress a byte array that was compressed using RFC1951 DEFLATE
Public methodStatic memberDeflaterExpand(Byte, Boolean)
Public methodStatic memberDeflaterExpandInternal
UnDeflate function which shows no UI and will throw on error
Public methodStatic memberdoChunk
Takes a byte array and applies HTTP Chunked Transfer Encoding to it
Public methodStatic memberdoUnchunk
Removes HTTP chunked encoding from the data in writeData and returns the resulting array.
Public methodStatic memberDupe
Duplicate a byte array, replacing null with byte[0]. Doing this instead of .Clone() because it better handles nulls and it may be faster.
Public methodStatic memberEllipsizeIfNeeded
Ensures that the target string is iMaxLength or fewer characters, appending ... if truncation occurred
Public methodStatic memberEnsureInRangeT
Ensures a value is within a specified range.
Public methodStatic memberEnsureOverwritable
Ensure that the target path exists and if a file exists there, it is not readonly or hidden. WARNING: Can throw if target "Filename" calls for a parent directoryname that is already used as a filename by a non-directory. E.g. EnsureOverwriteable(C:\io.sys\filename.txt); would throw.
Public methodStatic memberEnsurePathIsAbsolute
Ensure that a given path is absolute, if not, applying the root path. WARNING: This function only works as well as Path.IsPathRooted, which returns "True" for things like "/NoDriveSpecified/fuzzle.txt" A better approach would be to look at the internal Path.IsRelative method
Public methodStatic memberEnsureUniqueFilename
Ensure that the target file does not yet exist. If it does, generates a new filename with an embedded identifier, e.g. out[1].txt instead. Attempts to ensure filename is creatable; e.g. if a path component needs to be a directory but is a file already, injects [#] into that path component.
Public methodStatic memberEnsureValidAsPath
Address the problem where the target "PATH" calls for a directoryname is already a filename
Public methodStatic memberGetCommaTokenValue
Returns the Value from a (case-insensitive) token in the header string. Correctly handles double-quoted strings. Allows comma and semicolon as delimiter. Trailing whitespace may be present.
Public methodStatic membergetEntityBodyEncoding
WARNING: Potentially slow. WARNING: Does not decode the HTTP Response body; if compressed, embedded META or _charset_ will not be checked Gets (via Headers or Sniff) the provided body's text Encoding. If not found, returns CONFIG.oHeaderEncoding (usually UTF-8).
Public methodStatic memberGetExecutableOutput
Run an executable, wait for it to exit, and return its output as a string. NOTE: Uses CreateProcess, so you cannot launch applications which require Elevation.
Public methodStatic memberGetHashAsBase64
Public methodStatic memberGetMD5Hash
Warning: This will throw if FIPS mode is enabled
Public methodStatic memberGetRegistryBool
Get a bool from the registry
Public methodStatic memberGetRegistryFloat
Returns an Float from the registry, or a default.
Public methodStatic memberGetRegistryInt
Returns an integer from the registry, or a default.
Public methodStatic membergetResponseBodyEncoding
Gets (via Headers or Sniff) the Response Text Encoding. Returns CONFIG.oHeaderEncoding (usually UTF-8) if unknown. Perf: May be quite slow; cache the response
Public methodStatic memberGetSHA1Hash
Public methodStatic memberGetSHA256Hash
Public methodStatic memberGetSHA384Hash
Public methodStatic memberGetSHA512Hash
Public methodStatic memberGetStringFromArrayRemovingBOM
Gets a string from a byte-array, stripping a Byte Order Marker preamble if present.
Public methodStatic memberGetTextEncoding
WARNING: May throw. Gets an encoding, with proper respect for "utf8" as an alias for "utf-8"; Microsoft products don't support this prior to 2015-era, but it turns out to be common. We do have a linter elsewhere that reports a warning if it sees the dashless form. https://github.com/telerik/fiddler/issues/38
Public methodStatic memberGetTickCount
Get a TickCount (milliseconds since system start) as an unsigned 64bit value. On Vista+, uses the GetTickCount64 API that won't rollover, but on XP, this unsigned wrapper moves the rollover point to 49 days of uptime.
Public methodStatic memberGzipCompress
GZIPs a byte-array
Public methodStatic memberGzipExpand(Byte)
Expands a GZIP-compressed byte array
Public methodStatic memberGzipExpand(Byte, Boolean)
Public methodStatic memberGzipExpandInternal
GZIP-Expand function which shows no UI and will throw on error
Public methodStatic memberHasMagicBytes(Byte, Byte)
Determines whether the arrData array STARTS WITH with the supplied arrMagics bytes. Used for Content-Type sniffing.
Public methodStatic memberHasMagicBytes(Byte, String)
Determines whether the arrData array begins with the supplied sMagics ASCII text. Used for Content-Type sniffing.
Public methodStatic memberHasMagicBytes(Byte, Int32, Byte)
Public methodStatic memberHtmlEncode
HtmlEncode a string. In Fiddler itself, this is a simple wrapper for the System.Web.HtmlEncode function. The .NET3.5/4.0 Client Profile doesn't include System.Web, so we must provide our own implementation of HtmlEncode for FiddlerCore's use.
Public methodStatic memberHTTPMethodAllowsBody
Returns true if a request with the specified HTTP Method/Verb may contain a entity body
Public methodStatic memberHTTPMethodIsIdempotent
http://tools.ietf.org/html/draft-ietf-httpbis-p2-semantics-26#section-4.2.2
Public methodStatic memberHTTPMethodRequiresBody
Determines true if a request with the specified HTTP Method/Verb MUST contain a entity body
Public methodStatic memberHTTPStatusAllowsBody
Public methodStatic memberIndexOfNth
Public methodStatic memberIPEndPointFromHostPortString
Given a string/list in the form HOSTNAME:PORT#;HOSTNAME2:PORT2#, this function returns the FIRST IPEndPoint. Defaults to port 80 if not specified. Warning: DNS resolution is slow, so use this function wisely.
Public methodStatic memberIPEndPointListFromHostPortString
Given a string/list in the form HOSTNAME:PORT#;HOSTNAME2:PORT2#, this function returns all IPEndPoints for ALL listed hosts. Defaults to port 80 if not specified. Warning: DNS resolution is slow, so use this function wisely.
Public methodStatic memberIPFromString
This function attempts to be a ~fast~ way to return an IP from a hoststring that contains an IPv4/6-Literal.
Public methodStatic memberIsBinaryMIME
Determines if the specified MIME type is "binary" in nature.
Public methodStatic memberIsBrowserProcessName
For a given process name, returns a bool indicating whether this is a known browser process name.
Public methodStatic memberIsCommentUserSupplied
Returns TRUE if the string is non-empty and not of the pattern "[#123]" Necessary because SAZ-saving logic autogenerates comments of that form
Public methodStatic memberisLocalhost
This function cracks a sHostPort string to determine if the address refers to the local computer
Public methodStatic memberisLocalhostname
Determines if the specified Hostname is a either 'localhost' or an IPv4 or IPv6 loopback literal
Public methodStatic memberIsNullOrEmpty
Returns TRUE if the array is null or contains 0 bytes
Public methodStatic memberisPlainHostName
This function cracks a sHostPort string to determine if the address refers to a "local" site
Public methodStatic memberIsRedirectStatus
Public methodStatic memberisUnsupportedEncoding
Implements a BlockList for "unknown" encodings that the utilDecode* functions cannot handle
Public methodStatic memberIsUserAnAdmin
Returns TRUE if the user is running Elevated. Requires WinXP to Win8
Public methodStatic memberJoinByteArrays
Create a new byte[] containing the contents of two other byte arrays.
Public methodStatic memberLaunchHyperlink
Launch the user's browser to a hyperlink. This function traps exceptions and notifies the user via UI dialog.
Public methodStatic memberObtainFilenames
Public methodStatic memberObtainOpenFilename(String, String)
Queries the user for an OPEN filename
Public methodStatic memberObtainOpenFilename(String, String, String)
Queries the user for an OPEN filename
Public methodStatic memberObtainSaveFilename(String, String)
Queries the user for a filename
Public methodStatic memberObtainSaveFilename(String, String, String)
Queries the user for a filename
Public methodStatic memberParameterize(String)
Public methodStatic memberParameterize(String, Boolean)
Tokenize a string into tokens. Delimits on unquoted whitespace ; quote marks are dropped unless preceded by \ characters. Some special hackery to allow trailing slash not escape the final character of the entire input, so that: prefs set fiddler.config.path.vsplugins "F:\users\ericlaw\VSWebTest\" ...doesn't end up with a trailing quote.
Public methodStatic memberPlaySoundFile
Public methodStatic memberPrefixEllipsizeIfNeeded
Public methodStatic memberReadEntireStream(Stream)
Public methodStatic memberReadEntireStream(Stream, Byte)
Fills an array completely using the provided stream. Unlike a normal .Read(), this one will always fully fill the array unless the Stream throws.
Public methodStatic memberReadSessionArchive(String, Boolean)
Public methodStatic memberReadSessionArchive(String, Boolean, String)
Reads a Session Archive Zip file into an array of Session objects
Public methodStatic memberReadSessionArchive(String, Boolean, String, GetPasswordDelegate)
Reads a Session Archive Zip file into an array of Session objects
Public methodStatic memberRecoverMemory
Garbage collect and, if possible, compact the Large Object heap
Public methodStatic memberRunExecutable
Wrapper for Process.Start that shows error messages in the event of failure.
Public methodStatic memberRunExecutableAndWait
Run an executable and wait for it to exit, notifying the user of any exceptions.
Public methodStatic memberSetRegistryString
Save a string to the registry. Correctly handles null Value, saving as String.Empty
Public methodStatic memberTrimAfter(String, Char)
Returns the "Head" of a string, before and not including the first instance of specified delimiter.
Public methodStatic memberTrimAfter(String, Int32)
[Deprecated] Ensures that the target string is iMaxLength or fewer characters
Public methodStatic memberTrimAfter(String, String)
Returns the "Head" of a string, before and not including a specified search string.
Public methodStatic memberTrimBefore(String, Char)
Returns the "Tail" of a string, after (but NOT including) the First instance of specified delimiter. See also
Public methodStatic memberTrimBefore(String, String)
Returns the "Tail" of a string, after (but NOT including) the First instance of specified search string.
Public methodStatic memberTrimBeforeLast(String, Char)
Returns the "Tail" of a string, after (but not including) the Last instance of specified delimiter.
Public methodStatic memberTrimBeforeLast(String, String)
Returns the "Tail" of a string, after (but not including) the Last instance of specified substring.
Public methodStatic memberTrimTo
Ensures that the target string is iMaxLength or fewer characters
Public methodStatic memberTrimUpTo
Returns the "Tail" of a string, after (and including) the first instance of specified search string.
Public methodStatic memberTryHexParse
Try parsing the string for a Hex-formatted int. If it fails, return false and 0 in iOutput.
Public methodStatic memberUNSTABLE_DescribeClientHello
Public methodStatic memberUNSTABLE_DescribeServerHello
Public methodStatic memberUrlDecode
Convert the %-encoded string into a string, interpreting %-escape sequences as UTF-8 characters
Public methodStatic memberUrlEncode(String)
Public methodStatic memberUrlEncode(String, Encoding)
Public methodStatic memberUrlPathEncode
Replaces System.Web.HttpUtility.UrlPathEncode(str).
Public methodStatic memberutilDecodeHTTPBody(HTTPHeaders, Byte)
Remove all encodings from arrBody, based on those specified in the supplied HTTP headers; DOES NOT MODIFY HEADERS. Throws on errors.
Public methodStatic memberutilDecodeHTTPBody(HTTPHeaders, Byte, Boolean)
Remove all encodings from arrBody, based on those specified in the supplied HTTP headers; DOES NOT MODIFY HEADERS. DOES NOT HANDLE UNSUPPORTED ENCODINGS WELL. Throws on errors.
Public methodStatic memberWriteArrayToFile
Writes arrBytes to a file, creating the target directory and overwriting if the file exists.
Public methodStatic memberWriteSessionArchive
Create a Session Archive Zip file containing the specified sessions
Public methodStatic memberXpressExpand
Decompress a byte array that was compressed using Microsoft's Xpress Raw format. Available only on Windows 8+
Public methodStatic memberZLibExpand
Decompress an array compressed using an Zlib DEFLATE stream. Not a HTTP Encoding; it's used internally in the PNG format.
Top
Fields
  NameDescription
Public fieldStatic memberemptyByteArray
A static byte array containing 0 elements. Use to avoid having many copies of an empty byte[] floating around.
Public fieldStatic membersCommonRequestHeaders
Public fieldStatic membersCommonResponseHeaders
Top
See Also