php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #70607 fastcgi_finish_request bug
Submitted: 2015-09-30 12:04 UTC Modified: 2015-09-30 15:11 UTC
From: machin dot dmitry at gmail dot com Assigned:
Status: Closed Package: FPM related
PHP Version: 7.0.0RC3 OS: Ubuntu 14.04.3 LTS
Private report: No CVE-ID: None
 [2015-09-30 12:04 UTC] machin dot dmitry at gmail dot com
Description:
------------
When execute normal and then execute ajax request - after page relaod in the $_SERVER variable present - HTTP_X_REQUESTED_WITH.

This behavior reproduced only when used fastcgi_finish_request fucntion.

Test code to check: https://gist.github.com/madmis/313f99b45b23b506a6e6
More details about bug: http://stackoverflow.com/questions/32847635/php-7-http-x-requested-with-xmlhttprequest-out-of-nowhere

Test script:
---------------
<?php

$requestType = $_SERVER['HTTP_X_REQUESTED_WITH'] ?? 'not ajax';

$html = <<<EOL
<html>
    <!-- BEGIN HEAD -->
    <head lang="en">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="robots" content="noindex, nofollow" />
        <title>HUB - Client List</title>
        <script src="//code.jquery.com/jquery-2.1.4.js"></script>
    </head>
<body>

<strong>$requestType</strong>

<script>
    $(function() {
      $.get('index.php?test=test');
    });

    $(function() {
        setTimeout(function() {
               // $.get('index.php?test=test');
        }, 500);

        setTimeout(function() {
               // $.get('index.php?test=test');
        }, 1500);
    });
</script>
</body>
</html>
EOL;

if (!isset($_GET['test'])) {
    echo $html;
    var_dump($_SERVER);
} else {
    echo json_encode(['data' => 'any data']);
}
fastcgi_finish_request();


Expected result:
----------------
not ajax

Actual result:
--------------
XMLHttpRequest

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2015-09-30 12:28 UTC] laruence@php.net
-Status: Open +Status: Feedback
 [2015-09-30 12:28 UTC] laruence@php.net
Please try using this snapshot:

  http://snaps.php.net/php-trunk-latest.tar.gz
 
For Windows:

  http://windows.php.net/snapshots/

it should already be fixed , see #70279
 [2015-09-30 12:49 UTC] machin dot dmitry at gmail dot com
-Status: Feedback +Status: Open
 [2015-09-30 12:49 UTC] machin dot dmitry at gmail dot com
A havn't access to this page - http://snaps.php.net/php-trunk-latest.tar.gz.

But as i understand - fixed in RC4.
I will try to check it.
Thank you.
 [2015-09-30 15:11 UTC] machin dot dmitry at gmail dot com
-Status: Open +Status: Closed
 [2015-09-30 15:11 UTC] machin dot dmitry at gmail dot com
fixed
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sun Dec 22 06:01:30 2024 UTC