删除埋点,im和客服
This commit is contained in:
@@ -342,8 +342,8 @@ class CacheServer {
|
||||
// 是否是预缓存的请求
|
||||
bool isPreCache = false;
|
||||
Map<String, String> queryParameters = {};
|
||||
queryParameters.addAll(localReq.uri.queryParameters ?? {});
|
||||
if (queryParameters.containsKey("isPreCache") ?? false) {
|
||||
queryParameters.addAll(localReq.uri.queryParameters);
|
||||
if (queryParameters.containsKey("isPreCache")) {
|
||||
queryParameters.remove("isPreCache");
|
||||
isPreCache = true;
|
||||
}
|
||||
@@ -432,7 +432,7 @@ class CacheServer {
|
||||
if (rangeStart <= 0) {
|
||||
resp.data?.headers.forEach((key, values) {
|
||||
if (HttpHeaders.contentLengthHeader == key) {
|
||||
var ct = int.parse(values[0] ?? "0");
|
||||
var ct = int.parse(values[0]);
|
||||
localReq.response.headers.add(key, ct > 0 ? (ct - 6) : ct);
|
||||
csPrint("resp header ct:$key ${ct > 0 ? (ct - 6) : ct}");
|
||||
} else {
|
||||
@@ -515,12 +515,6 @@ class CacheServer {
|
||||
/// 处理M3u8
|
||||
_handleM3u8(Uri remoteUri, HttpRequest localReq, Stream<FileResponse> s, BaseCacheManager cacheManager) async {
|
||||
final sc = s.listen((f) {
|
||||
if (null == f) {
|
||||
//l.e(local_server_tag, "handleM3u8()...$remoteUri 来了个null���鬼东西");
|
||||
_requestErr(localReq);
|
||||
return;
|
||||
}
|
||||
|
||||
if (f is FileInfo) {
|
||||
var len = localReq.response.headers.value(HttpHeaders.contentLengthHeader);
|
||||
if (null != len) {
|
||||
@@ -540,7 +534,7 @@ class CacheServer {
|
||||
);
|
||||
// csPrint("before source:$source");
|
||||
if (TextUtil.isNotEmpty(tsLine) && tsLine.startsWith("http")) {
|
||||
var domin = Uri.parse(tsLine ?? "").origin;
|
||||
var domin = Uri.parse(tsLine).origin;
|
||||
if (TextUtil.isNotEmpty(domin)) {
|
||||
csPrint("need replace m3u8 inner host:$domin");
|
||||
source = source.replaceAll(domin, "");
|
||||
@@ -581,17 +575,15 @@ class CacheServer {
|
||||
|
||||
/// 请求错误
|
||||
_requestErr(HttpRequest req, {StreamSubscription? sc}) async {
|
||||
if (null != req) {
|
||||
// if (null == req.response.statusCode) {
|
||||
try {
|
||||
req.response.statusCode = HttpStatus.badRequest;
|
||||
} catch (e) {
|
||||
//l.e(local_server_tag, "_requestErr()..." + req.response.toString());
|
||||
}
|
||||
// }
|
||||
await req.response.close();
|
||||
sc?.cancel();
|
||||
// if (null == req.response.statusCode) {
|
||||
try {
|
||||
req.response.statusCode = HttpStatus.badRequest;
|
||||
} catch (e) {
|
||||
//l.e(local_server_tag, "_requestErr()..." + req.response.toString());
|
||||
}
|
||||
// }
|
||||
await req.response.close();
|
||||
sc?.cancel();
|
||||
}
|
||||
|
||||
BaseCacheManager _getCacheManager(String url) {
|
||||
@@ -641,7 +633,6 @@ class CacheServer {
|
||||
// l.i(local_server_tag, "getCacheFile()...闲时缓存策略预测需要缓��的url:$remoteUrl");
|
||||
var cacheManager = _getCacheManager(remotePath);
|
||||
var fileInfo = cacheManager.getFileFromMemory(getCacheKey(remotePath));
|
||||
fileInfo ??= (await cacheManager.getFileFromCache(getCacheKey(remotePath))) as Future<FileInfo?>;
|
||||
return fileInfo;
|
||||
}
|
||||
|
||||
@@ -662,8 +653,7 @@ class CacheServer {
|
||||
// return "https://fs.lhexm.com/sp/8a/67/lf/mg/605635d590d11f0679a058dbc013bd53.mp4";
|
||||
// remotePath = "sp/r1/8p/mt/if/970dd3185c924ff29c273917615c844a.m3u8";
|
||||
if (TextUtil.isEmpty(remotePath)) return null;
|
||||
var remoteUri = Uri.parse(remotePath); //修正后的绝对��径
|
||||
if (null == remoteUri) return null;
|
||||
var remoteUri = Uri.parse(remotePath);
|
||||
final dot = remoteUri.path.lastIndexOf(".");
|
||||
if (dot <= 0 || dot >= remoteUri.path.length - 1) return null;
|
||||
final fileExtension = remoteUri.path.substring(dot);
|
||||
@@ -715,8 +705,7 @@ class CacheServer {
|
||||
// 兼容相对路径 sp/vid/xxxx.m3u8
|
||||
remotePath = reqFilter.pathPrefix + "/" + remotePath;
|
||||
}
|
||||
var uri = Uri.parse(remotePath); //修正后的绝对路径
|
||||
if (null == uri) return null;
|
||||
var uri = Uri.parse(remotePath);
|
||||
//这里替换远程
|
||||
final remoteUri = uri.replace(scheme: reqFilter.schema, host: reqFilter.host, port: reqFilter.port);
|
||||
return remoteUri.toString();
|
||||
@@ -725,6 +714,5 @@ class CacheServer {
|
||||
|
||||
/// url/绝对路径和相对路径
|
||||
String getCacheKey(String url) {
|
||||
assert(null != url);
|
||||
return FileUtil.getName(url);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user