top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration

Facebook Login
Site Registration

How to set the http_response_header from a custom HTTP wrapper

+4 votes

I wrote a custom HTTP wrapper, but I've hit a snag. I do not know how to populate the $http_response_header variable. So my questions are:

  1. Is it even possible to set $http_response_header from a custom PHP Stream wrapper?
  2. Is there documentation on how to set it?
  3. If there is no official way to set it, then is there a work-a-round way to set $http_response_header?

I follow the following PHP doc on $http_response_header variable:

posted Nov 26, 2014 by Jagan Mishra

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button

1 Answer

+1 vote

I've been researching this myself and will provide you with what I've learned.

It's not possible to set $http_response_header (in the code's local scope) from a custom PHP Stream wrapper. This is officially reported here. As mentioned there, there's discussion of fixing the problem going forward in PHP 7.

The only lead I have to go on for now is the idea mentioned here, which suggests using a 'code transform' that works by intercepting the PHP code and morphing it on the fly. While non-trivial, the link there to the CodeTransform class is a beautiful example of how to do it.

Please put any follow-up on the linked pages. I'm trying to point eyes there.

answer Feb 20, 2015 by Tyler Collier
Similar Questions
+1 vote

We have a set up like Apahce (80,443) redirects the request to Tomcat (8080) using mod_jk.

The new requirement is to route the request from the same apache to another tomcat (8090). Hence I made the different config file for apache with different ports (86,4444) and different worker for mod_jk which routes the request to tomcat.

Now the issue is when I hit the url http://:86 and after providing the credentials, it is redirecting to https://:86 and throwing the below error.

Error in browser:

Secure Connection Failed

An error occurred during a connection to x.x.x.x:86. SSL received a record that exceeded the maximum permissible length. (Error code: ssl_error_rx_record_too_long)

Error in logs:

"x16x03x01" 501

[Thu Jan 08 08:22:46 2015] [debug] ssl_engine_io.c(1523): OpenSSL: I/O error, 11 bytes expected to read on BIO#1bf568 [mem: 1f3930]
[Thu Jan 08 08:22:46 2015] [debug] ssl_engine_kernel.c(1806): OpenSSL: Exit: error in SSLv2/v3 read client hello A
[Thu Jan 08 08:22:46 2015] [info] (70014)End of file found: SSL handshake interrupted by system [Hint: Stop button pressed in browser?!]
[Thu Jan 08 08:22:46 2015] [info] Connection to child 3 closed with abortive shutdown(server [2], client
[Thu Jan 08 08:23:53 2015] [error] [client] Invalid method in request x16x03x01

Could you please suggest where it might went wrong and the way forward..

+1 vote

I am trying to pass a "PHP variable" from Apache (2.2.15) to Tomcat (7.0.27) but without success. The apache is used as front-end server of tomcat using mod_proxy_ajp.

I verified that I can pass only variable set by Apache (e.g. using SetEnv directive); How I can pass a variable set by PHP to Tomcat?

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.