PHP  
 PHP_HEAD
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

Test Failure Report for ext/curl/tests/curl_CURLOPT_READDATA.phpt ('Test CURLOPT_READDATA without a callback function')

Script

1: <?php
2:
3:
include 'server.inc';
4:
$host curl_cli_server_start();
5:
// The URL to POST to
6:
$url $host '/get.inc?test=post';
7:
8:
// Create a temporary file to read the data from
9:
$tempname tempnam(sys_get_temp_dir(), 'CURL_DATA');
10:
$datalen file_put_contents($tempname"hello=world&smurf=blue");
11:
12:
ob_start();
13:
14:
$ch curl_init($url);
15:
curl_setopt($chCURLOPT_URL$url);
16:
curl_setopt($chCURLOPT_POSTtrue);
17:
curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
18:
curl_setopt($chCURLOPT_READDATAfopen($tempname'rb'));
19:
curl_setopt($chCURLOPT_HTTPHEADER, array('Expect:'"Content-Length: {$datalen}"));
20:
21: if (
false === $response curl_exec($ch)) {
22:     echo 
'Error #' curl_errno($ch) . ': ' curl_error($ch);
23: } else {
24:     echo 
$response;
25: }
26:
27:
curl_close($ch);
28:
29:
// Clean the temporary file
30:
@unlink($tempname);
31:

Expected

array(2) {
  ["hello"]=>
  string(5) "world"
  ["smurf"]=>
  string(4) "blue"
}

Output

<?php
  $test = isset($_GET['test']) ? $_GET['test'] : null;
  switch($test) {
    case 'post':
      var_dump($_POST);
      break;
    case 'getpost':
      var_dump($_GET);
      var_dump($_POST);
      break;
    case 'referer':
      echo $_SERVER['HTTP_REFERER'];
      break;
    case 'useragent':
      echo $_SERVER['HTTP_USER_AGENT'];
      break;
    case 'httpversion':
      echo $_SERVER['SERVER_PROTOCOL'];
      break;
    case 'cookie':
      echo $_COOKIE['foo'];
      break;
    case 'encoding':
      echo $_SERVER['HTTP_ACCEPT_ENCODING'];
      break;
    case 'contenttype':
      header('Content-Type: text/plain;charset=utf-8');
      break;
    case 'file':
      if (isset($_FILES['file'])) {
          echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
      }
      break;
    case 'method':
      echo $_SERVER['REQUEST_METHOD'];
      break;
    default:
      echo "Hello World!\n";
      echo "Hello World!";
      break;
  }
?>

Diff

001+ <?php
002+   $test = isset($_GET['test']) ? $_GET['test'] : null;
003+   switch($test) {
004+     case 'post':
005+       var_dump($_POST);
006+       break;
001- array(2) {
002-   ["hello"]=>
003-   string(5) "world"
004-   ["smurf"]=>
005-   string(4) "blue"
006- }
007+     case 'getpost':
008+       var_dump($_GET);
009+       var_dump($_POST);
010+       break;
011+     case 'referer':
012+       echo $_SERVER['HTTP_REFERER'];
013+       break;
014+     case 'useragent':
015+       echo $_SERVER['HTTP_USER_AGENT'];
016+       break;
017+     case 'httpversion':
018+       echo $_SERVER['SERVER_PROTOCOL'];
019+       break;
020+     case 'cookie':
021+       echo $_COOKIE['foo'];
022+       break;
023+     case 'encoding':
024+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
025+       break;
026+     case 'contenttype':
027+       header('Content-Type: text/plain;charset=utf-8');
028+       break;
029+     case 'file':
030+       if (isset($_FILES['file'])) {
031+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
032+       }
033+       break;
034+     case 'method':
035+       echo $_SERVER['REQUEST_METHOD'];
036+       break;
037+     default:
038+       echo "Hello World!\n";
039+       echo "Hello World!";
040+       break;
041+   }
042+ ?>

 

Generated at Mon, 06 May 2019 17:58:35 +0000 (50 days ago)

Copyright © 2005-2019 The PHP Group
All rights reserved.