@@ -25,6 +25,8 @@ class Proxy {
2525 private $ output_buffering = true ;
2626 private $ output_buffer = '' ;
2727
28+ private $ status_found = false ;
29+
2830 public function __construct (){
2931 $ this ->dispatcher = new EventDispatcher ();
3032 }
@@ -38,9 +40,11 @@ private function header_callback($ch, $headers){
3840 $ parts = explode (": " , $ headers , 2 );
3941
4042 // extract status code
41- if (preg_match ('/HTTP\/1.\d+ (\d+)/ ' , $ headers , $ matches )){
42-
43+ // if using proxy - we ignore this header: HTTP/1.1 200 Connection established
44+ if (preg_match ('/HTTP\/1.\d+ (\d+)/ ' , $ headers , $ matches ) && stripos ($ headers , '200 Connection established ' ) === false ){
45+
4346 $ this ->response ->setStatusCode ($ matches [1 ]);
47+ $ this ->status_found = true ;
4448
4549 } else if (count ($ parts ) == 2 ){
4650
@@ -50,7 +54,7 @@ private function header_callback($ch, $headers){
5054 // this must be a header: value line
5155 $ this ->response ->headers ->set ($ name , $ value , false );
5256
53- } else {
57+ } else if ( $ this -> status_found ) {
5458
5559 // this is hacky but until anyone comes up with a better way...
5660 $ event = new ProxyEvent (array ('request ' => $ this ->request , 'response ' => $ this ->response , 'proxy ' => &$ this ));
0 commit comments