ajax 如何从 Firefox 或 Chrome 浏览器手动发送 HTTP POST 请求?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4797534/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-06 10:56:49  来源:igfitidea点击:

How to manually send HTTP POST requests from Firefox or Chrome browser?

ajaxgoogle-chromefirefoxhttp-post

提问by Pascal Klein

I want to test some URLs on a web application I'm working on. For that I would like to manually create HTTP POST requests (meaning I can add whatever parameters I like).

我想在我正在处理的 Web 应用程序上测试一些 URL。为此,我想手动创建 HTTP POST 请求(这意味着我可以添加任何我喜欢的参数)。

Is there any extension or functionality in Chrome and/or Firefox that I'm missing?

Chrome 和/或 Firefox 中是否有我缺少的任何扩展程序或功能?

回答by Abhinav

I have been making a Chrome app called Postmanfor this type of stuff. All the other extensions seemed a bit dated so made my own. It also has a bunch of other features which have been helpful for documenting our own API here.

我一直在为这种类型的东西制作一个名为Postman的 Chrome 应用程序。所有其他扩展似乎有点过时,所以我自己做了。它还具有许多其他功能,这些功能有助于在此处记录我们自己的 API。



Postman now also has native apps(i.e. standalone) for Windows, Mac and Linux! It is more preferable now to use native apps, read more here.

Postman 现在也有适用于 Windows、Mac 和 Linux 的本地应用程序(即独立的)!现在更可取的是使用本机应用程序,请在此处阅读更多内容。

回答by Arno 2501

CURLis AWESOME to do what you want ! It's a simple but effective command line tool.

CURL很棒,可以做你想做的事!这是一个简单但有效的命令行工具。

Rest implementation test commands :

休息实现测试命令:

curl -i -X GET http://rest-api.io/items
curl -i -X GET http://rest-api.io/items/5069b47aa892630aae059584
curl -i -X DELETE http://rest-api.io/items/5069b47aa892630aae059584
curl -i -X POST -H 'Content-Type: application/json' -d '{"name": "New item", "year": "2009"}' http://rest-api.io/items
curl -i -X PUT -H 'Content-Type: application/json' -d '{"name": "Updated item", "year": "2010"}' http://rest-api.io/items/5069b47aa892630aae059584

回答by 0fnt

Firefox

火狐

Open Network panel in Developer Tools by pressing Ctrl+Shift+Eor by going Menubar -> Tools -> Web Developer -> Network. Then Click on small door icon on top-right (in expanded form in the screenshot, you'll find it just left of the highlighted Headers), second row (if you don't see it then reload the page) -> Edit and resend whatever request you want

通过按Ctrl+Shift+E或转到菜单栏 -> 工具 -> Web 开发人员 -> 网络,在开发人员工具中打开网络面板。然后单击右上角的小门图标(在屏幕截图中以展开形式,您会在突出显示的标题左侧找到它),第二行(如果您没有看到它,则重新加载页面)-> 编辑和重新发送您想要的任何请求

Firefox Dev Tools with button "Edit and Resent" highlighted

Firefox 开发工具突出显示了“编辑和重新发送”按钮

POST request body highlighted

POST 请求正文突出显示

回答by amra

Forget browser and try CLI. HTTPieis great tool!

忘记浏览器并尝试 CLI。HTTPie是个好工具!

enter image description here

在此处输入图片说明

CLIhttp clients:

CLIhttp 客户端:

If you insist on browser extension then:

如果你坚持浏览器扩展,那么:

Chrome:

Firefox:

火狐

回答by Nathan Osman

Having been greatly inspired by Postman for Chrome, I decided to write something similar for Firefox.

受到Postman for Chrome 的极大启发,我决定为 Firefox 编写类似的东西。

REST Easy* is a restartless Firefox add-on that aims to provide as much control as possible over requests. The add-on is still in an experimental state (it hasn't even been reviewed by Mozilla yet)but development is progressing nicely.

REST Easy* 是一个无需重启的 Firefox 插件,旨在尽可能多地控制请求。该附加组件仍处于实验状态(Mozilla 尚未对其进行审核),但开发进展顺利。

The project is open source, so if anyone feels compelled to help with development, that would be awesome: https://github.com/nathan-osman/Rest-Easy

该项目是开源的,所以如果有人觉得有必要帮助开发,那就太棒了:https: //github.com/nathan-osman/Rest-Easy

* the add-on available from http://addons.mozilla.orgwill always be slightly behind the code available on GitHub

* 可从http://addons.mozilla.org获得的附加组件将始终稍微落后于 GitHub 上的可用代码

回答by dumbledad

You specifically asked for "extension or functionality in Chrome and/or Firefox", which the answers you have already received provide, but I do like the simplicity of oezi's answer to the closed question "how to send a post request with a web browser"for simple parameters. oezi says:

您特别要求“Chrome 和/或 Firefox 中的扩展或功能”,您已经收到了这些答案,但我确实喜欢oezi 对封闭式问题“如何使用网络浏览器发送帖子请求”的简单回答对于简单的参数。oezi 说:

with a form, just set methodto "post"

使用表格,只需设置method"post"

<form action="blah.php" method="post">
  <input type="text" name="data" value="mydata" />
  <input type="submit" />
</form>

I.e. build yourself a very simple page to test the post actions.

即为自己建立一个非常简单的页面来测试发布操作。

回答by Nate

It's a bit ugly, but there's the Simple REST Clientextension for Chrome.

它有点难看,但有适用于 Chrome的Simple REST Client扩展。

It works great for me -- do remember that you can still use the debugger with it. The Network pane is particularly useful; it'll give you rendered JSON objects and error pages.

它对我很有用——请记住,您仍然可以使用调试器。网络窗格特别有用;它会给你呈现的 JSON 对象和错误页面。

回答by Johan Falk

For firefox there is also an extension called RESTClient which is quite nice:

对于 Firefox,还有一个名为 RESTClient 的扩展,它非常好:

https://addons.mozilla.org/en-US/firefox/addon/restclient

https://addons.mozilla.org/en-US/firefox/addon/restclient

回答by Vineel Kovvuri

May not be directly related to browsers but fiddleris another good software.

可能与浏览器没有直接关系,但fiddler是另一个不错的软件。

Fiddler web debugger

Fiddler 网络调试器

回答by Bennett Brown

Try Runscope. A free tool sampling their service is provided at https://www.hurl.it/. You can set the method, authentication, headers, parameters, and body. Response shows status code, headers, and body. The response body can be formatted from JSON with a collapsable heirarchy. Paid accounts can automate test API calls and use return data to build new test calls. COI disclosure: I have no relationship to Runscope.

尝试运行范围。https://www.hurl.it/提供了免费工具对其服务进行采样。您可以设置方法、身份验证、标头、参数和正文。响应显示状态代码、标题和正文。响应正文可以从具有可折叠层次结构的 JSON 格式化。付费账户可以自动化测试 API 调用并使用返回数据来构建新的测试调用。COI 披露:我与 Runscope 没有任何关系。