|
| 1 | +title: nginx fastcgi module shutdown eof test |
| 2 | + |
| 3 | +name: nginx-fastcgi-finish-shutdown-eof |
| 4 | + |
| 5 | +description: | |
| 6 | + Test for the issue with fastcgi_finish_request() behaviour that does not end requests with no body, allowing setting |
| 7 | + response header for the next request. This was reported in https://github.com/php/php-src/pull/18516 . |
| 8 | +
|
| 9 | +labels: [test, fcgi, net, nginx, bug] |
| 10 | + |
| 11 | +parameters: |
| 12 | + fpm_address_type: net |
| 13 | + fpm_uds_name: "" |
| 14 | + |
| 15 | +environments: |
| 16 | + local: |
| 17 | + ports: |
| 18 | + start: 8525 |
| 19 | + end: 8529 |
| 20 | + |
| 21 | +resources: |
| 22 | + scripts: |
| 23 | + index.php: | |
| 24 | + <?php |
| 25 | + // this is required to stop nginx from buffering the response (and otherwise this error doesn't happen) |
| 26 | + header('X-Accel-Buffering: no'); |
| 27 | + register_shutdown_function(static function () { |
| 28 | + register_shutdown_function(static function () { |
| 29 | + // this is required, otherwise it won't happen |
| 30 | + fastcgi_finish_request(); |
| 31 | + |
| 32 | + // the "sleep" is what creates the issue. A usleep for a shorter amount of time seems to be enough though |
| 33 | + sleep(1); |
| 34 | + |
| 35 | + // echoing arbitrary text with a space before any ":" will cause nginx to report: |
| 36 | + // upstream sent invalid header: "a\x20..." while reading response header from upstream |
| 37 | + // echo 'a b'; |
| 38 | + // outputting text that looks like a header, will set this as response header for the page we redirect to |
| 39 | + echo 'X-Risky: yes'; |
| 40 | + }); |
| 41 | + }); |
| 42 | +
|
| 43 | +services: |
| 44 | + fpm: |
| 45 | + server: |
| 46 | + name: fpm |
| 47 | + configs: |
| 48 | + fpm_conf: |
| 49 | + include: true |
| 50 | + parameters: |
| 51 | + address_type: net |
| 52 | + pool_options: |
| 53 | + pm: static |
| 54 | + pm.max_children: 1 |
| 55 | + catch_workers_output: yes |
| 56 | + php_ini: |
| 57 | + include: true |
| 58 | + resources: |
| 59 | + scripts: true |
| 60 | + |
| 61 | + nginx: |
| 62 | + requires: [fpm] |
| 63 | + public: true |
| 64 | + server: |
| 65 | + name: nginx |
| 66 | + configs: |
| 67 | + fastcgi_params: {} |
| 68 | + nginx_conf: |
| 69 | + parameters: |
| 70 | + upstream_address_type: net |
| 71 | + dest_service: fpm |
| 72 | + worker_connections: 4 |
| 73 | + root_location_directives: |
| 74 | + fastcgi_keep_conn: on |
| 75 | + |
| 76 | + resources: |
| 77 | + scripts: true |
| 78 | + |
| 79 | +actions: |
| 80 | + - start |
| 81 | + - parallel: |
| 82 | + actions: |
| 83 | + - expect/fpm/server_start |
| 84 | + - expect/nginx/server_start |
| 85 | + - request/nginx: |
| 86 | + path: /index.php |
| 87 | + - expect/nginx: |
| 88 | + response: |
| 89 | + status: 200 |
| 90 | + - execute/nginx: |
| 91 | + command: sleep 2 |
| 92 | + - expect/nginx: |
| 93 | + response: |
| 94 | + status: 200 |
| 95 | + - request/nginx: |
| 96 | + path: /index.php |
| 97 | + - expect/nginx: |
| 98 | + response: |
| 99 | + status: 200 |
| 100 | + - not: |
| 101 | + action: |
| 102 | + expect/nginx: |
| 103 | + response: |
| 104 | + headers: |
| 105 | + X-Risky: yes |
| 106 | + - stop: |
| 107 | + when: always |
| 108 | + - parallel: |
| 109 | + when: always |
| 110 | + actions: |
| 111 | + - expect/fpm/server_stop |
| 112 | + - expect/nginx/server_stop |
| 113 | + |
0 commit comments