Fiddler添加二进制文件数据到POST

发布于 2024-12-08 06:57:28 字数 155 浏览 1 评论 0原文

我尝试将二进制文件数据直接添加到 POST 调用的请求正文中,以便模拟文件上传。但是,我尝试设置“请求之前”断点并使用“插入文件”,但我似乎无法使其正常工作。我还尝试修改 CustomRules.js 以注入文件,但无法弄清楚如何通过 JScript 加载二进制数据。这里有一个简单的解决方案吗?

I'm try to add binary file data directly to the request body of a POST call so I can simulate a file upload. However, I tried setting a 'before request' breakpoint and using 'insert file' but I couldn't seem to get that to work. I also tried to modify CustomRules.js to inject the file but couldn't figure out how to load binary data via JScript. Is there an easy solution here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

古镇旧梦 2024-12-15 06:57:28

我确信这是自从这个问题得到解答以来今年的一个新功能,但我想无论如何都会添加它:

Composer 中现在有一个蓝色的“[上传文件]”链接,位于 URL 文本框的右侧。这将创建完整的多部分/表单数据请求。如果您使用它,您会注意到正文中现在有类似这样的内容:

<@INCLUDE C:\Some\Path\my-image.jpg@>

就我而言,我只是想直接发布二进制文件而不包含多部分垃圾,所以我只是将 <@INCLUDE ... @>请求正文中的魔法,并将二进制文件作为正文发送。

I'm sure this is a new feature in the year since this question was answered, but thought I'd add it anyhow:

There's a blue "[Upload file]" link in Composer now on the right side under the URL textbox. This will create a full multipart/form-data request. If you use this, you'll notice in the body you now have something that looks like this:

<@INCLUDE C:\Some\Path\my-image.jpg@>

In my case, I just wanted to POST the binary file directly with no multipart junk, so I just put the <@INCLUDE ... @> magic in the request body, and that sends the binary file as the body.

做个少女永远怀春 2024-12-15 06:57:28

为了发送multipart/form-data,此收据将得到帮助。

在上部面板(Http 标头)中,设置 Content-Type 如下。其他值会自动解析。

Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468

并且,在下面的面板中输入响应正文,如下所示。

---------------------------acebdf13572468
Content-Disposition: form-data; name="description" 

the_text_is_here
---------------------------acebdf13572468
Content-Disposition: form-data; name="file"; filename="123.jpg"
Content-Type: image/jpg

<@INCLUDE *C:\Users\Me\Pictures\95111c18-e969-440c-81bf-2579f29b3564.jpg*@>
---------------------------acebdf13572468--

导入规则是,

  1. Content-Type 应该比正文中的边界词多两个 - 符号。
  2. 正文的最后一个部分应以两个 - 符号结束。

In order to send multipart/form-data, this receipe will be helped.

In upper panel (Http header), set Content-Type as below. Other values are automatically resolved.

Content-Type: multipart/form-data; boundary=-------------------------acebdf13572468

And, input Response Body at the below panel as follows.

---------------------------acebdf13572468
Content-Disposition: form-data; name="description" 

the_text_is_here
---------------------------acebdf13572468
Content-Disposition: form-data; name="file"; filename="123.jpg"
Content-Type: image/jpg

<@INCLUDE *C:\Users\Me\Pictures\95111c18-e969-440c-81bf-2579f29b3564.jpg*@>
---------------------------acebdf13572468--

The import rules are,

  1. Content-Type should have two more - signs than boundary words in body.
  2. The last of the body should be ended with two - signs.
忘年祭陌 2024-12-15 06:57:28

在Fiddler脚本中:(在Fiddler:规则...自定义规则中),找到OnBeforeRequest函数,并添加类似于以下内容的行:

if (oSession.uriContains("yourdomain"))
{
    oSession.LoadRequestBodyFromFile("c:\\temp\\binarycontent.dat");    
}

In Fiddler script: (in Fiddler: Rules... Customize Rules), find the OnBeforeRequest function, and add a line similar to:

if (oSession.uriContains("yourdomain"))
{
    oSession.LoadRequestBodyFromFile("c:\\temp\\binarycontent.dat");    
}
梦醒时光 2024-12-15 06:57:28

从版本 2.0 开始,请求正文有一个“上传文件...”链接,允许您发布/上传二进制数据。

since version 2.0, the Request Body has an "Upload File..." link that allows you to post/upload binary data.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文