011.phpt 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. --TEST--
  2. header_remove()
  3. --SKIPIF--
  4. <?php include "skipif.inc"; ?>
  5. --FILE--
  6. <?php
  7. include "include.inc";
  8. $php = get_cgi_path();
  9. reset_env_vars();
  10. $f = tempnam(sys_get_temp_dir(), 'cgitest');
  11. function test($script) {
  12. file_put_contents($GLOBALS['f'], $script);
  13. $cmd = escapeshellcmd($GLOBALS['php']);
  14. $cmd .= ' -n -dreport_zend_debug=0 -dhtml_errors=0 ' . escapeshellarg($GLOBALS['f']);
  15. echo "----------\n";
  16. echo rtrim($script) . "\n";
  17. echo "----------\n";
  18. passthru($cmd);
  19. }
  20. test('<?php ?>');
  21. test('<?php header_remove(); ?>');
  22. test('<?php header_remove("X-Foo"); ?>');
  23. test('<?php
  24. header("X-Foo: Bar");
  25. ?>');
  26. test('<?php
  27. header("X-Foo: Bar");
  28. header("X-Bar: Baz");
  29. header_remove("X-Foo");
  30. ?>');
  31. test('<?php
  32. header("X-Foo: Bar");
  33. header_remove("X-Foo: Bar");
  34. ?>');
  35. test('<?php
  36. header("X-Foo: Bar");
  37. header_remove("X-Foo:");
  38. ?>');
  39. test('<?php
  40. header("X-Foo: Bar");
  41. header_remove();
  42. ?>');
  43. test('<?php
  44. header_remove("");
  45. ?>');
  46. test('<?php
  47. header_remove(":");
  48. ?>');
  49. test('<?php
  50. header("X-Foo: Bar");
  51. echo "flush\n";
  52. flush();
  53. header_remove("X-Foo");
  54. ?>');
  55. @unlink($f);
  56. ?>
  57. --EXPECTF--
  58. ----------
  59. <?php ?>
  60. ----------
  61. X-Powered-By: PHP/%s
  62. Content-type: text/html; charset=UTF-8
  63. ----------
  64. <?php header_remove(); ?>
  65. ----------
  66. Content-type: text/html; charset=UTF-8
  67. ----------
  68. <?php header_remove("X-Foo"); ?>
  69. ----------
  70. X-Powered-By: PHP/%s
  71. Content-type: text/html; charset=UTF-8
  72. ----------
  73. <?php
  74. header("X-Foo: Bar");
  75. ?>
  76. ----------
  77. X-Powered-By: PHP/%s
  78. X-Foo: Bar
  79. Content-type: text/html; charset=UTF-8
  80. ----------
  81. <?php
  82. header("X-Foo: Bar");
  83. header("X-Bar: Baz");
  84. header_remove("X-Foo");
  85. ?>
  86. ----------
  87. X-Powered-By: PHP/%s
  88. X-Bar: Baz
  89. Content-type: text/html; charset=UTF-8
  90. ----------
  91. <?php
  92. header("X-Foo: Bar");
  93. header_remove("X-Foo: Bar");
  94. ?>
  95. ----------
  96. X-Powered-By: PHP/%s
  97. X-Foo: Bar
  98. Content-type: text/html; charset=UTF-8
  99. Warning: Header to delete may not contain colon. in %s on line 3
  100. ----------
  101. <?php
  102. header("X-Foo: Bar");
  103. header_remove("X-Foo:");
  104. ?>
  105. ----------
  106. X-Powered-By: PHP/%s
  107. X-Foo: Bar
  108. Content-type: text/html; charset=UTF-8
  109. Warning: Header to delete may not contain colon. in %s on line 3
  110. ----------
  111. <?php
  112. header("X-Foo: Bar");
  113. header_remove();
  114. ?>
  115. ----------
  116. Content-type: text/html; charset=UTF-8
  117. ----------
  118. <?php
  119. header_remove("");
  120. ?>
  121. ----------
  122. X-Powered-By: PHP/%s
  123. Content-type: text/html; charset=UTF-8
  124. ----------
  125. <?php
  126. header_remove(":");
  127. ?>
  128. ----------
  129. X-Powered-By: PHP/%s
  130. Content-type: text/html; charset=UTF-8
  131. Warning: Header to delete may not contain colon. in %s on line 2
  132. ----------
  133. <?php
  134. header("X-Foo: Bar");
  135. echo "flush\n";
  136. flush();
  137. header_remove("X-Foo");
  138. ?>
  139. ----------
  140. X-Powered-By: PHP/%s
  141. X-Foo: Bar
  142. Content-type: text/html; charset=UTF-8
  143. flush
  144. Warning: Cannot modify header information - headers already sent by (output started at %s:3) in %s on line 5