对 POST 和 GET 的 HTTP 响应
假设我们正在讨论返回相同的内容,那么对 POST 和 GET 的 HTTP 响应是否相同?使用 GET,要访问图像之类的内容,我所要做的就是将浏览器指向 URL。然而,对于 POST,我似乎无法找出任何方法来做同样的事情。如何仅使用简单的 HTML 进行 POST 并在响应中显示图像,而不需要客户端脚本来处理响应?
Assuming we're talking about the same content being returned, are HTTP responses to POST and GET identical? With GET, all I have to do to access something like an image is point my browser to the URL. With POST however, I can't seem to figure out any way of doing the same. How would I do a POST and display the image in the response using nothing more than simple HTML, and without the need for client-side scripting to handle the response?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
创建一个指向图像 URL 的表单并提交。
相关服务器是否支持这个问题只有您才能回答。
这样的构造至少没有意义。 GET 用于幂等请求,POST 用于非幂等请求。
Create a form pointing to the image's URL and submit it.
Whether that's supported by the server in question is a question only you can answer.
Such a construct at least doesn't make sense. GET is intented for idempotent requests and POST for non-idempotent requests.
您可能喜欢 POST-REDIRECTT-GET 模式: http://en.wikipedia.org/维基/发布/重定向/获取。每个浏览器都可以正确处理该问题,无需客户端脚本,并且不会破坏 GET/POST 语义。
You might like the POST-REDIRECTT-GET pattern: http://en.wikipedia.org/wiki/Post/Redirect/Get. Each browser will handle that correctly without client-side scripting, and it does not break the GET/POST semantics.