Changeset 1248

Show
Ignore:
Timestamp:
02/11/09 05:37:50 (3 years ago)
Author:
bermi
Message:

Adding Content-Length to HTTP responses to tell HTTP 1.0 clients when the content has been delivered on Keep Alive connections

Changing the plugin discovery url to its new location at http://www.akelos.org/wiki/plugins

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/AkPlugin/AkPluginManager.php

    r1185 r1248  
    2727 
    2828defined('AK_PLUGINS_MAIN_REPOSITORY') ? null : define('AK_PLUGINS_MAIN_REPOSITORY', 'http://svn.akelos.org/plugins'); 
    29 defined('AK_PLUGINS_REPOSITORY_DISCOVERY_PAGE') ? null : define('AK_PLUGINS_REPOSITORY_DISCOVERY_PAGE', 'http://wiki.akelos.org/plugins'); 
     29defined('AK_PLUGINS_REPOSITORY_DISCOVERY_PAGE') ? null : define('AK_PLUGINS_REPOSITORY_DISCOVERY_PAGE', 'http://www.akelos.org/wiki/plugins'); 
    3030 
    3131/** 
     
    291291 
    292292    /** 
    293      * Gets a list of repositories available at the web page defined by AK_PLUGINS_REPOSITORY_DISCOVERY_PAGE (http://wiki.akelos.org/plugins by default) 
    294      *  
    295      * @return array An array of non trusted repositories available at http://wiki.akelos.org/plugins 
     293     * Gets a list of repositories available at the web page defined by AK_PLUGINS_REPOSITORY_DISCOVERY_PAGE (http://www.akelos.org/wiki/plugins by default) 
     294     *  
     295     * @return array An array of non trusted repositories available at http://www.akelos.org/wiki/plugins 
    296296     * @access public  
    297297     */ 
     
    360360 
    361361    /** 
    362      * Retrieves the URL's from the AK_PLUGINS_REPOSITORY_DISCOVERY_PAGE (http://wiki.akelos.org/plugins by default) 
     362     * Retrieves the URL's from the AK_PLUGINS_REPOSITORY_DISCOVERY_PAGE (http://www.akelos.org/wiki/plugins by default) 
    363363     *  
    364364     * Plugins in that page must follow this convention: 
     
    374374 
    375375        $repositories = array(); 
    376         if(preg_match_all('/href="(http:\/\/(?!wiki\.akelos\.org)[^"]*plugins)/', Ak::url_get_contents($this->respository_discovery_page), $matches)){ 
     376        if(preg_match_all('/href="(http:\/\/(?!www\.akelos\.org\/wiki\/)[^"]*plugins)/', Ak::url_get_contents($this->respository_discovery_page), $matches)){ 
    377377            $repositories = array_unique($matches[1]); 
    378378        } 
  • trunk/lib/AkResponse.php

    r1206 r1248  
    6363        } 
    6464    } 
     65     
    6566    function setContentTypeForFormat($format) 
    6667    { 
     
    7273        } 
    7374    } 
     75     
    7476    function outputResults() 
    7577    { 
    7678        $this->sendHeaders(); 
    77         if(is_object($this->body) && method_exists($this->body,'stream')){ 
     79        if($this->_streamBody()){ 
    7880            AK_LOG_EVENTS && !empty($this->_Logger) ? $this->_Logger->message("Sending response as stream") : null; 
    7981            $this->body->stream(); 
     
    8385        } 
    8486    } 
     87     
    8588    function getStatus() 
    8689    { 
    8790        return isset($this->_headers['Status'])?$this->_headers['Status']:$this->_default_status; 
    8891    } 
     92     
    8993    function sendHeaders($terminate_if_redirected = true) 
    9094    { 
     
    108112        unset($this->_headers['Status']); 
    109113 
    110          
     114        $_has_content_type = $_has_content_length = false; 
    111115        if(!empty($this->_headers) && is_array($this->_headers)){ 
    112116            $this->addHeader('Connection: close'); 
     
    122126                    } 
    123127                } 
    124                 if(strtolower(substr($header,0,13)) == 'content-type:'){ 
     128                if(!$_has_content_type && strtolower(substr($header,0,13)) == 'content-type:'){ 
    125129                    $_has_content_type = true; 
     130                }elseif(!$_has_content_length && strtolower(substr($header,0,15)) == 'content-length:'){ 
     131                    $_has_content_length = true; 
    126132                } 
     133                 
    127134                AK_LOG_EVENTS && !empty($this->_Logger) ? $this->_Logger->message("Sending header:  $header") : null; 
    128135                header($header); 
     
    130137        } 
    131138         
    132         if(empty($_has_content_type) && defined('AK_CHARSET') && (empty($_redirected) || (!empty($_redirected) && !empty($javascript_redirection)))){ 
     139        if(!$_has_content_type && defined('AK_CHARSET') && (empty($_redirected) || (!empty($_redirected) && !empty($javascript_redirection)))){ 
    133140            header('Content-Type: text/html; charset='.AK_CHARSET); 
    134141            $this->_headers_sent[] = 'Content-Type: text/html; charset='.AK_CHARSET; 
    135142        } 
    136143         
     144        if(!$_has_content_length && !$this->_streamBody()){ 
     145            $length = strlen($this->body); 
     146            if($length > 0){ 
     147                header('Content-Length: '.$length); 
     148                $this->_headers_sent[] = 'Content-Length: '.$length;    
     149            } 
     150        } 
     151 
    137152        if(!empty($javascript_redirection)){ 
    138153            echo $javascript_redirection; 
     
    141156        $terminate_if_redirected ? (!empty($_redirected) ? exit() : null) : null; 
    142157    } 
     158     
    143159    function addSentHeader($header) 
    144160    { 
    145161        $this->_headers_sent[] = $header; 
    146162    } 
     163     
    147164    function deleteHeader($header) 
    148165    { 
     
    211228        return empty($status_codes[$status_code]) ? false : $status_codes[$status_code]; 
    212229    } 
     230     
     231    function _streamBody() 
     232    { 
     233        return is_object($this->body) && method_exists($this->body,'stream'); 
     234    } 
    213235} 
    214236 
  • trunk/lib/utils/generators/model/templates/unit_test.tpl

    r423 r1248  
    22 
    33 
    4 // Unit test for <?php  echo $class_name?>. (Testing docs at http://wiki.akelos.org/testing-guide) 
     4// Unit test for <?php  echo $class_name?>. (Testing docs at http://www.akelos.org/wiki/testing-guide) 
    55// Run this test with the command 
    66//  ./script/test model <?php  echo $class_name?> 
  • trunk/lib/utils/generators/scaffold/sintags_templates/model_unit_test.tpl

    r423 r1248  
    22 
    33 
    4 // Unit test for <?php  echo $plural_name?>. (Testing docs at http://wiki.akelos.org/testing-guide) 
     4// Unit test for <?php  echo $plural_name?>. (Testing docs at http://www.akelos.org/wiki/testing-guide) 
    55// Run this test with the command 
    66//  ./script/test model <?php  echo $model_name?> 
  • trunk/lib/utils/generators/scaffold/templates/model_unit_test.tpl

    r377 r1248  
    22 
    33// To run this test calling ./script/test unit/app/models/<?php  echo AkInflector::underscore($model_name); ?> 
    4 // More about testing at http://wiki.akelos.org/testing-guide 
     4// More about testing at http://www.akelos.org/wiki/testing-guide 
    55 
    66class <?php  echo $model_name?>TestCase extends AkUnitTest