【问题标题】:php curl post fails from within apache without proxyphp curl post在没有代理的apache内部失败
【发布时间】:2011-12-12 02:06:20
【问题描述】:

我有一个从网页调用的 php 脚本(服务器是 Apache debian 6.03),它使用 curl 执行 GET 和 POST。 GET 没问题。如果 php curl 直接进入网络,则 POST 失败,但如果我使用 charles 作为代理,则工作正常。 (没有尝试过其他代理。)

特别是,如果我添加

curl_setopt($ch, CURLOPT_PROXY, "localhost:8888" );

到我的脚本(查尔斯在 8888 上运行)它成功了。否则我会得到:

"HTTP/1.1 400 Bad Request".

非常感谢任何想法。

【问题讨论】:

    标签: php apache curl proxy


    【解决方案1】:

    哎呀。我的脚本在帖子中使用了 cookie,并且在我构建的 cookie 字符串的开头有空格。添加“修剪”解决了这个问题。

    对不起。

    【讨论】:

      猜你喜欢
      • 2014-09-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多