note 100559 modified in function.stream-context-create by danbrown

From: Date: Sat, 23 Oct 2010 16:54:49 +0000
Subject: note 100559 modified in function.stream-context-create by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-173403@lists.php.net to get a copy of this message
If you are trying to set a custom http header on php 5.2.x, try this: <?php // build header and set it the usual way $authenticationHeader = $headername . ': ' . $headervalue; $opts = array( 'http' => array( 'header' => $authenticationHeader ) ); // workaround for php bug where http headers don't get sent in php 5.2 if(version_compare(PHP_VERSION, '5.3.0') == -1){ ini_set('user_agent', 'PHP-SOAP/' . PHP_VERSION . "\r\n" . $authenticationHeader); } $context = stream_context_create($opts); // now use context for soap call or whatever... ?> this is the only option that worked for me. --was-- If you are trying to set a custom http header on php 5.2.x, try this: // build header and set it the usual way $authenticationHeader = $headername . ': ' . $headervalue; $opts = array( 'http' => array( 'header' => $authenticationHeader ) ); // workaround for php bug where http headers don't get sent in php 5.2 if(version_compare(PHP_VERSION, '5.3.0') == -1){ ini_set('user_agent', 'PHP-SOAP/' . PHP_VERSION . "\r\n" . $authenticationHeader); } $context = stream_context_create($opts); // now use context for soap call or whatever... this is the only option that worked for me. http://php.net/manual/en/function.stream-context-create.php

« previous php.notes (#173403) next »