php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #50347 $http_response_header does not get populated by file_put_contents stream
Submitted: 2009-12-01 00:56 UTC Modified: 2009-12-01 08:59 UTC
From: php at hm2k dot org Assigned:
Status: Not a bug Package: Streams related
PHP Version: 5.3.1 OS:
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: php at hm2k dot org
New email:
PHP Version: OS:

 

 [2009-12-01 00:56 UTC] php at hm2k dot org
Description:
------------
When using file_put_contents(), $http_response_header does not populate as expected.

Reproduce code:
---------------
<?php
$file=tempnam('','');
$url='http://example.com/';
file_put_contents($file,$url);
var_dump($http_response_header);

Expected result:
----------------
array(9) {
  [0]=>
  string(15) "HTTP/1.1 200 OK"
  [1]=>
  string(35) "Date: Sat, 12 Apr 2008 17:30:38 GMT"
  [2]=>
  string(29) "Server: Apache/2.2.3 (CentOS)"
  [3]=>
  string(44) "Last-Modified: Tue, 15 Nov 2005 13:24:10 GMT"
  [4]=>
  string(27) "ETag: "280100-1b6-80bfd280""
  [5]=>
  string(20) "Accept-Ranges: bytes"
  [6]=>
  string(19) "Content-Length: 438"
  [7]=>
  string(17) "Connection: close"
  [8]=>
  string(38) "Content-Type: text/html; charset=UTF-8"
}

Actual result:
--------------
false

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-12-01 08:35 UTC] jani@php.net
What exactly are you trying to do? Write to HTTP? 
 [2009-12-01 08:43 UTC] php at hm2k dot org
Your question is already answered by the sample code I provided.

For clarification: file_put_contents() is reading from a URL and writing to a temp file.
 [2009-12-01 08:47 UTC] jani@php.net
Well, your script only writes 'http://example.com' string to the $file.
RTFM: http://php.net/file_put_contents
 [2009-12-01 08:59 UTC] php at hm2k dot org
Ah, touché, I need to open the stream first.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Sat Dec 21 15:01:29 2024 UTC