update: support cf etag

This commit is contained in:
tokumeikoi 2022-03-15 22:40:30 +08:00
parent fc2b4bd422
commit 1111c6f13d
3 changed files with 6 additions and 6 deletions

View File

@ -56,13 +56,13 @@ class DeepbworkController extends Controller
array_push($result, $user); array_push($result, $user);
} }
$eTag = sha1(json_encode($result)); $eTag = sha1(json_encode($result));
if ($eTag === $request->header("IF-NONE-MATCH")) { if (strpos($request->header('If-None-Match'), $eTag) !== false ) {
abort(304); abort(304);
} }
return response([ return response([
'msg' => 'ok', 'msg' => 'ok',
'data' => $result, 'data' => $result,
])->header('ETag', $eTag); ])->header('ETag', "\"{$eTag}\"");
} }
// 后端提交数据 // 后端提交数据

View File

@ -49,12 +49,12 @@ class ShadowsocksTidalabController extends Controller
]); ]);
} }
$eTag = sha1(json_encode($result)); $eTag = sha1(json_encode($result));
if ($eTag === $request->header("IF-NONE-MATCH")) { if (strpos($request->header('If-None-Match'), $eTag) !== false ) {
abort(304); abort(304);
} }
return response([ return response([
'data' => $result 'data' => $result
])->header('ETag', $eTag); ])->header('ETag', "\"{$eTag}\"");
} }
// 后端提交数据 // 后端提交数据

View File

@ -53,13 +53,13 @@ class TrojanTidalabController extends Controller
array_push($result, $user); array_push($result, $user);
} }
$eTag = sha1(json_encode($result)); $eTag = sha1(json_encode($result));
if ($eTag === $request->header("IF-NONE-MATCH")) { if (strpos($request->header('If-None-Match'), $eTag) !== false ) {
abort(304); abort(304);
} }
return response([ return response([
'msg' => 'ok', 'msg' => 'ok',
'data' => $result, 'data' => $result,
])->header('ETag', $eTag); ])->header('ETag', "\"{$eTag}\"");
} }
// 后端提交数据 // 后端提交数据