Skip to content

Commit

Permalink
Send early content type header
Browse files Browse the repository at this point in the history
  • Loading branch information
g105b committed Dec 16, 2014
1 parent d3c3d1d commit 83c258f
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/Cli/Gateway.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ class Gateway {
* @return mixed An instance of the $phpgt class
*/
public static function serve($uri, $phpgt = "\Gt\Core\Start") {
// Will be overridden by ResponseContent. text/plain used for
// early-finishing scripts.
header("Content-type: text/plain");

if(self::isStaticFileRequest($uri)) {
$filePath = self::getAbsoluteFilePath($uri);
self::serveStaticFile($filePath);
Expand Down
1 change: 0 additions & 1 deletion src/Dispatcher/PageDispatcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,5 +172,4 @@ public function createResponseContent($html, $config) {
return $domDocument;
}


}#
1 change: 1 addition & 0 deletions src/Dom/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@
class Document extends ResponseContent {

const DEFAULT_HTML = "<!doctype html>";
public $contentType = "text/html";
public $domDocument;
public $node;
public $nodeMap = [];
Expand Down
2 changes: 2 additions & 0 deletions src/Response/ResponseContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
abstract class ResponseContent {

public $config; // Response config.
public $contentType = "text/plain";

/**
* By default, a Manifest has no capabilities, but each type of ResponseContent
Expand All @@ -34,6 +35,7 @@ public function createManifest($request, $response) {
* buffer, ready for flushing at the end of the response cycle.
*/
public function flush() {
Headers::add("Content-type", $this->contentType);
echo $this->__toString();
}

Expand Down

0 comments on commit 83c258f

Please sign in to comment.