Example #1
0
 /**
  * 处理request对象
  * @param req swoole http server 获得的request对象
  */
 public static function httpReqHandle($req)
 {
     $method = $req->server['request_method'];
     $uri = $req->server['request_uri'];
     //路由
     $appRoute = HttpRoute::urlrouter_rewrite($uri, $method);
     SysLog::info(__METHOD__ . print_r($appRoute, true), __CLASS__);
     if (!$appRoute) {
         return array('r' => self::HTTP_ERROR_URI);
     }
     return array('r' => self::HTTP_OK, 'route' => $appRoute, 'request' => array('uri' => $uri, 'header' => $req->header, 'get' => array_merge((array) (isset($req->get) ? $req->get : array()), (array) $appRoute['get']), 'post' => isset($req->post) ? $req->post : '', 'files' => isset($req->files) ? $req->files : '', 'cookie' => isset($req->cookie) ? $req->cookie : '', 'rawcontent' => $req->rawContent(), 'method' => $method));
 }
 /**
  * 处理request对象
  * @param req swoole http server 获得的request对象
  */
 public static function httpReqHandle($req)
 {
     $ver = swoole_version();
     $method = $ver == '1.7.9' ? $req->server['REQUEST_METHOD'] : $req->server['request_method'];
     if ($method != 'POST') {
         return array('r' => self::HTTP_ERROR_METHOD);
     }
     $uri = $ver == '1.7.9' ? $req->server['REQUEST_URI'] : $req->server['request_uri'];
     $appRoute = HttpRoute::getRoute($uri);
     if (!$appRoute) {
         return array('r' => self::HTTP_ERROR_URI);
     }
     return array('r' => self::HTTP_OK, 'route' => $appRoute, 'request' => array('uri' => $uri, 'get' => $req->get, 'post' => $req->post ? $req->post : $req->rawContent()));
 }