@@ -144,6 +144,9 @@ public function __construct($user_key, $service_url = 'https://analytics.babelst
144144 'Content-Type ' => 'application/json ' ,
145145 'Accept-Encoding ' => 'gzip ' ,
146146 'User-Agent ' => $ this ->getUserAgent (),
147+ 'X-BabelStreetAPI-Binding ' => 'php ' ,
148+ 'X-BabelStreetAPI-Binding-Version ' => $ this ->getBindingVersion (),
149+ // TODO remove this in future release
147150 'X-RosetteApi-Binding ' => 'php ' ,
148151 'X-RosetteAPI-Binding-Version ' => $ this ->getBindingVersion ());
149152
@@ -170,7 +173,7 @@ public function getBindingVersion()
170173 */
171174 public function getUserAgent ()
172175 {
173- return 'RosetteAPIPHP / ' . $ this ->getBindingVersion () . '/ ' . phpversion ();
176+ return 'Babel-Street-Analytics-API-PHP / ' . $ this ->getBindingVersion () . '/ ' . phpversion ();
174177 }
175178
176179 /**
@@ -379,10 +382,12 @@ public function getCustomHeaders()
379382 */
380383 public function setCustomHeader ($ header , $ value = null )
381384 {
382- $ headerPrefix = 'x-rosetteapi- ' ;
383- if (strlen ($ header ) < strlen ($ headerPrefix ) ||
384- strcasecmp (substr ($ header , 0 , strlen ($ headerPrefix )), $ headerPrefix ) != 0 ) {
385- throw new RosetteException ("Custom headers must start with \"$ headerPrefix \"" );
385+ $ legacyHeaderPrefix = 'x-rosetteapi- ' ;
386+ $ headerPrefix = 'x-babelstreetapi- ' ;
387+ if (strlen ($ header ) < strlen ($ legacyHeaderPrefix ) ||
388+ (strcasecmp (substr ($ header , 0 , strlen ($ headerPrefix )), $ headerPrefix ) != 0 &&
389+ strcasecmp (substr ($ header , 0 , strlen ($ legacyHeaderPrefix )), $ legacyHeaderPrefix ) != 0 )) {
390+ throw new RosetteException ("Custom headers must start with \"$ headerPrefix \" or \"$ legacyHeaderPrefix \"" );
386391 }
387392 if (is_null ($ value ) && array_key_exists ($ header , $ this ->customHeaders )) {
388393 unsset ($ this ->customHeaders , $ header );
0 commit comments