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/bug27023.phpt ('Bug #27023 (CURLOPT_POSTFIELDS does not parse content types for files)')

Script

1: <?php
2:
3:
include 'server.inc';
4:
$host curl_cli_server_start();
5:
$ch curl_init();
6:
curl_setopt($chCURLOPT_SAFE_UPLOAD1);
7:
curl_setopt($chCURLOPT_URL"{$host}/get.inc?test=file");
8:
curl_setopt($chCURLOPT_RETURNTRANSFER1);
9:
10:
$file curl_file_create(__DIR__ '/curl_testdata1.txt');
11:
$params = array('file' => $file);
12:
curl_setopt($chCURLOPT_POSTFIELDS$params);
13:
var_dump(curl_exec($ch));
14:
15:
$file curl_file_create(__DIR__ '/curl_testdata1.txt'"text/plain");
16:
$params = array('file' => $file);
17:
curl_setopt($chCURLOPT_POSTFIELDS$params);
18:
var_dump(curl_exec($ch));
19:
20:
$file curl_file_create(__DIR__ '/curl_testdata1.txt'null"foo.txt");
21:
$params = array('file' => $file);
22:
curl_setopt($chCURLOPT_POSTFIELDS$params);
23:
var_dump(curl_exec($ch));
24:
25:
$file curl_file_create(__DIR__ '/curl_testdata1.txt'"text/plain""foo.txt");
26:
$params = array('file' => $file);
27:
curl_setopt($chCURLOPT_POSTFIELDS$params);
28:
var_dump(curl_exec($ch));
29:
30:
31:
curl_close($ch);
32:
?>
33:

Expected

string(%d) "curl_testdata1.txt|application/octet-stream"
string(%d) "curl_testdata1.txt|text/plain"
string(%d) "foo.txt|application/octet-stream"
string(%d) "foo.txt|text/plain"

Output

string(973) "<?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;
  }
?>
"
string(973) "<?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;
  }
?>
"
string(973) "<?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;
  }
?>
"
string(973) "<?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+ string(973) "<?php
002+   $test = isset($_GET['test']) ? $_GET['test'] : null;
003+   switch($test) {
004+     case 'post':
001- string(%d) "curl_testdata1.txt|application/octet-stream"
002- string(%d) "curl_testdata1.txt|text/plain"
003- string(%d) "foo.txt|application/octet-stream"
004- string(%d) "foo.txt|text/plain"
005+       var_dump($_POST);
006+       break;
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+ ?>
043+ "
044+ string(973) "<?php
045+   $test = isset($_GET['test']) ? $_GET['test'] : null;
046+   switch($test) {
047+     case 'post':
048+       var_dump($_POST);
049+       break;
050+     case 'getpost':
051+       var_dump($_GET);
052+       var_dump($_POST);
053+       break;
054+     case 'referer':
055+       echo $_SERVER['HTTP_REFERER'];
056+       break;
057+     case 'useragent':
058+       echo $_SERVER['HTTP_USER_AGENT'];
059+       break;
060+     case 'httpversion':
061+       echo $_SERVER['SERVER_PROTOCOL'];
062+       break;
063+     case 'cookie':
064+       echo $_COOKIE['foo'];
065+       break;
066+     case 'encoding':
067+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
068+       break;
069+     case 'contenttype':
070+       header('Content-Type: text/plain;charset=utf-8');
071+       break;
072+     case 'file':
073+       if (isset($_FILES['file'])) {
074+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
075+       }
076+       break;
077+     case 'method':
078+       echo $_SERVER['REQUEST_METHOD'];
079+       break;
080+     default:
081+       echo "Hello World!\n";
082+       echo "Hello World!";
083+       break;
084+   }
085+ ?>
086+ "
087+ string(973) "<?php
088+   $test = isset($_GET['test']) ? $_GET['test'] : null;
089+   switch($test) {
090+     case 'post':
091+       var_dump($_POST);
092+       break;
093+     case 'getpost':
094+       var_dump($_GET);
095+       var_dump($_POST);
096+       break;
097+     case 'referer':
098+       echo $_SERVER['HTTP_REFERER'];
099+       break;
100+     case 'useragent':
101+       echo $_SERVER['HTTP_USER_AGENT'];
102+       break;
103+     case 'httpversion':
104+       echo $_SERVER['SERVER_PROTOCOL'];
105+       break;
106+     case 'cookie':
107+       echo $_COOKIE['foo'];
108+       break;
109+     case 'encoding':
110+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
111+       break;
112+     case 'contenttype':
113+       header('Content-Type: text/plain;charset=utf-8');
114+       break;
115+     case 'file':
116+       if (isset($_FILES['file'])) {
117+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
118+       }
119+       break;
120+     case 'method':
121+       echo $_SERVER['REQUEST_METHOD'];
122+       break;
123+     default:
124+       echo "Hello World!\n";
125+       echo "Hello World!";
126+       break;
127+   }
128+ ?>
129+ "
130+ string(973) "<?php
131+   $test = isset($_GET['test']) ? $_GET['test'] : null;
132+   switch($test) {
133+     case 'post':
134+       var_dump($_POST);
135+       break;
136+     case 'getpost':
137+       var_dump($_GET);
138+       var_dump($_POST);
139+       break;
140+     case 'referer':
141+       echo $_SERVER['HTTP_REFERER'];
142+       break;
143+     case 'useragent':
144+       echo $_SERVER['HTTP_USER_AGENT'];
145+       break;
146+     case 'httpversion':
147+       echo $_SERVER['SERVER_PROTOCOL'];
148+       break;
149+     case 'cookie':
150+       echo $_COOKIE['foo'];
151+       break;
152+     case 'encoding':
153+       echo $_SERVER['HTTP_ACCEPT_ENCODING'];
154+       break;
155+     case 'contenttype':
156+       header('Content-Type: text/plain;charset=utf-8');
157+       break;
158+     case 'file':
159+       if (isset($_FILES['file'])) {
160+           echo $_FILES['file']['name'] . '|' . $_FILES['file']['type'];
161+       }
162+       break;
163+     case 'method':
164+       echo $_SERVER['REQUEST_METHOD'];
165+       break;
166+     default:
167+       echo "Hello World!\n";
168+       echo "Hello World!";
169+       break;
170+   }
171+ ?>
172+ "

 

Generated at Tue, 19 Mar 2019 00:18:08 +0000 (4 days ago)

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