JHTTP-HEADERS-001

$response->headers['Content-Type'] as string

JHttp response headers are arrays

Joomla 4 HTTP responses follow PSR-7: a header name maps to a list of values, not a string.

$response->headers['Content-Type'] as stringRead header values as an array

Dies at Joomla 3 → 4J3: Works nativelyJ4: Changed behaviourJ6: Changed behaviourBC plugin: not applicablePatch possible — review itJoomla API

Symptoms people search

content-type check fails · JHttp headers

Replace this code

Swap $response->headers['Content-Type'] as string for Read header values as an array.

Joomla 3

Remove or stop calling this

$type = $response->headers['Content-Type'];

Joomla 4 / 6

Use this instead

$type = $response->getHeader('Content-Type')[0] ?? '';

How to fix it

  1. 1Use getHeader() and take [0].
  2. 2Do not strcmp the whole headers array.

Also known as

JHttp · getHeader

Related issues

Get in touch

Have a project in mind? Let's talk about it.

Tell us what you're building. Whether it's a new site, an online store, a mobile app, or something that needs AI under the hood, we'll get back to you within a business day.

Free consultation
No commitment, no pressure
Reply within 24 hours
Usually much faster

Prefer a direct conversation?

Request a project quote

Tell us about your project

Fill out the quick form and we'll reach out.