<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>fiddler 彙整 - 泰克哪裡去</title>
	<atom:link href="https://tech.uccu.website/tag/fiddler/feed" rel="self" type="application/rss+xml" />
	<link>https://tech.uccu.website/tag/fiddler</link>
	<description>一個科技相關的隨手記錄網站</description>
	<lastBuildDate>Sat, 17 Sep 2022 20:53:34 +0000</lastBuildDate>
	<language>zh-TW</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.8.1</generator>
<site xmlns="com-wordpress:feed-additions:1">119574712</site>	<item>
		<title>利用Fiddler(Classic)上傳檔案</title>
		<link>https://tech.uccu.website/post-file-by-fiddler.html?utm_source=rss&#038;utm_medium=rss&#038;utm_campaign=post-file-by-fiddler</link>
					<comments>https://tech.uccu.website/post-file-by-fiddler.html#respond</comments>
		
		<dc:creator><![CDATA[鳴人]]></dc:creator>
		<pubDate>Thu, 17 Feb 2022 10:02:41 +0000</pubDate>
				<category><![CDATA[工具應用]]></category>
		<category><![CDATA[fiddler]]></category>
		<guid isPermaLink="false">https://tech.uccu.website/?p=1685</guid>

					<description><![CDATA[<p>Fiddler是一個好用的Web封包攔截分析工具，也是一個不錯的Web測試工具。前一篇「Asp.Net Cor ... <a title="利用Fiddler(Classic)上傳檔案" class="read-more" href="https://tech.uccu.website/post-file-by-fiddler.html" aria-label="Read more about 利用Fiddler(Classic)上傳檔案">閱讀全文</a></p>
<p>這篇文章 <a href="https://tech.uccu.website/post-file-by-fiddler.html">利用Fiddler(Classic)上傳檔案</a> 最早出現於 <a href="https://tech.uccu.website">泰克哪裡去</a>。</p>
]]></description>
										<content:encoded><![CDATA[
<p>Fiddler是一個好用的Web封包攔截分析工具，也是一個不錯的Web測試工具。<br>前一篇「<a href="https://tech.uccu.website/asp-net-core-kestrel-set-max-request-body-size.html">Asp.Net Core Kestrel設定Request Body Size</a>」調整了Request body size之後，因為要測試的Api是直接從Request.Body取得Stream，沒辦法透過Swagger的Web UI介面來選擇檔案上傳，所以就用到了Fiddler這套軟體。</p>



<span id="more-1685"></span>



<p>通常使用Fiddler的時候是從左邊選擇對應的Request記錄，從右邊的「Inspectors」頁籤中查看攔截下來的內容，畫面如下：</p>



<figure class="wp-block-image size-large"><img data-recalc-dims="1" fetchpriority="high" decoding="async" width="1024" height="603" src="https://i0.wp.com/storage.googleapis.com/stateless-tech-uccu-website/2022/02/4673158d-image-1024x603.png?resize=1024%2C603&#038;ssl=1" alt="" class="wp-image-1688" srcset="https://i0.wp.com/storage.googleapis.com/stateless-tech-uccu-website/2022/02/4673158d-image.png?resize=1024%2C603&amp;ssl=1 1024w, https://i0.wp.com/storage.googleapis.com/stateless-tech-uccu-website/2022/02/4673158d-image.png?resize=300%2C177&amp;ssl=1 300w, https://i0.wp.com/storage.googleapis.com/stateless-tech-uccu-website/2022/02/4673158d-image.png?resize=768%2C452&amp;ssl=1 768w, https://i0.wp.com/storage.googleapis.com/stateless-tech-uccu-website/2022/02/4673158d-image.png?w=1203&amp;ssl=1 1203w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>不過若是要透過Fiddler來發出Request進行測試，則是需要切換到「Composer」這個功能頁籤，如果是要上傳檔案的話則是選擇下圖藍色框的「Upload file&#8230;」文字來選擇檔案，選完檔案之後會在下面的Request Body加入一些文字：</p>



<figure class="wp-block-image size-large"><img data-recalc-dims="1" decoding="async" width="1024" height="603" src="https://i0.wp.com/storage.googleapis.com/stateless-tech-uccu-website/2022/02/ff641277-image-1024x603.png?resize=1024%2C603&#038;ssl=1" alt="" class="wp-image-1691" srcset="https://i0.wp.com/storage.googleapis.com/stateless-tech-uccu-website/2022/02/ff641277-image.png?resize=1024%2C603&amp;ssl=1 1024w, https://i0.wp.com/storage.googleapis.com/stateless-tech-uccu-website/2022/02/ff641277-image.png?resize=300%2C177&amp;ssl=1 300w, https://i0.wp.com/storage.googleapis.com/stateless-tech-uccu-website/2022/02/ff641277-image.png?resize=768%2C452&amp;ssl=1 768w, https://i0.wp.com/storage.googleapis.com/stateless-tech-uccu-website/2022/02/ff641277-image.png?w=1203&amp;ssl=1 1203w" sizes="(max-width: 1024px) 100vw, 1024px" /></figure>



<p>如果後端的Api是直接透過Request.Body取得Stream來作為檔案的話，只要保留上圖第二個藍色框的「&lt;@INCLUDE &#8230;  @&gt;」這一段文字即可，否則取得的Stream會無法如預期的作為檔案的Stream，例如下面的程式碼就是透過Request.Body將Stream直接作為zip檔案使用，如果包含藍色框以外的文字，就會有Exception。</p>



<pre class="wp-block-prismatic-blocks"><code class="language-csharp">try
{
    using (var zip = new ZipArchive(Request.Body))
    {
        return Ok();
    }
} catch (InvalidDataException)
{
    return BadRequest(&quot;body is not in zip format&quot;);
}</code></pre>



<p></p>
<p>這篇文章 <a href="https://tech.uccu.website/post-file-by-fiddler.html">利用Fiddler(Classic)上傳檔案</a> 最早出現於 <a href="https://tech.uccu.website">泰克哪裡去</a>。</p>
]]></content:encoded>
					
					<wfw:commentRss>https://tech.uccu.website/post-file-by-fiddler.html/feed</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">1685</post-id>	</item>
	</channel>
</rss>
