mirror of
https://github.com/tuyoogame/YooAsset.git
synced 2026-05-22 16:50:18 +00:00
Update UnityWebCacheRequestOperation.cs
This commit is contained in:
@@ -1,4 +1,6 @@
|
|||||||
using UnityEngine.Networking;
|
using System.Collections;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using UnityEngine.Networking;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
namespace YooAsset
|
namespace YooAsset
|
||||||
@@ -14,6 +16,7 @@ namespace YooAsset
|
|||||||
}
|
}
|
||||||
|
|
||||||
private UnityWebRequestAsyncOperation _requestOperation;
|
private UnityWebRequestAsyncOperation _requestOperation;
|
||||||
|
private readonly Dictionary<string, string> _headers = new Dictionary<string, string>();
|
||||||
private ESteps _steps = ESteps.None;
|
private ESteps _steps = ESteps.None;
|
||||||
|
|
||||||
|
|
||||||
@@ -64,13 +67,22 @@ namespace YooAsset
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void SetRequestHeader(string name, string value)
|
public void SetRequestHeader(string name, string value)
|
||||||
{
|
{
|
||||||
_webRequest.SetRequestHeader(name, value);
|
_headers.Add(name, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void CreateWebRequest()
|
private void CreateWebRequest()
|
||||||
{
|
{
|
||||||
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
|
_webRequest = DownloadSystemHelper.NewUnityWebRequestGet(_requestURL);
|
||||||
_webRequest.disposeDownloadHandlerOnDispose = true;
|
_webRequest.disposeDownloadHandlerOnDispose = true;
|
||||||
|
|
||||||
|
// 设置消息头
|
||||||
|
foreach (var keyValuePair in _headers)
|
||||||
|
{
|
||||||
|
string name = keyValuePair.Key;
|
||||||
|
string value = keyValuePair.Value;
|
||||||
|
_webRequest.SetRequestHeader(name, value);
|
||||||
|
}
|
||||||
|
|
||||||
_requestOperation = _webRequest.SendWebRequest();
|
_requestOperation = _webRequest.SendWebRequest();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user