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 string → Read header values as an array
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
- 1Use getHeader() and take [0].
- 2Do not strcmp the whole headers array.
Also known as
JHttp · getHeader
Related issues
- Joomla 3 → 4Joomla API
JRequest::getVar() and the whole JRequest API
JRequest::getVar() → $app->getInput()->get('id')
- Joomla 3 → 4Joomla API
JError / JException
JError::raiseError() → throw new RuntimeException() / try-catch
- Joomla 3 → 4Joomla API
isAdmin() / isSite()
$app->isAdmin() → $app->isClient('administrator') / isClient('site')
- Joomla 3 → 4Joomla API
Factory::getUri()
JFactory::getUri() → Uri::getInstance()
- Joomla 3 → 4Joomla API
Factory::getXml() / JXMLElement
JFactory::getXML() → SimpleXMLElement
- Joomla 3 → 4Joomla API
Factory::getEditor()
JFactory::getEditor() → Editor::getInstance()