Skip to content

Message->setHeader allowing duplicates #2170

Description

@MGatner

Describe the bug
Message->setHeader() will accept any case for headers (as it should) but if different ones are supplied it will produce duplicate headers.

CodeIgniter 4 version
Latest develop branch

Affected module(s)
Message, Response, CURLRequest

Expected behavior, and steps to reproduce if appropriate
Consider the following:

$response = service('response');
$response->setHeader('Content-Type', 'application/json');
$response->setHeader('Content-type', 'application/json');
  	
$headers = $response->getHeaders();
var_dump($headers);

This should produce one header, but it produces two with each case-sensitive key.

EDIT - output of example:

array(2) {
  ["Content-Type"]=>
  object(CodeIgniter\HTTP\Header)#52 (2) {
    ["name":protected]=>
    string(12) "Content-Type"
    ["value":protected]=>
    string(16) "application/json"
  }
  ["Content-type"]=>
  object(CodeIgniter\HTTP\Header)#17 (2) {
    ["name":protected]=>
    string(12) "Content-type"
    ["value":protected]=>
    string(16) "application/json"
  }
}

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions