Skip to content
This repository has been archived by the owner on Apr 27, 2023. It is now read-only.

Fixing case for x-jwt-token #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Conversation

rmckeel
Copy link

@rmckeel rmckeel commented Jun 1, 2017

Response headers come back with case sensitive "X-Jwt-Token". The field "X-Jwt-Token" seems to be case sensitive. That is, checking $response['headers']['x-jwt-token'] does not work, whereas checking $response['headers']['X-Jwt-Token'] does work.

Correcting case sensitivity issue in this codebase.

Response headers come back with case sensitive "X-Jwt-Token".  Correcting case in this codebase.
@rmckeel rmckeel mentioned this pull request Jun 1, 2017
@travist
Copy link
Member

travist commented Jun 1, 2017

Hey Ryan,

Thanks for your contribution. I would prefer to have it so that it is case insensitive so that we don't possibly break other cases. I would propose making the following change to the getHeaders method. Let me know if this works.

private function getHeaders($header) {
    $headers = array();
    foreach (explode("\r\n", $header) as $i => $line) {
      if ($i === 0) {
        $headers['http_code'] = $line;
      }
      else {
        list ($key, $value) = explode(': ', $line);
        $headers[strtolower($key)] = $value;
      }
    }
    return $headers;
  }

Notice the strtolower when assigning the key.

@rmckeel
Copy link
Author

rmckeel commented Jun 1, 2017

Travis, that works great! That is more resilient than what I was thinking.

I was thinking about adding some PHP documentation and a little formatting. Does that seem reasonable, or do you already have it in a format and doc style you like?

@rmckeel
Copy link
Author

rmckeel commented Jun 16, 2017

Creating new pull request with minimal changes, except strtolower change for response header alignment.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants