Changeset 454

Show
Ignore:
Timestamp:
06/08/07 14:57:38 (2 years ago)
Author:
laurentj
Message:

- jResponse::addHttpHeader has an additionnal parameter
- new methode jResponse::clearHttpHeaders()
- ticket #199 : when a response send an error, it now sets the http status code to 500
- ticket #198 : some responses were not manage http header very well
- jResponseBinary now handle errors

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/jelix-modules/jelix/locales/en_EN/errors.ISO-8859-1.properties

    r415 r454  
    2424#---- includer 
    2525includer.source.missing=(140)Includer : the selector "%s" doesn't point to a source file 
     26 
     27#---- responses 
     28repxml.no.content=(150) Undefined content for xml response 
     29repxml.invalid.content=(151) Invalid xml content for xml response 
     30repbin.unknow.file=(152) unknow file for binary response (%s) 
    2631 
    2732#---- locales 
  • trunk/lib/jelix-modules/jelix/locales/en_EN/errors.ISO-8859-1.properties

    r415 r454  
    2424#---- includer 
    2525includer.source.missing=(140)Includer : the selector "%s" doesn't point to a source file 
     26 
     27#---- responses 
     28repxml.no.content=(150) Undefined content for xml response 
     29repxml.invalid.content=(151) Invalid xml content for xml response 
     30repbin.unknow.file=(152) unknow file for binary response (%s) 
    2631 
    2732#---- locales 
  • trunk/lib/jelix-modules/jelix/locales/en_EN/errors.UTF-8.properties

    r415 r454  
    2424#---- includer 
    2525includer.source.missing=(140)Includer : the selector "%s" doesn't point to a source file 
     26 
     27#---- responses 
     28repxml.no.content=(150) Undefined content for xml response 
     29repxml.invalid.content=(151) Invalid xml content for xml response 
     30repbin.unknow.file=(152) unknow file for binary response (%s) 
    2631 
    2732#---- locales 
  • trunk/lib/jelix-modules/jelix/locales/en_EN/errors.UTF-8.properties

    r415 r454  
    2424#---- includer 
    2525includer.source.missing=(140)Includer : the selector "%s" doesn't point to a source file 
     26 
     27#---- responses 
     28repxml.no.content=(150) Undefined content for xml response 
     29repxml.invalid.content=(151) Invalid xml content for xml response 
     30repbin.unknow.file=(152) unknow file for binary response (%s) 
    2631 
    2732#---- locales 
  • trunk/lib/jelix-modules/jelix/locales/en_US/errors.ISO-8859-1.properties

    r415 r454  
    2424#---- includer 
    2525includer.source.missing=(140)Includer : the selector "%s" doesn't point to a source file 
     26 
     27#---- responses 
     28repxml.no.content=(150) Undefined content for xml response 
     29repxml.invalid.content=(151) Invalid xml content for xml response 
     30repbin.unknow.file=(152) unknow file for binary response (%s) 
    2631 
    2732#---- locales 
  • trunk/lib/jelix-modules/jelix/locales/en_US/errors.ISO-8859-1.properties

    r415 r454  
    2424#---- includer 
    2525includer.source.missing=(140)Includer : the selector "%s" doesn't point to a source file 
     26 
     27#---- responses 
     28repxml.no.content=(150) Undefined content for xml response 
     29repxml.invalid.content=(151) Invalid xml content for xml response 
     30repbin.unknow.file=(152) unknow file for binary response (%s) 
    2631 
    2732#---- locales 
  • trunk/lib/jelix-modules/jelix/locales/en_US/errors.UTF-8.properties

    r415 r454  
    2424#---- includer 
    2525includer.source.missing=(140)Includer : the selector "%s" doesn't point to a source file 
     26 
     27#---- responses 
     28repxml.no.content=(150) Undefined content for xml response 
     29repxml.invalid.content=(151) Invalid xml content for xml response 
     30repbin.unknow.file=(152) unknow file for binary response (%s) 
    2631 
    2732#---- locales 
  • trunk/lib/jelix-modules/jelix/locales/en_US/errors.UTF-8.properties

    r415 r454  
    2424#---- includer 
    2525includer.source.missing=(140)Includer : the selector "%s" doesn't point to a source file 
     26 
     27#---- responses 
     28repxml.no.content=(150) Undefined content for xml response 
     29repxml.invalid.content=(151) Invalid xml content for xml response 
     30repbin.unknow.file=(152) unknow file for binary response (%s) 
    2631 
    2732#---- locales 
  • trunk/lib/jelix-modules/jelix/locales/fr_FR/errors.ISO-8859-1.properties

    r415 r454  
    2222#---- includer 
    2323includer.source.missing=(140)Includer : le s�cteur %s n'indique pas de fichier source 
     24 
     25#---- R�nses 
     26repxml.no.content=(150) Aucun contenu d�ni pour la r�nse XML 
     27repxml.invalid.content=(151) Contenu xml invalid pour la r�nse XML 
     28repbin.unknow.file=(152) Fichier inconnu pour la r�nse Binary (%s) 
    2429 
    2530#---- locales 
  • trunk/lib/jelix-modules/jelix/locales/fr_FR/errors.ISO-8859-1.properties

    r415 r454  
    2222#---- includer 
    2323includer.source.missing=(140)Includer : le s�cteur %s n'indique pas de fichier source 
     24 
     25#---- R�nses 
     26repxml.no.content=(150) Aucun contenu d�ni pour la r�nse XML 
     27repxml.invalid.content=(151) Contenu xml invalid pour la r�nse XML 
     28repbin.unknow.file=(152) Fichier inconnu pour la r�nse Binary (%s) 
    2429 
    2530#---- locales 
  • trunk/lib/jelix-modules/jelix/locales/fr_FR/errors.UTF-8.properties

    r415 r454  
    2424#---- includer 
    2525includer.source.missing=(140)Includer : le sélecteur %s n'indique pas de fichier source 
     26 
     27#---- Réponses 
     28repxml.no.content=(150) Aucun contenu défini pour la réponse XML 
     29repxml.invalid.content=(151) Contenu xml invalid pour la réponse XML 
     30repbin.unknow.file=(152) Fichier inconnu pour la réponse Binary (%s) 
    2631 
    2732#---- locales 
     
    7782file.notexists = (23)Le fichier %s n'existe pas 
    7883inifile.write.error = (24)Un problème est survenu lors de l'écriture du fichier ini  %s 
     84 
  • trunk/lib/jelix-modules/jelix/locales/fr_FR/errors.UTF-8.properties

    r415 r454  
    2424#---- includer 
    2525includer.source.missing=(140)Includer : le sélecteur %s n'indique pas de fichier source 
     26 
     27#---- Réponses 
     28repxml.no.content=(150) Aucun contenu défini pour la réponse XML 
     29repxml.invalid.content=(151) Contenu xml invalid pour la réponse XML 
     30repbin.unknow.file=(152) Fichier inconnu pour la réponse Binary (%s) 
    2631 
    2732#---- locales 
     
    7782file.notexists = (23)Le fichier %s n'existe pas 
    7883inifile.write.error = (24)Un problème est survenu lors de l'écriture du fichier ini  %s 
     84 
  • trunk/lib/jelix/core/jResponse.class.php

    r334 r454  
    8888     * @param string $htype the header type ("Content-Type", "Date-modified"...) 
    8989     * @param string $hcontent value of the header type 
     90     * @param boolean $overwrite false if the value should be set only if it doesn't still exist 
    9091     */ 
    91     public function addHttpHeader($htype, $hcontent){ $this->_httpHeaders[$htype]=$hcontent;} 
     92    public function addHttpHeader($htype, $hcontent, $overwrite=true){  
     93        if(!$overwrite && isset($this->_httpHeaders[$htype])) 
     94            return; 
     95        $this->_httpHeaders[$htype]=$hcontent; 
     96    } 
     97 
     98    /** 
     99     * delete all http headers 
     100     */ 
     101    public function clearHttpHeaders(){ 
     102        $this->_httpHeaders = array(); 
     103        $this->_httpStatusCode ='200'; 
     104        $this->_httpStatusMsg ='OK'; 
     105    } 
    92106 
    93107    /** 
  • trunk/lib/jelix/core/jResponse.class.php

    r334 r454  
    8888     * @param string $htype the header type ("Content-Type", "Date-modified"...) 
    8989     * @param string $hcontent value of the header type 
     90     * @param boolean $overwrite false if the value should be set only if it doesn't still exist 
    9091     */ 
    91     public function addHttpHeader($htype, $hcontent){ $this->_httpHeaders[$htype]=$hcontent;} 
     92    public function addHttpHeader($htype, $hcontent, $overwrite=true){  
     93        if(!$overwrite && isset($this->_httpHeaders[$htype])) 
     94            return; 
     95        $this->_httpHeaders[$htype]=$hcontent; 
     96    } 
     97 
     98    /** 
     99     * delete all http headers 
     100     */ 
     101    public function clearHttpHeaders(){ 
     102        $this->_httpHeaders = array(); 
     103        $this->_httpStatusCode ='200'; 
     104        $this->_httpStatusMsg ='OK'; 
     105    } 
    92106 
    93107    /** 
  • trunk/lib/jelix/core/response/jResponseAtom10.class.php

    r386 r454  
    66* @contributor Laurent Jouanneau 
    77* @copyright   2006 Yannick Le Guédart 
    8 * @copyright   2006 Laurent Jouanneau 
     8* @copyright   2006-2007 Laurent Jouanneau 
    99* @link        http://www.jelix.org 
    1010* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    8383    final public function outputErrors() { 
    8484        if (!$this->_headSent) { 
    85             if ($this->_sendHttpHeader) { 
     85            if (!$this->_httpHeadersSent) { 
     86                header("HTTP/1.0 500 Internal Server Error"); 
    8687                header('Content-Type: text/xml;charset='.$this->charset); 
    8788            } 
     
    106107        foreach ($GLOBALS['gJCoord']->errorMessages  as $e) { 
    107108            // FIXME : Pourquoi utiliser htmlentities() ? 
    108            $errors .=  '<error type="'. $e[0] .'" code="'. $e[1] .'" file="'. $e[3] .'" line="'. $e[4] .'">'.htmlentities($e[2], ENT_NOQUOTES, $this->charset). '</error>'. "\n"; 
     109           $errors .=  '<error xmlns="http://jelix.org/ns/xmlerror/1.0" type="'. $e[0] .'" code="'. $e[1] .'" file="'. $e[3] .'" line="'. $e[4] .'">'.htmlentities($e[2], ENT_NOQUOTES, $this->charset). '</error>'. "\n"; 
    109110        } 
    110111        return $errors; 
  • trunk/lib/jelix/core/response/jResponseAtom10.class.php

    r386 r454  
    66* @contributor Laurent Jouanneau 
    77* @copyright   2006 Yannick Le Guédart 
    8 * @copyright   2006 Laurent Jouanneau 
     8* @copyright   2006-2007 Laurent Jouanneau 
    99* @link        http://www.jelix.org 
    1010* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    8383    final public function outputErrors() { 
    8484        if (!$this->_headSent) { 
    85             if ($this->_sendHttpHeader) { 
     85            if (!$this->_httpHeadersSent) { 
     86                header("HTTP/1.0 500 Internal Server Error"); 
    8687                header('Content-Type: text/xml;charset='.$this->charset); 
    8788            } 
     
    106107        foreach ($GLOBALS['gJCoord']->errorMessages  as $e) { 
    107108            // FIXME : Pourquoi utiliser htmlentities() ? 
    108            $errors .=  '<error type="'. $e[0] .'" code="'. $e[1] .'" file="'. $e[3] .'" line="'. $e[4] .'">'.htmlentities($e[2], ENT_NOQUOTES, $this->charset). '</error>'. "\n"; 
     109           $errors .=  '<error xmlns="http://jelix.org/ns/xmlerror/1.0" type="'. $e[0] .'" code="'. $e[1] .'" file="'. $e[3] .'" line="'. $e[4] .'">'.htmlentities($e[2], ENT_NOQUOTES, $this->charset). '</error>'. "\n"; 
    109110        } 
    110111        return $errors; 
  • trunk/lib/jelix/core/response/jResponseBinary.class.php

    r443 r454  
    55* @author      Laurent Jouanneau 
    66* @contributor Nicolas Lassalle <nicolas@beroot.org> (ticket #188) 
    7 * @copyright   2005-2006 Laurent Jouanneau 
     7* @copyright   2005-2007 Laurent Jouanneau 
    88* @copyright   2007 Nicolas Lassalle 
    99* @link        http://www.jelix.org 
     
    6060     */ 
    6161    public function output(){ 
     62 
    6263        if($this->doDownload){ 
    6364            $this->mimeType = 'application/forcedownload'; 
     
    6768            } 
    6869        } 
     70 
    6971        if($this->hasErrors()) return false; 
     72 
     73        $this->addHttpHeader("Content-Type",$this->mimeType, $this->doDownload); 
     74 
     75        if($this->doDownload) 
     76              $this->_downloadHeader(); 
    7077 
    7178        if($this->content === null){ 
    7279            if (is_readable ($this->fileName) && is_file ($this->fileName)){ 
    73                 header("Content-Type: ".$this->mimeType); 
    74                 if($this->doDownload) $this->_downloadHeader(); 
    75                 header("Content-Length: ".filesize ($this->fileName)); 
     80                $this->_httpHeaders['Content-Length']=filesize ($this->fileName); 
     81                $this->sendHttpHeaders(); 
    7682                readfile ($this->fileName); 
    7783                flush(); 
    7884                return true; 
    79             }else 
     85            }else{ 
     86                throw new jException('jelix~errors.repbin.unknow.file' , $this->fileName); 
    8087                return false; 
     88            } 
    8189        }else{ 
    82             header("Content-Type: ".$this->mimeType); 
    83             if($this->doDownload) $this->_downloadHeader(); 
    84             header("Content-Length: ".strlen ($this->content)); 
     90            $this->_httpHeaders['Content-Length']=strlen ($this->content); 
     91            $this->sendHttpHeaders(); 
    8592            echo $this->content; 
    8693            flush(); 
     
    8895        } 
    8996    } 
    90  
    91     private function _downloadHeader(){ 
    92         header("Content-Disposition: attachment; filename=".$this->outputFileName); 
    93         header("Content-Description: File Transfert"); 
    94         header("Content-Transfer-Encoding: binary"); 
    95         header("Pragma: no-cache"); 
    96         header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); 
    97         header("Expires: 0"); 
     97     
     98    /** 
     99     * set all headers to force download 
     100     */ 
     101    protected function _downloadHeader(){ 
     102        $this->addHttpHeader('Content-Disposition','attachment; filename='.$this->outputFileName, false); 
     103        $this->addHttpHeader('Content-Description','File Transfert', false); 
     104        $this->addHttpHeader('Content-Transfer-Encoding','binary', false); 
     105        $this->addHttpHeader('Pragma','no-cache', false); 
     106        $this->addHttpHeader('Cache-Control','no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false); 
     107        $this->addHttpHeader('Expires','0', false); 
    98108    } 
    99109 
    100110    /** 
    101      * @todo do this method 
     111     * 
    102112     */ 
    103113    public function outputErrors(){ 
    104  
     114        $this->clearHttpHeaders(); 
     115        $this->_httpStatusCode ='500'; 
     116        $this->_httpStatusMsg ='Internal Server Error'; 
     117        $this->_httpHeaders["Content-Type"]='text/plain'; 
     118        $this->sendHttpHeaders(); 
     119        if($this->hasErrors()){ 
     120            foreach( $GLOBALS['gJCoord']->errorMessages  as $e){ 
     121               echo '['.$e[0].' '.$e[1].'] '.$e[2]." \t".$e[3]." \t".$e[4]."\n"; 
     122            } 
     123        }else{ 
     124            echo "[unknow error]\n"; 
     125        } 
    105126    } 
    106127} 
  • trunk/lib/jelix/core/response/jResponseBinary.class.php

    r443 r454  
    55* @author      Laurent Jouanneau 
    66* @contributor Nicolas Lassalle <nicolas@beroot.org> (ticket #188) 
    7 * @copyright   2005-2006 Laurent Jouanneau 
     7* @copyright   2005-2007 Laurent Jouanneau 
    88* @copyright   2007 Nicolas Lassalle 
    99* @link        http://www.jelix.org 
     
    6060     */ 
    6161    public function output(){ 
     62 
    6263        if($this->doDownload){ 
    6364            $this->mimeType = 'application/forcedownload'; 
     
    6768            } 
    6869        } 
     70 
    6971        if($this->hasErrors()) return false; 
     72 
     73        $this->addHttpHeader("Content-Type",$this->mimeType, $this->doDownload); 
     74 
     75        if($this->doDownload) 
     76              $this->_downloadHeader(); 
    7077 
    7178        if($this->content === null){ 
    7279            if (is_readable ($this->fileName) && is_file ($this->fileName)){ 
    73                 header("Content-Type: ".$this->mimeType); 
    74                 if($this->doDownload) $this->_downloadHeader(); 
    75                 header("Content-Length: ".filesize ($this->fileName)); 
     80                $this->_httpHeaders['Content-Length']=filesize ($this->fileName); 
     81                $this->sendHttpHeaders(); 
    7682                readfile ($this->fileName); 
    7783                flush(); 
    7884                return true; 
    79             }else 
     85            }else{ 
     86                throw new jException('jelix~errors.repbin.unknow.file' , $this->fileName); 
    8087                return false; 
     88            } 
    8189        }else{ 
    82             header("Content-Type: ".$this->mimeType); 
    83             if($this->doDownload) $this->_downloadHeader(); 
    84             header("Content-Length: ".strlen ($this->content)); 
     90            $this->_httpHeaders['Content-Length']=strlen ($this->content); 
     91            $this->sendHttpHeaders(); 
    8592            echo $this->content; 
    8693            flush(); 
     
    8895        } 
    8996    } 
    90  
    91     private function _downloadHeader(){ 
    92         header("Content-Disposition: attachment; filename=".$this->outputFileName); 
    93         header("Content-Description: File Transfert"); 
    94         header("Content-Transfer-Encoding: binary"); 
    95         header("Pragma: no-cache"); 
    96         header("Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0"); 
    97         header("Expires: 0"); 
     97     
     98    /** 
     99     * set all headers to force download 
     100     */ 
     101    protected function _downloadHeader(){ 
     102        $this->addHttpHeader('Content-Disposition','attachment; filename='.$this->outputFileName, false); 
     103        $this->addHttpHeader('Content-Description','File Transfert', false); 
     104        $this->addHttpHeader('Content-Transfer-Encoding','binary', false); 
     105        $this->addHttpHeader('Pragma','no-cache', false); 
     106        $this->addHttpHeader('Cache-Control','no-store, no-cache, must-revalidate, post-check=0, pre-check=0', false); 
     107        $this->addHttpHeader('Expires','0', false); 
    98108    } 
    99109 
    100110    /** 
    101      * @todo do this method 
     111     * 
    102112     */ 
    103113    public function outputErrors(){ 
    104  
     114        $this->clearHttpHeaders(); 
     115        $this->_httpStatusCode ='500'; 
     116        $this->_httpStatusMsg ='Internal Server Error'; 
     117        $this->_httpHeaders["Content-Type"]='text/plain'; 
     118        $this->sendHttpHeaders(); 
     119        if($this->hasErrors()){ 
     120            foreach( $GLOBALS['gJCoord']->errorMessages  as $e){ 
     121               echo '['.$e[0].' '.$e[1].'] '.$e[2]." \t".$e[3]." \t".$e[4]."\n"; 
     122            } 
     123        }else{ 
     124            echo "[unknow error]\n"; 
     125        } 
    105126    } 
    106127} 
  • trunk/lib/jelix/core/response/jResponseCss.class.php

    r338 r454  
    44* @subpackage  core_response 
    55* @author      Nicolas Jeudy 
    6 * @contributor 
     6* @contributor Laurent Jouanneau 
    77* @copyright   2006 Nicolas Jeudy 
     8* @copyright   2007 Laurent Jouanneau 
    89* @link        http://www.jelix.org 
    910* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    4546    public function outputErrors(){ 
    4647        global $gJConfig; 
     48        header("HTTP/1.0 500 Internal Server Error"); 
    4749        header('Content-Type: text/css;charset='.$gJConfig->defaultCharset); 
    4850        echo "/*\n"; 
  • trunk/lib/jelix/core/response/jResponseCss.class.php

    r338 r454  
    44* @subpackage  core_response 
    55* @author      Nicolas Jeudy 
    6 * @contributor 
     6* @contributor Laurent Jouanneau 
    77* @copyright   2006 Nicolas Jeudy 
     8* @copyright   2007 Laurent Jouanneau 
    89* @link        http://www.jelix.org 
    910* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    4546    public function outputErrors(){ 
    4647        global $gJConfig; 
     48        header("HTTP/1.0 500 Internal Server Error"); 
    4749        header('Content-Type: text/css;charset='.$gJConfig->defaultCharset); 
    4850        echo "/*\n"; 
  • trunk/lib/jelix/core/response/jResponseHtml.class.php

    r433 r454  
    199199    final public function outputErrors(){ 
    200200        if($this->_headSent < 1){ 
    201              if(!$this->_httpHeadersSent) header('Content-Type: text/html;charset='.$this->_charset); 
     201             if(!$this->_httpHeadersSent){ 
     202                header("HTTP/1.0 500 Internal Server Error"); 
     203                header('Content-Type: text/html;charset='.$this->_charset); 
     204             } 
    202205            echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', "\n<html>"; 
    203206        } 
  • trunk/lib/jelix/core/response/jResponseHtml.class.php

    r433 r454  
    199199    final public function outputErrors(){ 
    200200        if($this->_headSent < 1){ 
    201              if(!$this->_httpHeadersSent) header('Content-Type: text/html;charset='.$this->_charset); 
     201             if(!$this->_httpHeadersSent){ 
     202                header("HTTP/1.0 500 Internal Server Error"); 
     203                header('Content-Type: text/html;charset='.$this->_charset); 
     204             } 
    202205            echo '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">', "\n<html>"; 
    203206        } 
  • trunk/lib/jelix/core/response/jResponseJson.class.php

    r446 r454  
    4646        $content = $json->encode($this->datas); 
    4747#endif 
     48        if($this->hasErrors()) return false; 
     49 
    4850        $this->_httpHeaders['Content-length'] = strlen($content); 
    4951        $this->sendHttpHeaders(); 
     
    6365            $message['errorCode'] = -1; 
    6466        } 
     67        $this->clearHttpHeaders(); 
     68        $this->_httpStatusCode ='500'; 
     69        $this->_httpStatusMsg ='Internal Server Error'; 
    6570        $this->_httpHeaders['Content-Type'] = "text/plain"; 
    6671#if ENABLE_PHP_JSON 
  • trunk/lib/jelix/core/response/jResponseJson.class.php

    r446 r454  
    4646        $content = $json->encode($this->datas); 
    4747#endif 
     48        if($this->hasErrors()) return false; 
     49 
    4850        $this->_httpHeaders['Content-length'] = strlen($content); 
    4951        $this->sendHttpHeaders(); 
     
    6365            $message['errorCode'] = -1; 
    6466        } 
     67        $this->clearHttpHeaders(); 
     68        $this->_httpStatusCode ='500'; 
     69        $this->_httpStatusMsg ='Internal Server Error'; 
    6570        $this->_httpHeaders['Content-Type'] = "text/plain"; 
    6671#if ENABLE_PHP_JSON 
  • trunk/lib/jelix/core/response/jResponseJsonrpc.class.php

    r446 r454  
    55* @author      Laurent Jouanneau 
    66* @contributor Loic Mathaud 
    7 * @copyright   2005-2006 Laurent Jouanneau 
     7* @copyright   2005-2007 Laurent Jouanneau 
    88* @copyright   2007 Loic Mathaud 
    99* @link        http://www.jelix.org 
     
    3535    public function output(){ 
    3636        global $gJCoord; 
    37         if($this->hasErrors()) return false; 
     37         
    3838        $this->_httpHeaders['Content-Type'] = "text/plain"; 
    3939        if($gJCoord->request->jsonRequestId !== null){ 
    4040            $content = jJsonRpc::encodeResponse($this->response, $gJCoord->request->jsonRequestId); 
     41            if($this->hasErrors()) return false; 
    4142            $this->_httpHeaders['Content-length'] = strlen($content); 
    4243            $this->sendHttpHeaders(); 
    4344            echo $content; 
    4445        }else{ 
     46            if($this->hasErrors()) return false; 
    4547            $this->_httpHeaders['Content-length'] = '0'; 
    4648            $this->sendHttpHeaders(); 
     
    5961            $errorCode = -1; 
    6062        } 
     63        $this->clearHttpHeaders(); 
     64        $this->_httpStatusCode ='500'; 
     65        $this->_httpStatusMsg ='Internal Server Error'; 
    6166        $this->_httpHeaders['Content-Type'] = "text/plain"; 
    6267        $content = jJsonRpc::encodeFaultResponse($errorCode,$errorMessage, $gJCoord->request->jsonRequestId); 
  • trunk/lib/jelix/core/response/jResponseJsonrpc.class.php

    r446 r454  
    55* @author      Laurent Jouanneau 
    66* @contributor Loic Mathaud 
    7 * @copyright   2005-2006 Laurent Jouanneau 
     7* @copyright   2005-2007 Laurent Jouanneau 
    88* @copyright   2007 Loic Mathaud 
    99* @link        http://www.jelix.org 
     
    3535    public function output(){ 
    3636        global $gJCoord; 
    37         if($this->hasErrors()) return false; 
     37         
    3838        $this->_httpHeaders['Content-Type'] = "text/plain"; 
    3939        if($gJCoord->request->jsonRequestId !== null){ 
    4040            $content = jJsonRpc::encodeResponse($this->response, $gJCoord->request->jsonRequestId); 
     41            if($this->hasErrors()) return false; 
    4142            $this->_httpHeaders['Content-length'] = strlen($content); 
    4243            $this->sendHttpHeaders(); 
    4344            echo $content; 
    4445        }else{ 
     46            if($this->hasErrors()) return false; 
    4547            $this->_httpHeaders['Content-length'] = '0'; 
    4648            $this->sendHttpHeaders(); 
     
    5961            $errorCode = -1; 
    6062        } 
     63        $this->clearHttpHeaders(); 
     64        $this->_httpStatusCode ='500'; 
     65        $this->_httpStatusMsg ='Internal Server Error'; 
    6166        $this->_httpHeaders['Content-Type'] = "text/plain"; 
    6267        $content = jJsonRpc::encodeFaultResponse($errorCode,$errorMessage, $gJCoord->request->jsonRequestId); 
  • trunk/lib/jelix/core/response/jResponseLatexToPdf.class.php

    r411 r454  
    167167    public function outputErrors(){ 
    168168        global $gJConfig; 
     169        header("HTTP/1.0 500 Internal Server Error"); 
    169170        header('Content-Type: text/plain;charset='.$gJConfig->defaultCharset); 
    170171        if($this->hasErrors()){ 
  • trunk/lib/jelix/core/response/jResponseLatexToPdf.class.php

    r411 r454  
    167167    public function outputErrors(){ 
    168168        global $gJConfig; 
     169        header("HTTP/1.0 500 Internal Server Error"); 
    169170        header('Content-Type: text/plain;charset='.$gJConfig->defaultCharset); 
    170171        if($this->hasErrors()){ 
  • trunk/lib/jelix/core/response/jResponseRdf.class.php

    r338 r454  
    55* @author      Laurent Jouanneau 
    66* @contributor 
    7 * @copyright   2006 Laurent Jouanneau 
     7* @copyright   2006-2007 Laurent Jouanneau 
    88* @link        http://www.jelix.org 
    99* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    139139        $EOL="\n"; 
    140140        if(!$this->_httpHeadersSent){ 
     141            header("HTTP/1.0 500 Internal Server Error"); 
    141142            header("Content-Type: text/xml;charset=".$GLOBALS['gJConfig']->defaultCharset); 
    142143        } 
  • trunk/lib/jelix/core/response/jResponseRdf.class.php

    r338 r454  
    55* @author      Laurent Jouanneau 
    66* @contributor 
    7 * @copyright   2006 Laurent Jouanneau 
     7* @copyright   2006-2007 Laurent Jouanneau 
    88* @link        http://www.jelix.org 
    99* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    139139        $EOL="\n"; 
    140140        if(!$this->_httpHeadersSent){ 
     141            header("HTTP/1.0 500 Internal Server Error"); 
    141142            header("Content-Type: text/xml;charset=".$GLOBALS['gJConfig']->defaultCharset); 
    142143        } 
  • trunk/lib/jelix/core/response/jResponseRss20.class.php

    r386 r454  
    88* @copyright   2005-2006 Loic Mathaud 
    99* @copyright   2006 Yannick Le Guédart 
    10 * @copyright   2006 Laurent Jouanneau 
     10* @copyright   2006-2007 Laurent Jouanneau 
    1111* @link        http://www.jelix.org 
    1212* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    7979    final public function outputErrors() { 
    8080        if (!$this->_headSent) { 
    81              if ($this->_sendHttpHeader) { 
     81             if (!$this->_httpHeadersSent) { 
     82                header("HTTP/1.0 500 Internal Server Error"); 
    8283                header('Content-Type: text/xml;charset='.$this->charset); 
    8384             } 
     
    102103        foreach ($GLOBALS['gJCoord']->errorMessages  as $e) { 
    103104            // FIXME : Pourquoi utiliser htmlentities() ? 
    104            $errors .=  '<error type="'. $e[0] .'" code="'. $e[1] .'" file="'. $e[3] .'" line="'. $e[4] .'">'.htmlentities($e[2], ENT_NOQUOTES, $this->charset). '</error>'. "\n"; 
     105           $errors .=  '<error xmlns="http://jelix.org/ns/xmlerror/1.0" type="'. $e[0] .'" code="'. $e[1] .'" file="'. $e[3] .'" line="'. $e[4] .'">'.htmlentities($e[2], ENT_NOQUOTES, $this->charset). '</error>'. "\n"; 
    105106        } 
    106107        return $errors; 
  • trunk/lib/jelix/core/response/jResponseRss20.class.php

    r386 r454  
    88* @copyright   2005-2006 Loic Mathaud 
    99* @copyright   2006 Yannick Le Guédart 
    10 * @copyright   2006 Laurent Jouanneau 
     10* @copyright   2006-2007 Laurent Jouanneau 
    1111* @link        http://www.jelix.org 
    1212* @licence     GNU Lesser General Public Licence see LICENCE file or http://www.gnu.org/licenses/lgpl.html 
     
    7979    final public function outputErrors() { 
    8080        if (!$this->_headSent) { 
    81              if ($this->_sendHttpHeader) { 
     81             if (!$this->_httpHeadersSent) { 
     82                header("HTTP/1.0 500 Internal Server Error"); 
    8283                header('Content-Type: text/xml;charset='.$this->charset); 
    8384             } 
     
    102103        foreach ($GLOBALS['gJCoord']->errorMessages  as $e) { 
    103104            // FIXME : Pourquoi utiliser htmlentities() ? 
    104            $errors .=  '<error type="'. $e[0] .'" code="'. $e[1] .'" file="'. $e[3] .'" line="'. $e[4] .'">'.htmlentities($e[2], ENT_NOQUOTES, $this->charset). '</error>'. "\n"; 
     105           $errors .=  '<error xmlns="http://jelix.org/ns/xmlerror/1.0" type="'. $e[0] .'" code="'. $e[1] .'" file="'. $e[3] .'" line="'. $e[4] .'">'.htmlentities($e[2], ENT_NOQUOTES, $this->charset). '</error>'. "\n"; 
    105106        } 
    106