gpt4 book ai didi

php - 如何模拟HTTP请求?

转载 作者:可可西里 更新时间:2023-11-01 16:25:11 26 4
gpt4 key购买 nike

如何模拟 HTTP 请求。例如,我想模拟将数据插入我的数据库的请求,以检查我的程序的安全性和可靠性。有什么好的工具吗?

最佳答案

对于 *nix 操作系统,您可以使用 telnetcurlwget 实用程序:

远程登录:

user@host:~$ telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /api.php?param1=10&param2=20 HTTP/1.1 # here is your request params
Host: localhost # required HTTP header
# double ENTER for sending request

检查 telnet man-page您的操作系统的高级选项。

curl :

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&param2=20

检查 curl man-page您的操作系统的高级选项。

Wget:

user@host:~$ wget http://localhost/api.php?param1=10&param2=20

检查 wget man-page您的操作系统的高级选项。

仅供引用 如果您选择curl 那么您将允许使用*nix shell 的强大功能:grepsed , output redirection以及许多其他有用的东西。

关于php - 如何模拟HTTP请求?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19041448/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com