服务器实际上收到请求了吗,您是否在正确处理主机名(别名)?
添加到我的.hosts文件后
检查您的网络服务器日志,以了解请求是如何传入的...
curl可以选择转储发送的请求和接收到的响应,这称为跟踪,它将被保存到文件中。
- 跟踪
如果缺少主机或标头信息,则可以使用config选项强制使用这些标头。
我将在命令行上使用curl请求,然后尝试在PHP中实现。
config选项是
-K /-配置
卷曲相关的选项在这里
--trace启用将所有传入和传出数据(包括描述性信息)完整地跟踪转储到给定输出文件的功能。使用“-”作为文件名可以将输出发送到stdout。
This option overrides previous uses of -v/--verbose or --trace-ascii.
If this option is used several times, the last one will be used.
-K /-config指定从哪个配置文件读取curl参数。配置文件是一个文本文件,可以在其中写入命令行参数,然后将其用作实际在命令行上写入的参数。选项及其参数必须在同一配置文件行中指定,并用空格,冒号,等号或其任意组合分隔(但是,首选分隔符为等号)。如果参数包含空格,则必须将参数用引号引起来。在双引号中,可以使用以下转义序列:\,\“,\ t,\ n,\ r和\ v。忽略任何其他字母前面的反斜杠。如果配置行的第一列是'#'字符,该行的其余部分将被视为注释。
Specify the filename to -K/--config as '-' to make curl read the file from stdin.
Note that to be able to specify a URL in the config file, you need to specify it using the --url option, and not by simply writing the URL on its own line. So, it could look similar to this:
url = "http://curl.haxx.se/docs/"
Long option names can optionally be given in the config file without the initial double dashes.
When curl is invoked, it always (unless -q is used) checks for a default config file and uses it if found. The default config file is checked for in the following places in this order:
1) curl tries to find the "home dir": It first checks for the CURL_HOME and then the HOME environment variables. Failing that, it uses getpwuid() on UNIX-like systems (which returns the home dir
given the current user in your system). On Windows, it then checks for the APPDATA variable, or as a last resort the '%USERPROFILE%\Application Data'.
2) On windows, if there is no _curlrc file in the home dir, it checks for one in the same dir the curl executable is placed. On UNIX-like systems, it will simply try to load .curlrc from the deter-
mined home dir.
# --- Example file ---
# this is a comment
url = "curl.haxx.se"
output = "curlhere.html"
user-agent = "superagent/1.0"
# and fetch another URL too
url = "curl.haxx.se/docs/manpage.html"
-O
referer = "http://nowhereatall.com/"
# --- End of example file ---
This option can be used multiple times to load multiple config files.