相关疑难解决方法(0)

如何用curl做PUT请求?

如何使用curl测试RESTful PUT(或DELETE)方法?

rest curl http

381
推荐指数
5
解决办法
40万
查看次数

PHP cURL内容长度和内容类型错误

我正在尝试通过PHP cURL登录网站,我只收到"错误请求"响应.

我玩了hosts文件并将其设置到我的服务器,以检查我的浏览器发送的请求标头,并将其与cURL发送的请求标头进行比较.

一切都是平等的,除了:

浏览器:

Content-Type: application/x-www-form-urlencoded
Content-Length: 51
Run Code Online (Sandbox Code Playgroud)

PHP cURL:

Content-Length: 51, 359
Content-Type: application/x-www-form-urlencoded; boundary=----------------------------5a377b7e6ba7
Run Code Online (Sandbox Code Playgroud)

我已经使用此命令设置了这些值,但它仍然发送错误的标头:

curl_setopt($this->hCurl, CURLOPT_HTTPHEADER, array(
    'Expect:',
    'Content-Type: application/x-www-form-urlencoded',
    'Content-Length: 51' 
));
Run Code Online (Sandbox Code Playgroud)

php curl header request

11
推荐指数
1
解决办法
3万
查看次数

标签 统计

curl ×2

header ×1

http ×1

php ×1

request ×1

rest ×1