setHeader() публичный Метод

设置Http头信息
public setHeader ( $key, $value )
$key
$value
Пример #1
0
 /**
  * 定时器,检查某些连接是否已超过最大时间
  * @param $timerId
  */
 function onTimer($timerId)
 {
     $now = time();
     //echo "timer $interval\n";
     foreach ($this->wait_requests as $id => $request) {
         if ($request->time < $now - $this->request_timeout) {
             $response = new Swoole\Response();
             $response->setHeader('Access-Control-Allow-Origin', $this->origin);
             $response->body = json_encode(array('success' => 0, 'text' => 'timeout'));
             $this->response($request, $response);
             unset($this->wait_requests[$id]);
         }
     }
 }
Пример #2
0
 /**
  * http请求 ->来自客户
  * todo 检验消息之后通知客服 然后关闭连接
  * @param Swoole\Request $request
  */
 function onHttpRequest(Swoole\Request $request)
 {
     $this->log("Http connection  is connected");
     $response = new Swoole\Response();
     $response->setHeader('Content-Type', 'image/jpeg');
     return $response;
 }