Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[BrowserKit] Impossible to specify request content-type #36640

Copy link
Copy link
Closed
@ro0NL

Description

@ro0NL
Issue body actions

Symfony version(s) affected: 4.4

Description

$headers = $this->getHeaders($request);
[$body, $extraHeaders] = $this->getBodyAndExtraHeaders($request);
$response = $this->client->request($request->getMethod(), $request->getUri(), [
'headers' => array_merge($headers, $extraHeaders),

$extraHeaders includes a content-type, guessed here:

if (null !== $content = $request->getContent()) {
$part = new TextPart($content, 'utf-8', 'plain', '8bit');
return [$part->bodyToString(), $part->getPreparedHeaders()->toArray()];
}

and it's effectively overwriting the existing one in $headers due the array_merge.

dd($headers, $extraHeaders, array_merge($headers, $extraHeaders));
array:6 [
  "user-agent" => "Symfony BrowserKit"
  "content-type" => "application/json"
]
array [
  0 => "Content-Type: text/plain; charset=utf-8"
  1 => "Content-Transfer-Encoding: 8bit"
]
array [
  "user-agent" => "Symfony BrowserKit"
  "content-type" => "application/json"
  0 => "Content-Type: text/plain; charset=utf-8"
  1 => "Content-Transfer-Encoding: 8bit"
]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.