From fa15f83d85afc8e70b2c7e3496c6e0bbcf14c8e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E5=86=A0=E5=B3=B0?= Date: Tue, 22 Jul 2025 17:36:39 +0800 Subject: [PATCH] Update UnityWebCacheRequestOperation.cs --- .../Internal/UnityWebCacheRequestOperation.cs | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebCacheRequestOperation.cs b/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebCacheRequestOperation.cs index ae8080a8..a5b8a72b 100644 --- a/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebCacheRequestOperation.cs +++ b/Assets/YooAsset/Runtime/DownloadSystem/Operation/Internal/UnityWebCacheRequestOperation.cs @@ -1,4 +1,6 @@ -using UnityEngine.Networking; +using System.Collections; +using System.Collections.Generic; +using UnityEngine.Networking; using UnityEngine; namespace YooAsset @@ -14,6 +16,7 @@ namespace YooAsset } private UnityWebRequestAsyncOperation _requestOperation; + private readonly Dictionary _headers = new Dictionary(); private ESteps _steps = ESteps.None; @@ -64,13 +67,22 @@ namespace YooAsset /// public void SetRequestHeader(string name, string value) { - _webRequest.SetRequestHeader(name, value); + _headers.Add(name, value); } private void CreateWebRequest() { _webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL); _webRequest.disposeDownloadHandlerOnDispose = true; + + // 设置消息头 + foreach (var keyValuePair in _headers) + { + string name = keyValuePair.Key; + string value = keyValuePair.Value; + _webRequest.SetRequestHeader(name, value); + } + _requestOperation = _webRequest.SendWebRequest(); } }