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
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem:
9 + 39 = ?
Subscribe to this entry?

 
 [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

Add a Patch

Pull Requests

Add a Pull Request

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: Tue Apr 23 15:01:32 2024 UTC