#45540 [Fbk->Opn]: stream_context_create creates bad http request

From: Date: Fri, 18 Jul 2008 16:45:04 +0000
Subject: #45540 [Fbk->Opn]: stream_context_create creates bad http request
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-126962@lists.php.net to get a copy of this message
ID: 45540 User updated by: jdespatis at yahoo dot fr Reported By: jdespatis at yahoo dot fr -Status: Feedback +Status: Open Bug Type: Streams related Operating System: Linux Kubuntu PHP Version: 5.2.6 New Comment: enzo@poseidon:~$ cat php-5.2.6/config.nice #! /bin/sh # # Created by configure './configure' \ '--enable-sockets' \ '--enable-soap' \ '--with-mysql' \ '--enable-mbstring' \ '--enable-ftp' \ '--with-zlib' \ '--with-openssl' \ '--prefix=/home/enzo/divers/php_compil/' \ '--exec-prefix=/home/enzo/divers/php_compil/' \ '--disable-short-tags' \ "$@" Previous Comments: ------------------------------------------------------------------------ [2008-07-18 16:05:44] jani@php.net For the second time: What was the configure line you used to build PHP? ------------------------------------------------------------------------ [2008-07-18 12:23:17] jdespatis at yahoo dot fr And to help to diagnose the problem i can perfectly make this script work if I code the stream by my own for example, I replace stream_context_create by some code using fsockopen, all works perfectly ... (i really think stream_context_create leaves some \r \n in some special case ...) $context = stream_context_create($opts); $buff = @file_get_contents("http://uploads.gdata.youtube.com/feeds/api/users/$username/uploads", false, $context); by $fp = fsockopen("uploads.gdata.youtube.com", 80, $errno, $errstr, 30); if (!$fp) { return "Youtube unreachable $errstr ($errno)"; } $out = "POST /feeds/api/users/$username/uploads HTTP/1.0\r\n"; $out .= "Host: uploads.gdata.youtube.com\r\n"; $out .= "Content-Length: " . strlen($opts["http"]["content"] ."\r\n"; $out .= "Connection: Close\r\n"; $out .= $opts["http"]["header"]; $out .= "\r\n"; $out .= $opts["http"]["content"]; fwrite($fp, $out); $buff = ""; while (!feof($fp)) { $buff .= fgets($fp, 4096); } fclose($fp); ------------------------------------------------------------------------ [2008-07-18 08:44:26] jdespatis at yahoo dot fr No this bug is different than bug 43222. In the latter the post content seems to be good except a CRLF more which is not dramatic In my case, the post content and header are completely broken... I've modified my configuration to forbid short open tag (i check with echo ini_get("short_open_tag") which returns nothing meaning false) and i get the same bug. But as I said, one could thing the bug comes from here (i've thought also), but not at all, the bug disappear if i let the short tag <? but change something else Php behavior is really weird... ------------------------------------------------------------------------ [2008-07-17 22:46:57] jani@php.net Are you sure this isn't same issue as reported in bug #43222 ? What was the configure line you used to configure PHP? Is short_open_tag enabled? Check from phpinfo()! ------------------------------------------------------------------------ [2008-07-17 07:14:41] jdespatis at yahoo dot fr Oups, my script bug.php contains a function To test it, one can use this simple script : (no need to create a nothing.mp4 to use this example) <?php include("bug.php"); $params = array("username" => "bigbluezen", "password" => "demo", "title" => "ultimate video topmoumoute", "tags" => "test machin bidule", "channel" => "poetic"); print_r(publish("nothing.mp4", $params)); ?> ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/45540 -- Edit this bug report at http://bugs.php.net/?id=45540&edit=1

« previous php.bugs (#126962) next »