【问题标题】:HTTP Get not using PortHTTP Get 不使用端口
【发布时间】:2012-06-18 09:52:47
【问题描述】:

我正在尝试使用 http_get 调用 PHP 中的页面:

$url = "http://mysite.fr:9090/neolane-webservice/campagnesclient/Coclico=1135446";
http_get($url, $appelOptions, $appelInfos);

我的问题是它不是每次都有效。

我安装了 Wireshark 以查看我真正发送的内容,但我发现了一件奇怪的事情。有时,该端口不用于 HTTP 请求。

当它起作用时,我有:

Hypertext Transfer Protocol
GET http://mysite.fr:9090/neolane-webservice/campagnesclient/Coclico=1135446 HTTP/1.1\r\n
    Request Method: GET
    Request URI: http://mysite.fr:9090/neolane-webservice/campagnesclient/Coclico=1135446
    Request Version: HTTP/1.1
User-Agent: PECL::HTTP/1.6.5 (PHP/5.2.4-2ubuntu5.7)\r\n
Host: mysite.fr:9090\r\n
Pragma: no-cache\r\n
Accept: */*\r\n
Proxy-Connection: Keep-Alive\r\n
Keep-Alive: 300\r\n
Connection: keep-alive\r\n
Date: Fri, 15 Jun 2012 16:40:46 +0200\r\n
Accept-Charset: utf-8\r\n
Accept-Encoding: gzip;q=1.0,deflate;q=0.5\r\n
\r\n

如果不是:

Hypertext Transfer Protocol
GET http://mysite.fr:9090/neolane-webservice/campagnesclient/Coclico=1135446 HTTP/1.1\r\n
    Request Method: GET
    Request URI: http://mysite.fr:9090/neolane-webservice/campagnesclient/Coclico=1135446
    Request Version: HTTP/1.1
User-Agent: PECL::HTTP/1.6.5 (PHP/5.2.4-2ubuntu5.7)\r\n
Host: mysite.fr\r\n
Pragma: no-cache\r\n
Accept: */*\r\n
Proxy-Connection: Keep-Alive\r\n
Keep-Alive: 300\r\n
Connection: keep-alive\r\n
Date: Fri, 15 Jun 2012 16:40:34 +0200\r\n
Accept-Charset: utf-8\r\n
Accept-Encoding: gzip;q=1.0,deflate;q=0.5\r\n
\r\n

我尝试使用 wget 调用该页面,但它一直在工作:

wget http://mysite.fr:9090/neolane-webservice/campagnesclient/Coclico=1135446

所以我猜我的问题 id 是由于 Apache 配置,但我不知道去哪里找。你能帮我吗?

【问题讨论】:

  • $appelOptions = Array ( [url] => mysite.fr:9090/neolane-webservice/campagnesclient/… [compress] => 1 [headers] => Array ( [Keep-Alive] => 300 [Connection] => keep-alive [日期] => 2012 年 6 月 18 日星期一 16:47:54 +0200 [接受字符集] => utf-8 ) [超时] => 10 [代理主机] => myproxy );

标签: http http-headers apache2 neolane


【解决方案1】:

您需要在$appelOptions 数组中设置端口。

$appelOptions['port']=9090;
http_get($url, $appelOptions, $appelInfos);

不幸的是,http_get 似乎不尊重 URL 中的 :port 语法

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-07
    • 2018-09-26
    • 1970-01-01
    • 2011-03-23
    相关资源
    最近更新 更多