Skip to content

Fix setting X-Ably-* and Accept headers#133

Merged
owenpearson merged 1 commit intomainfrom
fix-http-headers
Feb 23, 2022
Merged

Fix setting X-Ably-* and Accept headers#133
owenpearson merged 1 commit intomainfrom
fix-http-headers

Conversation

@lmars
Copy link
Copy Markdown
Member

@lmars lmars commented Feb 22, 2022

The CURLOPT_HTTPHEADER value should be an array of <key>: <val> strings representing the headers to set.

See https://www.php.net/manual/en/function.curl-setopt.php

Tested manually by running the following program:

require_once __DIR__ . '/vendor/autoload.php';
$settings = array(
  'key'  => '8YPQbA.H2SX3g:************',
  'logLevel' => 4,
);
$app = new \Ably\AblyRest($settings);
$channel = $app->channel('test');
$channel->publish('test', array('handle' => 'x', 'message' => 'y') );

And observing the headers being set correctly in the verbose logs:

2022-02-22 22:12:15     cURL command:   2022-02-22 22:12:15     curl -X POST -X POST --data "{\"data\":\"{\\"handle\\":\\"x\\",\\"message\\":\\"y\\"}\",\"encoding\":\"json\",\"name\":\"test\"}" -H "Authorization: Basic ****************" -H "Accept: application/json" -H "X-Ably-Version: 1.1" -H "X-Ably-Lib: php-1.1.4" -H "Content-Type: application/json" https://rest.ably.io/channels/test/messages

I also confirmed the request was successfully tracked in our internal metrics database.

The CURLOPT_HTTPHEADER value should be an array of '<key>: <val>'
strings representing the headers to set.

See https://www.php.net/manual/en/function.curl-setopt.php

Signed-off-by: Lewis Marshall <lewis.marshall@ably.com>
Copy link
Copy Markdown
Member

@owenpearson owenpearson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM thanks

@owenpearson owenpearson merged commit 58507eb into main Feb 23, 2022
@owenpearson owenpearson deleted the fix-http-headers branch February 23, 2022 10:49
@owenpearson owenpearson linked an issue Feb 23, 2022 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

X-Ably-Lib header not being set correctly

2 participants