FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Http服务器增加request/response对象 · cnote0/framework@ba9d524 · GitHub

Repository navigation

Commit ba9d524

Browse files
committed
Http服务器增加request/response对象
1 parent 3747334 commit ba9d524

4 files changed

Lines changed: 6 additions & 2 deletions

File tree

‎examples/http_server.php‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?php
22
define('DEBUG', 'on');
3-
define("WEBPATH", realpath(__DIR__.'/../'));
3+
define("WEBPATH", realpath(__DIR__ . '/../'));
44
require dirname(__DIR__) . '/libs/lib_config.php';
55

66
Swoole\Config::$debug = false;

‎examples/webroot/index.php‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
<?php
2+
Swoole::$php->http->header('Gateway-Interface', 'PHP-5.4.6');
23
echo "<h1>hello world</h1>";

‎examples/websocket_client.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script>
2-
var wsServer = 'ws://127.0.0.1:9443';
2+
var wsServer = 'ws://127.0.0.1:9501';
33
var websocket = new WebSocket(wsServer);
44
websocket.onopen = function (evt) {
55
console.log("Connected to WebSocket server.");

‎libs/Swoole/Protocol/HttpServer.php‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,8 @@ function onRequest(Swoole\Request $request)
369369
{
370370
$response = new Swoole\Response;
371371
$this->currentResponse = $response;
372+
\Swoole::$php->request = $request;
373+
\Swoole::$php->response = $response;
372374

373375
//请求路径
374376
if ($request->meta['path'][strlen($request->meta['path']) - 1] == '/')
@@ -475,6 +477,7 @@ function processDynamic(Swoole\Request $request, Swoole\Response $response)
475477
{
476478
$request->setGlobal();
477479
$response->head['Content-Type'] = 'text/html';
480+
478481
ob_start();
479482
try
480483
{

0 commit comments

Comments
 (0)

Back | FazBrowse Home | New Git URL