Nefunkcni HttpRequest vs PECL: pecl_http

Upozornění: Tohle vlákno je hodně staré a informace nemusí být platné pro současné Nette.
grivaldu
Člen | 13
+
0
-

Zdravim, delam RESTful API nad Nette a po instalaci php_http z PECL, ktere potrebuju pro funkcni http_get_request_body prestane fungovat HttpRequest s chybou: HttpRequest::__construct() expects at most 3 parameters, 9 given

PHP: 5.3.1 (Win build VC6 thread-safe)

PECL: php_http (php_http-5.3-svn20091125-vc6-x86.zip)

NETTE: version 2.0-dev released on 2011–02–06 (non-prefix pro 5.2)

Parametry, ktere se predavaji v ramci HttpRequest::__construct() jsou:

$url

UriScript(10) ▼ {
   "scriptPath" private => "/neco/www/" (18)
   "scheme" private => "http" (4)
   "user" private => ""
   "pass" private => ""
   "host" private => "localhost" (9)
   "port" private => 80
   "path" private => "/neco/www/user/" (23)
   "query" private => ""
   "fragment" private => ""
   "frozen" private => FALSE
}

$method

array(0)

$options

array(0)

#3

array(0)

#4

array(2) ▼ {
   "PHPSESSID" => "kbmn732tsl94ieeof8ojser0d4" (26)
   "nette-browser" => "97s4hfcoux" (10)
}

#5

array(10) ▼ {
   "host" => "localhost" (9)
   "user-agent" => "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13" (90)
   "accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" (63)
   "accept-language" => "en-us,en;q=0.5" (14)
   "accept-encoding" => "gzip,deflate" (12)
   "accept-charset" => "ISO-8859-1,utf-8;q=0.7,*;q=0.7" (30)
   "keep-alive" => "115" (3)
   "connection" => "keep-alive" (10)
   "cookie" => "PHPSESSID=kbmn732tsl94ieeof8ojser0d4; nette-browser=97s4hfcoux" (62)
   "cache-control" => "max-age=0" (9)
}

#6

"GET" (3)

#7

"127.0.0.1" (9)

#8

NULL

Editoval grivaldu (26. 2. 2011 23:44)

grivaldu
Člen | 13
+
0
-

Pro zajimavost takto vypada __construct() param backtrace z vypnutou extension:

$uri

UriScript(10) ► {
   "scriptPath" private => "/neco/www/" (18)
   "scheme" private => "http" (4)
   "user" private => ""
   "pass" private => ""
   "host" private => "localhost" (9)
   "port" private => 80
   "path" private => "/neco/www/user/" (23)
   "query" private => ""
   "fragment" private => ""
   "frozen" private => FALSE
}

$query

array(0)

$post

array(0)

$files

array(0)

$cookies

array(2) ▼ {
   "PHPSESSID" => "kbmn732tsl94ieeof8ojser0d4" (26)
   "nette-browser" => "97s4hfcoux" (10)
}

$headers

array(10) ► {
   "host" => "localhost" (9)
   "user-agent" => "Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13) Gecko/20101203 Firefox/3.6.13" (90)
   "accept" => "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8" (63)
   "accept-language" => "en-us,en;q=0.5" (14)
   "accept-encoding" => "gzip,deflate" (12)
   "accept-charset" => "ISO-8859-1,utf-8;q=0.7,*;q=0.7" (30)
   "keep-alive" => "115" (3)
   "connection" => "keep-alive" (10)
   "cookie" => "PHPSESSID=kbmn732tsl94ieeof8ojser0d4; nette-browser=97s4hfcoux" (62)
   "cache-control" => "max-age=0" (9)
}

$method

"GET" (3)

$remoteAddress

"127.0.0.1" (9)

$remoteHost

NULL

Editoval grivaldu (26. 2. 2011 23:54)

grivaldu
Člen | 13
+
0
-

Beru zpet, problem je prave v pouziti non-prefixed verze. PHP_HTTP pouziva stejne pojmenovanou tridu http://www.php.net/…prequest.php jako Nette.

Editoval grivaldu (27. 2. 2011 0:31)

voda
Člen | 561
+
0
-

Tluče se ti třída HttpRequest z pecl s třídou HttpRequest z Nette.

Vzhledem k tomu, že máš PHP 5.3 doporučuju použít namespace verzi Nette. Prefixed taky bude fungovat.

grivaldu
Člen | 13
+
0
-

Bohuzel to nejde, klient ma totiz na svych serverech PHP5.2 a v nejblizsich mesicich jine mit urcite bude.

Editoval grivaldu (27. 2. 2011 0:46)

voda
Člen | 561
+
0
-

Tak v tom případě prefixed verzi pro PHP 5.2.