private void ProxyServer_BeforeRequest(object sender, Titanium.Web.Proxy.EventArguments.SessionEventArgs e) { var request = e.ProxySession.Request; string path = request.RequestUri.PathAndQuery; Utility.Configuration.ConfigurationData.ConfigConnection c = Utility.Configuration.Config.Connection; if (path.Contains("/kcsapi/")) { string body = e.GetRequestBodyAsString(); //保存 if (c.SaveReceivedData && c.SaveRequest) { Task.Run((Action)(() => { SaveRequest(path, body); })); } UIControl.BeginInvoke((Action)(() => { LoadRequest(path, body); })); } if (path.Contains(".mp3")) { Logger.Add(1, $"Requesting audio: {path}"); string[] substrings = path.Split('/'); switch (substrings[3]) { case "titlecall": DialogueTranslator.Add(DialogueType.Titlecall, substrings[4], substrings[5].Split('.')[0]); break; case "kc9999": DialogueTranslator.Add(DialogueType.NPC, "npc", substrings[4].Split('.')[0]); break; default: DialogueTranslator.Add(DialogueType.Shipgirl, substrings[3].Substring(2), substrings[4].Split('.')[0]); break; } if (request.RequestHeaders.Where(h => h.Name == "If-Modified-Since").Count() > 0) { if (cacheControl.ContainsKey(path)) { if (cacheControl[path].Item2 < DateTime.Now) { return; } else { e.NotModified(cacheControl[path].Item1); } } } } }
private void ProxyServer_BeforeRequest(object sender, Titanium.Web.Proxy.EventArguments.SessionEventArgs e) { var request = e.ProxySession.Request; string path = request.RequestUri.PathAndQuery; if (path.Contains(".mp3")) { string[] substrings = path.Split('/'); switch (substrings[3]) { case "titlecall": ToolViewModel.UpdateText(DialogueTranslator.Add(DialogueType.Titlecall, substrings[4], substrings[5].Split('.')[0])); break; case "kc9999": ToolViewModel.UpdateText(DialogueTranslator.Add(DialogueType.NPC, "npc", substrings[4].Split('.')[0])); break; default: ToolViewModel.UpdateText(DialogueTranslator.Add(DialogueType.Shipgirl, substrings[3].Substring(2), substrings[4].Split('.')[0])); break; } if (request.RequestHeaders.Where(h => h.Name == "If-Modified-Since").Count() > 0) { if (cacheControl.ContainsKey(path)) { if (cacheControl[path].Item2 < DateTime.Now) { return; } else { e.NotModified(cacheControl[path].Item1); } } } } }