

FastCGI: comm with server “/usr/lib/cgi-bin/php5-fcgi” aborted: error parsing headers: duplicate header ‘Content-Type’
Qualche giorno fa abbiamo verificato che il Gestore dei file media, quello che si apre quando vogliamo inserire una immagine nel CMS per capirci, non mostrava le thumbnails delle immagini; scelta l’iimagine questa era però ben visibile sia nell’editor wysiwyg, sia nel frontend di Magento.
Controllando i log abbiamo riscontrato l’errore riportato sopra, ossia un
1 |
FastCGI: comm with server "/usr/lib/cgi-bin/php5-fcgi" aborted: error parsing headers: duplicate header 'Content-Type', referer: https://xxxxxx.xxx/index.php/admin/cms_wysiwyg_images/thumbnail/file/bG9nb19pZmJiLnBuZw--/key/3d37ff057d327cd0f3e001b16747fe5f/ |
Facendo una ricerca su internet abbiamo trovato questo utile post (qui), che spiega come l’errore sia dovuto ad una errata creazione dell’header inviato e come sia risolvibile sostiuendo la funzione sendHeaders() di app/code/core/Mage/Core/Controller/Response/Http.php con questa
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
public function sendHeaders() { if (!$this->canSendHeaders()) { Mage::log('HEADERS ALREADY SENT: '.mageDebugBacktrace(true, true, true)); return $this; } if (in_array(substr(php_sapi_name(), 0, 3), array('cgi', 'fpm'))) { // remove duplicate headers $remove = array('status', 'content-type'); // already sent headers $sent = array(); foreach (headers_list() as $header) { // parse name if (!$pos = strpos($header, ':')) continue; $sent[strtolower(substr($header, 0, $pos))] = true; } // raw headers $headersRaw = array(); foreach ($this->_headersRaw as $i=>$header) { // parse name if (!$pos = strpos($header, ':')) continue; $name = strtolower(substr($header, 0, $pos)); if (in_array($name, $remove)) { // check sent headers if ($sent[$name]) { unset($this->_headersRaw[$i]); continue; } // check header if (!is_null($existing = $headers[$name])) { $this->_headersRaw[$existing] = $header; unset($this->_headersRaw[$i]); } else $headersRaw[$name] = $i; } } // object headers $headers = array(); foreach ($this->_headers as $i=>$header) { $name = strtolower($header['name']); if (in_array($name, $remove)) { // check sent headers if ($sent[$name]) { unset($this->_headers[$i]); continue; } // check header if (!is_null($existing = $headers[$name])) { $this->_headers[$existing] = $header; unset($this->_headers[$i]); } else $headers[$name] = $i; // check raw headers if (!is_null($existing = $headersRaw[$name])) unset($this->_headersRaw[$existing]); } } } parent::sendHeaders(); } |