HTTP POST 方法是否将数据作为 QueryString 发送? [英] Do HTTP POST methods send data as a QueryString?

查看:21
本文介绍了HTTP POST 方法是否将数据作为 QueryString 发送?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道 HTTP 上的 POST 方法是将数据作为 QueryString 发送,还是使用特殊结构将数据传递给服务器.

事实上,当我分析从客户端到服务器的 POST 方法的通信时(例如使用 Fiddler),我没有看到任何 QueryString,而是一个带有名称/值对的 Form Body 上下文.

解决方案

可视化这一点的最佳方法是使用数据包分析器,例如 查询字符串使用的,但如果您使用的是 SOAP Web 服务,它也可以使用 多部分 MIME 格式和 XML 数据.

例如,这里是对位于 http://192.168.24.23 的基于 XML 的 SOAP Web 服务的 HTTP POST:8090/msh 看起来像 Wireshark 跟随 TCP 流:

I'd like to know if the POST method on HTTP sends data as a QueryString, or if it use a special structure to pass the data to the server.

In fact, when I analyze the communication with POST method from client to server (with Fiddler for example), I don't see any QueryString, but a Form Body context with the name/value pairs.

解决方案

The best way to visualize this is to use a packet analyzer like Wireshark and follow the TCP stream. HTTP simply uses TCP to send a stream of data starting with a few lines of HTTP headers. Often this data is easy to read because it consists of HTML, CSS, or XML, but it can be any type of data that gets transfered over the internet (Executables, Images, Video, etc).

For a GET request, your computer requests a specific URL and the web server usually responds with a 200 status code and the the content of the webpage is sent directly after the HTTP response headers. This content is the same content you would see if you viewed the source of the webpage in your browser. The query string you mentioned is just part of the URL and gets included in the HTTP GET request header that your computer sends to the web server. Below is an example of an HTTP GET request to http://accel91.citrix.com:8000/OA_HTML/OALogout.jsp?menu=Y, followed by a 302 redirect response from the server. Some of the HTTP Headers are wrapped due to the size of the viewing window (these really only take one line each), and the 302 redirect includes a simple HTML webpage with a link to the redirected webpage (Most browsers will automatically redirect any 302 response to the URL listed in the Location header instead of displaying the HTML response):

For a POST request, you may still have a query string, but this is uncommon and does not have anything to do with the data that you are POSTing. Instead, the data is included directly after the HTTP headers that your browser sends to the server, similar to the 200 response that the web server uses to respond to a GET request. In the case of POSTing a simple web form this data is encoded using the same URL encoding that a query string uses, but if you are using a SOAP web service it could also be encoded using a multi-part MIME format and XML data.

For example here is what an HTTP POST to an XML based SOAP web service located at http://192.168.24.23:8090/msh looks like in Wireshark Follow TCP Stream:

这篇关于HTTP POST 方法是否将数据作为 QueryString 发送?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆