-2

I am trying to make a GET request in PHP using cURL and here is what the documentation says about my header:

Append an HTTP header called zuluapi using the created signature.

zuluapi <publicKey>:<base 64 encoded signature>

I have the publicKey and signature, I just can't seem to figure out how to attach the header in the way they want. When I try to add the header, like below, I get bad header error.

$headers = [
    "zuluapi {$public}:{$signedMessage}"
]; 
tylerkmw
  • 37
  • 1
  • 5
  • @ADyson No, because it doesn't address why the above header returns a bad header error despite being in the same format they requested. – tylerkmw Feb 20 '20 at 15:07
  • Can you debug the variables (or randomized structually identical data) used ? – YouriKoeman Feb 20 '20 at 15:11
  • @tylerkmw hmm...can you show how you attach `$headers` to your cURL request, please? In most of those examples in the link I gave, they use an associative array, not just an array of simple strings. e.g. `$headers = [ "zuluapi" => "{$public}:{$signedMessage}" ];`. That way the name of the header and the content of the header are distinct. Try it like that, at least. Also, all you've shown us here is variable names. Have you done a `var_dump($headers);` after your command to ensure the variables actually contain the exact values you were expecting? – ADyson Feb 20 '20 at 15:18
  • Also...exactly what is generating the error? The remote server, or cURL? Please show the exact error message and where it comes from – ADyson Feb 20 '20 at 15:19
  • And I should have said, the one which doesn't use associative syntax puts a colon between the header name and the values. https://stackoverflow.com/a/28347848/5947043 – ADyson Feb 20 '20 at 16:50

1 Answers1

-1

The header structure is indeed invalid.

Look for the specification (rfc): https://www.rfc-editor.org/rfc/rfc7230#section-3.2.3

No whitespace is allowed between the header field-name and colon. In the past, differences in the handling of such whitespace have led to security vulnerabilities in request routing and response handling.

You are not allowed to use whitespace in the header name.

Since i am not familiar with the api you are trying to make requests to and did not provide any links to the docs i am going to give you some examples, pick the one that works for you.

// Posibility #1
$headers = [
    "zuluapi{$public}: {$signedMessage}"
]; 

// Posibility #2
$headers = [
    "zuluapi-{$public}: {$signedMessage}"
]; 
Community
  • 1
  • 1
YouriKoeman
  • 768
  • 3
  • 10