$response->header('Accept-Charset', 'utf-8'); $response->header('Content-Type', 'application/vnd.collection+json'); // logic layer $res_arr = static::hotLogic($request, $this->json_col, $this->getRedisIns()); if (array_key_exists('code', $res_arr)) { $code = $res_arr['code']; $response->status($code); echo 'StCode:' . $code . PHP_EOL; if (201 == $code) { //created extra header $response->header('Location', Json_Collection::$host . '/' . $res_arr['location']); } } else { // 200 is the default code $this->json_col->fillWithArr($res_arr['arr']); $ret_str = $this->json_col->getEncodedStr(); $this->json_col->cleanUp(); } $httpcontent = isset($ret_str) ? $ret_str : ''; unset($ret_str); echo 'Ret_Cont:' . $httpcontent . PHP_EOL; $response->end($httpcontent); } public function run() { $this->serv->start(); } } $http = new HttpServer(); $http->setting(); $http->run();