php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #40529 invalid SimpleXMLElement forces HTTP 200 header
Submitted: 2007-02-17 23:17 UTC Modified: 2007-02-18 01:47 UTC
From: PK at eBrain dot nl Assigned:
Status: Not a bug Package: SimpleXML related
PHP Version: 5.2.1 OS: Fedore Core 3
Private report: No CVE-ID: None
 [2007-02-17 23:17 UTC] PK at eBrain dot nl
Description:
------------
When SimpleXMLElement in run on something invalid or empty, the HTTP status code is forced to 200 and can not be influenced later on. Either this is a bug or expected behavior - in the last case, it should be: documented on http://nl2.php.net/simplexml/ + explained how to work around it.

Note: my actual PHP version is: 5.0.4

Reproduce code:
---------------
Note: php://input is empty (i.e. a direct request to the page).


$PostXML = new SimpleXMLElement('php://input');
if (empty($PostXML))
{
	header('HTTP/1.1 400 Bad Request');
}
else
{
	header('HTTP/1.1 202 Accepted');
}

Expected result:
----------------
HTTP Status Code: HTTP/1.1 400

Actual result:
--------------
HTTP Status Code: HTTP/1.1 200

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2007-02-18 01:47 UTC] derick@php.net
Thank you for taking the time to report a problem with PHP.
Unfortunately you are not using a current version of PHP -- 
the problem might already be fixed. Please download a new
PHP version from http://www.php.net/downloads.php

If you are able to reproduce the bug with one of the latest
versions of PHP, please change the PHP version on this bug report
to the version you tested and change the status back to "Open".
Again, thank you for your continued support of PHP.

.
 
PHP Copyright © 2001-2023 The PHP Group
All rights reserved.
Last updated: Thu Feb 09 13:03:40 2023 UTC