the different between Post and Get

本文详细对比了GET与POST两种HTTP请求方法的区别,包括数据传输方式、数据大小限制、安全性及应用场景等方面,帮助开发者理解何时使用何种请求方法。
1、Get 方法通过 URL 请求来传递用户的数据,将表单内各字段名称与其内容,以成对的字符串连接,置于 action 属性所指程序的 url 后,如[url]http://www.mdm.com/test.asp?name=asd&password=sad[/url],数据都会直接显示在 url 上,就像用户点击一个链接一样;Post 方法通过 HTTP post 机制,将表单内各字段名称与其内容放置在 HTML 表头(header)内一起传送给服务器端交由 action 属性能所指的程序处理,该程序会通过标准输入(stdin)方式,将表单的数据读出并加以处理


2、 Get 方式需要使用 Request.QueryString 来取得变量的值;而 Post 方式通过 Request.Form 来访问提交的内容


3、Get 方式传输的数据量非常小,一般限制在 2 KB 左右,但是执行效率却比 Post 方法好;而 Post 方式传递的数据量相对较大,它是等待服务器来读取数据,不过也有字节限制,这是为了避免对服务器用大量数据进行恶意攻击,根据微软方面的说法,微软对用 Request.Form() 可接收的最大数据有限制,IIS 4 中为 80 KB 字节,IIS 5 中为 100 KB 字节

建议:除非你肯定你提交的数据可以一次性提交,否则请尽量用 Post 方法


4、Get 方式提交数据,会带来安全问题,比如一个登陆页面,通过 Get 方式提交数据时,用户名和密码将出现在 URL 上,如果页面可以被缓存或者其他人可以访问客户这台机器,就可以从历史记录获得该用户的帐号和密码,所以表单提交建议使用 Post 方法;Post 方法提交的表单页面常见的问题是,该页面如果刷新的时候,会弹出一个对话框

建议:出于安全性考虑,建议最好使用 Post 提交数据
The PostMessage function is used to post a message to the message queue of a thread. This function is one of the ways to communicate between different threads in Windows. To hook the PostMessage function, you can use the Detours library provided by Microsoft. Detours allows you to intercept function calls and redirect them to your own function. Here's an example of how to hook the PostMessage function using Detours: ```c++ #include <windows.h> #include <detours.h> // Define a function pointer for the original PostMessage function typedef BOOL (WINAPI *POSTMESSAGE)(HWND, UINT, WPARAM, LPARAM); // Define a global variable to hold the address of the original PostMessage function POSTMESSAGE g_pOrigPostMessage = NULL; // Define your own PostMessage function BOOL WINAPI MyPostMessage(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) { // Do something before calling the original PostMessage function // ... // Call the original PostMessage function BOOL bRet = g_pOrigPostMessage(hWnd, Msg, wParam, lParam); // Do something after calling the original PostMessage function // ... return bRet; } // Hook the PostMessage function BOOL HookPostMessage() { // Get the address of the original PostMessage function HMODULE hUser32 = GetModuleHandle("user32.dll"); g_pOrigPostMessage = (POSTMESSAGE)GetProcAddress(hUser32, "PostMessageA"); // Detour the PostMessage function to your own function if (DetourTransactionBegin() == NO_ERROR) { if (DetourUpdateThread(GetCurrentThread()) == NO_ERROR) { if (DetourAttach(&(PVOID&)g_pOrigPostMessage, MyPostMessage) == NO_ERROR) { if (DetourTransactionCommit() == NO_ERROR) { return TRUE; } } } } return FALSE; } // Unhook the PostMessage function BOOL UnhookPostMessage() { // Detour the PostMessage function back to the original function if (DetourTransactionBegin() == NO_ERROR) { if (DetourUpdateThread(GetCurrentThread()) == NO_ERROR) { if (DetourDetach(&(PVOID&)g_pOrigPostMessage, MyPostMessage) == NO_ERROR) { if (DetourTransactionCommit() == NO_ERROR) { return TRUE; } } } } return FALSE; } // Example usage int main() { // Hook the PostMessage function if (HookPostMessage()) { // Call the PostMessage function PostMessage(NULL, WM_USER, 0, 0); // Unhook the PostMessage function UnhookPostMessage(); } return 0; } ``` Note that the Detours library is not officially supported by Microsoft and is intended for research and experimentation purposes only. Use it at your own risk.
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值