コード例 #1
0
ファイル: ResponseTest.php プロジェクト: Prowect/HTTP
 public function testResponse()
 {
     $response = new Response();
     $this->assertFalse(Response::isSent());
     $response->setHeader("Content-Type", "text/html");
     $response->unsetHeader("Cache-Control");
     $response->unsetHeader("Cache-Control");
     $this->assertTrue($response->send());
     $this->assertTrue(Response::isSent());
     $response = new Response();
     $this->assertFalse($response->send());
 }
コード例 #2
0
ファイル: drips.php プロジェクト: Prowect/Debugbar
<?php

use Drips\Debugbar\Debugbar;
use Drips\HTTP\Request;
use Drips\HTTP\Response;
if (!defined('DRIPS_DEBUG')) {
    define('DRIPS_DEBUG', true);
}
if (class_exists('Drips\\App')) {
    Response::on('send', function ($response) {
        $request = Request::getInstance();
        if (in_array('text/html', $request->getAccept())) {
            $debugbar = Debugbar::getInstance();
            if ($debugbar->hasTabs()) {
                $debugbarString = $debugbar->__toString();
                $bodyTag = '</body>';
                if (strpos($response->body, $bodyTag) !== false) {
                    $response->body = str_replace($bodyTag, $debugbarString . $bodyTag, $response->body);
                } else {
                    $response->body .= $debugbarString;
                }
            }
        }
    });
}