您的位置:首页 > 产品设计 > UI/UE

Simulate a Form POST Request Using WinInet

2001-11-22 01:27 351 查看

这是MSDN中的一篇文章,说的是用WinInet来模拟表单的发送,用的是VC及SDK两种方法实现的,用文中方法便可以实现直接将表单发送到WEB服务器上了,比直接在网页上填表高明多了。

原文较短且很简单,就没翻译,直接帖上来了,没弄明白MSDN中的算转帖还是算收藏,反正哪位仁兄能用上就行了

HOWTO: Simulate a Form POST Request Using WinInet

Last reviewed: February 10, 1998
Article ID: Q165298
The information in this article applies to:
The Microsoft Foundation Classes (MFC) included with: - Microsoft Visual C++, 32-bit Editions, versions 4.2, 5.0

Microsoft Internet Client SDK, versions 4.0, 4.01

SUMMARY

To properly simulate a Form submission using WinInet, you need to send a header that indicates the proper Content-Type. For Forms, the proper Content-Type header is:


MORE INFORMATION

In many cases, the server does not respond appropriately if a Content-Type is not specified. For example, the Active Server Pages component of IIS 3.0 actually checks this header specifically for 'application/x-www-form- urlencoded' before adding form variables to the "Request.Form" object. This MIME/Content-Type indicates that the data of the request is a list of URL- encoded form variables. URL-encoding means that space character (ASCII 32) is encoded as '+', special character such '!' encoded in hexadecemal form as '%21'.

Here is a snippet of code that uses the MFC WinInet classes to simulate a Form POST request:

Without MFC, the same code translates to straight SDK calls as follows:

REFERENCES

For more information on URL-encoding and the format of a Form POST request, see section 8.2 in RFC 1866.

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐