• No results found

Keyboard Shortcuts

In document Debugging With Fiddler (Page 139-149)

After selecting a session in the Web Sessions list, you can press CTRL+H to activate the Request and Response Header Inspectors. Within the Inspector, the following hotkeys are available:

CTRL+C Copy the selected header to the clipboard.

CTRL+SHIFT+C Copy the selected header’s value to the clipboard.

F2 or Enter Open the Header Viewer or Header Editor window for the selected header.

CTRL+V When in Editing mode, attempt to add one or more new headers based on the text on the clip-board.

Insert When in Editing mode, create a new blank header.

Delete When in Editing mode, remove the selected header.

Editing

When the Inspector is in Edit mode, you can make changes to the headers before they are sent to the server or the client. If you would like to edit the entire set of headers at once, click the Raw link at the top-right of the Inspector.

The Raw Headers window will appear and enable you to save the new set of headers.

Alternatively, you can directly change the contents of the Request or Status Line by editing the text in the box at the top of the Inspector. To edit an individual name-value header, select it and press F2 or hit Enter and the Header Editor window will appear. To add a new Header, press the Insert key; a new header will appear and the Header Editor will automatically open.

122 | Inspectors

You may update the name and value of the new header using the boxes, or you may click the Header Templates button at the bottom of the window to choose from commonly-used headers.

123 | Inspectors

H E X V I E W

Type Request & Response Allows Editing Yes

The HexView Inspector allows you to view the request and response headers and body using a hexadecimal edit box.

This capability is most useful when inspecting binary content.

The Inspector contains a HexEdit control organized into three vertical columns. In the left column, in light grey, is the hexadecimal address for the adjacent line of bytes. In the center column are the hexadecimal representations of the individual bytes. The right column redisplays those bytes, interpreted as ASCII text. If the HexView is configured to show the headers, the request headers will be shown using in blue text and response headers will be shown in green.

The body bytes are shown in black.

At the bottom of the Inspector is a status bar containing three panels. The first panel shows the current cursor position within the bytes in decimal form and hexadecimal form. If the Inspector is configured to show the header bytes, the offset will automatically reset to zero when the cursor enters the body bytes.

If one or more bytes are selected in the control, the middle panel displays the length of the current byte selection.

The right panel indicates the current mode: Read only, Overwrite, or Insert. The Inspector is in Read only mode except when the Session is paused at a breakpoint or is Unlocked for Editing. In Edit mode, you may press the Insert key to toggle between overwriting bytes and inserting new bytes.

The HexView Inspector’s context menu offers the following items:

Insert File Here… In Edit mode, inserts the bytes of a selected file at the current cursor position.

Select Bytes… Prompts you for a number of bytes to select, then selects that number of bytes starting at the current cursor position. Enter a leading $ character if you wish to specify the number of bytes in Hexadecimal format.

Tip: This feature can be useful if you wish to examine HTTP Chunked Encoding blocks, as the length of each block is specified as a hexadecimal number.

Save Selected Bytes… When one or more bytes are selected, this item enables saving the selected bytes to a file of your choosing.

Goto Offset… Enables you to move the cursor to a selected byte of the content.

Enter a leading + or – character to specify the offset from the current cursor position instead of the start of the content. Enter a leading $ character if you wish to specify the number of bytes in Hexadecimal format.

Find Bytes… Enables you to specify a sequence of hexadecimal characters to search for. The search begins at the current cursor position. Press F3 to continue the search after each match.

Find String… Enables you to specify a sequence of characters to search for (the bytes will be interpreted as UTF-8 characters). The search begins at the current cursor position. Press F3 to continue the search after each match.

124 | Inspectors

Show Headers This checkbox controls whether the header bytes will be displayed within the control. When unticked, only the body bytes will be shown.

Note: In current versions of Fiddler, this option is automatically unticked when the HexView Inspector enters Edit mode, as the Inspector currently does not support editing of headers.

Set Bytes per Line… Enables you to specify how many bytes to show on each line of the display. Enter 0 to instruct the HexView to automatically select the number of bytes based on the available width (a minimum of four bytes per line will be shown).

125 | Inspectors

I M A G E V I E W

Type Response

Allows Editing No

The ImageView Inspector allows you to view the response as an image. The Inspector can display most common web image formats, including JPEGs, PNGs, and GIFs, as well as less common formats including cursors, images,

bitmaps, EMF/WMF, and TIFF. The Inspector does not support display of SVG graphics; if IE9 or later is installed, SVG responses can be viewed using the WebView Inspector.

The grey panel at left shows information about the currently selected image, including its size in bytes, pixel

dimensions, and file format. At the bottom of the grey panel is a dropdown that allows you to control how the image is scaled:

No scaling – Images are shown at their native dimensions.

Autoshrink – Images that are larger than the display area are scaled down.

Scale to fit – Images that are larger than the display area are scaled down, and images that are smaller than the display area are scaled up to fill the area.

The Inspector’s context menu allows you to copy the image to the clipboard as a bitmap, or quickly save the image file to your Windows desktop using the current time as the basis for the filename. Also available is an option to copy the image as a DataURI, a text format which can be embedded in HTML or stylesheets and displayed in modern browsers (IE8+). If the resulting URI is over 32kb in length, Fiddler will warn you that that IE8 does not support 32kb+ URIs; IE9 or later will be required to render the image. The final option on the menu allows you to change the background color (normally light blue) which can provide useful contrast when examining small or transparent images.

Middle-clicking on the image will silently copy the image to your Desktop folder. Double-clicking on the image will open a full-screen view. In full-screen view, the following functions are available:

Key or Mouse action Function

Enter or Z Toggle Zoom between Full-Screen and Actual Size

H Flip the image horizontally

V Flip the image vertically

R Rotate the image clockwise by 90 degrees.

Mousewheel up Zoom to Full-Screen Mousewheel down Show Actual Size

Escape Exit the full-screen viewer

To more rapidly view a large number of image responses, use the GalleryView extension.

126 | Inspectors

JSON

Type Request & Response Allows Editing No

The JSON Inspector interprets the selected request or response body as a JavaScript Object Notation (JSON) format-ted string, showing a treeview of the JSON object’s nodes. If the body cannot be interpreformat-ted as JSON, the treeview will remain empty. Unlike most inspectors, the JSON Inspector is able to render the data even if the request or response is compressed or has HTTP Chunked Encoding applied; you do not need to remove the encoding to display the content.

Many responses delivered with the JSON Content-Type are not really JSON. Instead, they’re JSONP, a JavaScript file consisting of a single function call with a string argument containing JSON. The JSON Inspector is able to handle many types of JSONP by ignoring the leading function call and trailing parenthesis and semicolon. However, some JSONP is malformed such that the name component of the name/value pairs is unquoted: the JSON Inspector cannot handle this type of malformedness and will refuse to parse the content.

The context menu offers two options: Copy, to copy the selected node to the clipboard (or press CTRL+C), and Send to TextWizard, to send the selected node’s content to the TextWizard window for encoding or decoding.

The Expand All button in the footer will expand all nodes of the tree, while the Collapse button will collapse all nodes of the tree. The JSON tree will be automatically expanded if the body contains less than 2000 nodes; for performance reasons, you must manually expand the tree for larger documents.

127 | Inspectors

R A W

Type Request & Response Allows Editing Yes

The Raw Inspector allows you to view the complete request and response, including headers and bodies, as text. The term “raw” is a bit of a misnomer, because Fiddler is still interpreting the bytes of the request and response; if you need a purely “raw” view of network traffic, use a packet sniffer like Microsoft Network Monitor (NetMon) or Wireshark.

Most of the Inspector is a large text area that displays headers and the body interpreted as text using the character set detected using the headers, the byte-order-marker, or an embedded META tag declaration. Pressing CTRL+G in the text area allows you to move the cursor to a specific line number. When right-clicking, the text area’s context menu offers standard Cut, Copy and Paste options. The menu also offers an option to send the currently selected text to the TextWizard tool. There are two checkboxes on the menu: one controls whether Word Wrap is enabled and the other controls whether the AutoTruncate feature is enabled.

Along the bottom of the Inspector is a bar that offers additional features. First is a search box that allows you to select matching text within the content. The search text is case-insensitive and does not support regular expressions.

Pressing the Up or Down arrow keys in the search box will scroll the text area above (to allow you to view search results in context). Matches are selected as you type, and the box will turn green if a match was found or red if no further matches were found. Pressing Enter or F3 will select the next match. Pressing CTRL+Enter will highlight all matches in the content.

The View in Notepad button saves the text content to a temporary file and opens a text editor to view the file. The text editor launched is controlled by the fiddler.config.path.texteditor preference; notepad.exe is the default.

The Inspector replaces any null bytes with the Unicode replacement character (�) and as such can be used to view binary response bodies, although the HexView remains more suitable for that task. Because displaying large binary bodies in the textbox can require large amounts of CPU time and memory, the Inspector is configured to automatical-ly truncate the display of large responses. The threshold at which truncation occurs is controlled by the Content-Type and four preferences:

 fiddler.inspectors.request.raw.truncatebinaryat

 fiddler.inspectors.request.raw.truncatetextat

 fiddler.inspectors.response.raw.truncatebinaryat

 fiddler.inspectors.response.raw.truncatetextat

By default, binary Content-Types are truncated at 128 bytes, and text types are truncated at 262144 bytes. Truncation can be disabled using the context menu.

128 | Inspectors

S Y N T A X V I E W

Type Request & Response Allows Editing Yes

The SyntaxView Inspector allows you to view request and response body text highlighted according to type-specific rules. This is a very useful feature when reading HTML, XML, CSS, and JavaScript. The Inspector uses the Content-Type header when deciding which highlighting rules to apply.

The SyntaxView Inspector is one of the most useful Inspectors available for Fiddler, but it is not included in the default install package for size reasons. Fiddler’s installer is currently around 750kb, and including the Syntax Highlighting extensions would nearly double that size. To ensure that Fiddler updates are as compact as possible, the SyntaxView extension is available as a separate download from http://fiddler2.com/r/?SYNTAXVIEWINSTALL.

Along the bottom of the Inspector is a bar which exposes additional features and functionality. First is text which displays the current caret position in Line:Column format. Next is the QuickFind box which enables inline search.

Next is a button which launches advanced Find and Replace functionality. At the far right of the bar is text indicating whether the Inspector is in Read Only or Edit mode.

The QuickFind box supports the use of Regular Expressions; simply prefix your search string with the text REGEX:

and the remainder of the string will be interpreted as a regular expression.

In addition to the standard Cut, Copy, Paste, Undo, and Redo commands, the SyntaxView’s Context Menu offers the following features:

Send to TextWizard Sends the currently-selected text to the TextWizard window for encoding or decoding.

Format XML Attempts to parse the document as XML. If successful, the text is reformatted as an indented XML treeview. This option remains available

129 | Inspectors even when the Inspector is in Read Only mode, but the reformatting is

only permanently applied in Edit mode.

Format Script/JSON Attempts to parse the document as JavaScript/JSON. The text will be reformatted using standard JavaScript indentation styles.

This option remains available even when the Inspector is in Read Only mode, but the reformatting is only permanently applied in Edit mode.

Find… Opens a Find and Replace dialog which offers a variety of search and replacement options.

Word Wrap This checkbox toggles whether text is word-wrapped.

Editor Options… Opens an options window containing dozens of advanced text display options.

130 | Inspectors

T E X T V I E W

Type Request & Response Allows Editing Yes

The TextView Inspector allows you to view the request and response bodies as text. The Inspector truncates its display at the first null byte it finds, and as such is unsuitable for displaying binary content.

Most of the Inspector is a large text area that displays the body text interpreted using the character set detected using the headers, the byte-order-marker, or an embedded META tag declaration. Pressing CTRL+G in the text area allows you to move the cursor to a specific line number. When right-clicking, the text area’s context menu offers standard Cut, Copy and Paste options and a checkbox to enable or disable word wrapping. The menu also offers an option to send the currently selected text to the TextWizard tool.

Along the bottom of the Inspector is a bar that offers additional information and features. The first box shows the current cursor position in Line:Column format. The next box shows the current character offset within the content in Offset/Total format. The third box shows the character count of the current text selection, if any.

Next is a search box that allows you to select matching text within the content. The search text is case-insensitive and does not support regular expressions. Pressing the Up or Down arrow keys in the search box will scroll the text area above (to allow you to view search results in context). Matches are selected as you type, and the box will turn green if a match was found or red if no further matches were found. Pressing Enter or F3 will select the next match. Pressing CTRL+Enter will highlight all matches in the content.

The View in Notepad button saves the text content to a temporary file and opens a text editor to view the file. The text editor launched is controlled by the fiddler.config.path.texteditor preference; notepad.exe is the default.

The … button at the right end of the bar saves the content to a temporary file and shows Windows’ Open With prompt to allow you to select an application to load the file.

131 | Inspectors

T R A N S F O R M E R

Type Response only

Allows Editing Always

In document Debugging With Fiddler (Page 139-149)