ttw*_*ard 2 php networking jquery http request
如何模拟 HTTP 请求。例如,我想模拟向我的数据库中插入数据的请求,以检查我的程序的安全性和可靠性。有什么好的工具吗?
对于 *nix 操作系统,您可以使用telnet、curl或wget实用程序:
远程登录:
user@host:~$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /api.php?param1=10¶m2=20 HTTP/1.1 # here is your request params
Host: localhost # required HTTP header
# double ENTER for sending request
Run Code Online (Sandbox Code Playgroud)
检查您操作系统的telnet 手册页以获取高级选项。
卷曲:
user@host:~$ curl \
--header 'Host: localhost' \
--user-agent 'Mozilla/5.0 (Linux x86_64; rv:10.0.12) Gecko/ Firefox/10.0.12' \
--no-keepalive \
http://localhost/api.php?param1=10¶m2=20
Run Code Online (Sandbox Code Playgroud)
检查您操作系统的curl 手册页以获取高级选项。
获取:
user@host:~$ wget http://localhost/api.php?param1=10¶m2=20
Run Code Online (Sandbox Code Playgroud)
查看操作系统的wget 手册页以获取高级选项。
仅供参考,如果您选择curl,那么您将允许使用 *nix shell 的强大功能:grep、sed、输出重定向和许多其他有用的东西。