Advertisement
Guest User

Simple test case showing flush() wrecking PHP and Apache

a guest
Dec 28th, 2020
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.68 KB | None | 0 0
  1. library.php:
  2. ------------
  3. <?php
  4.  
  5. function foo() {
  6. }
  7.  
  8. ?>
  9.  
  10.  
  11. error.php:
  12. ----------
  13. <?php
  14.  
  15. error_reporting(E_ALL);
  16. require_once 'library.php';
  17.  
  18. echo 'I will deal with a 500 error and show a pretty error message';
  19.  
  20. ?>
  21.  
  22.  
  23. test.php:
  24. ---------
  25. <?php
  26.  
  27. error_reporting(E_ALL);
  28. require_once 'library.php';
  29.  
  30. $test = 1; // Try all 3 tests
  31.  
  32. if ($test == 1) {
  33.     header('Foo: Bar');
  34.     flush();
  35.     echo 'I worked absolutely fine';
  36. }
  37.  
  38. if ($test == 2) {
  39.     header('Foo : Bar'); // Only change
  40.     echo 'I went wrong but did so gracefully';
  41. }
  42.  
  43.  
  44. if ($test == 3) {
  45.     header('Foo : Bar');
  46.     flush(); // Only change
  47.     echo 'I fell to pieces in a horrendous and nonsensical way';
  48. }
  49.  
  50. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement