Files
Dec2017-Script-Dump/UnityEngine/WWW.cs
T
2026-06-04 11:42:34 +02:00

742 lines
18 KiB
C#

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Text;
using UnityEngine.Networking;
namespace UnityEngine
{
// Token: 0x0200029D RID: 669
public class WWW : CustomYieldInstruction, IDisposable
{
// Token: 0x06002D66 RID: 11622 RVA: 0x00040470 File Offset: 0x0003E670
public WWW(string url)
{
this._uwr = UnityWebRequest.Get(url);
this._uwr.Send();
}
// Token: 0x06002D67 RID: 11623 RVA: 0x00040494 File Offset: 0x0003E694
public WWW(string url, WWWForm form)
{
this._uwr = UnityWebRequest.Post(url, form);
this._uwr.Send();
}
// Token: 0x06002D68 RID: 11624 RVA: 0x000404B8 File Offset: 0x0003E6B8
public WWW(string url, byte[] postData)
{
this._uwr = new UnityWebRequest(url, "POST");
UploadHandler uploadHandler = new UploadHandlerRaw(postData);
uploadHandler.contentType = "application/x-www-form-urlencoded";
this._uwr.uploadHandler = uploadHandler;
this._uwr.downloadHandler = new DownloadHandlerBuffer();
this._uwr.Send();
}
// Token: 0x06002D69 RID: 11625 RVA: 0x00040518 File Offset: 0x0003E718
[Obsolete("This overload is deprecated. Use UnityEngine.WWW.WWW(string, byte[], System.Collections.Generic.Dictionary<string, string>) instead.")]
public WWW(string url, byte[] postData, Hashtable headers)
{
string text = ((postData != null) ? "POST" : "GET");
this._uwr = new UnityWebRequest(url, text);
UploadHandler uploadHandler = new UploadHandlerRaw(postData);
uploadHandler.contentType = "application/x-www-form-urlencoded";
this._uwr.uploadHandler = uploadHandler;
this._uwr.downloadHandler = new DownloadHandlerBuffer();
IEnumerator enumerator = headers.Keys.GetEnumerator();
try
{
while (enumerator.MoveNext())
{
object obj = enumerator.Current;
this._uwr.SetRequestHeader((string)obj, (string)headers[obj]);
}
}
finally
{
IDisposable disposable;
if ((disposable = enumerator as IDisposable) != null)
{
disposable.Dispose();
}
}
this._uwr.Send();
}
// Token: 0x06002D6A RID: 11626 RVA: 0x000405F8 File Offset: 0x0003E7F8
public WWW(string url, byte[] postData, Dictionary<string, string> headers)
{
string text = ((postData != null) ? "POST" : "GET");
this._uwr = new UnityWebRequest(url, text);
UploadHandler uploadHandler = new UploadHandlerRaw(postData);
uploadHandler.contentType = "application/x-www-form-urlencoded";
this._uwr.uploadHandler = uploadHandler;
this._uwr.downloadHandler = new DownloadHandlerBuffer();
foreach (KeyValuePair<string, string> keyValuePair in headers)
{
this._uwr.SetRequestHeader(keyValuePair.Key, keyValuePair.Value);
}
this._uwr.Send();
}
// Token: 0x06002D6B RID: 11627 RVA: 0x000406C8 File Offset: 0x0003E8C8
internal WWW(string url, string name, Hash128 hash, uint crc)
{
this._uwr = UnityWebRequest.GetAssetBundle(url, new CachedAssetBundle(name, hash), crc);
this._uwr.Send();
}
// Token: 0x17000A48 RID: 2632
// (get) Token: 0x06002D6C RID: 11628 RVA: 0x000406F4 File Offset: 0x0003E8F4
public AssetBundle assetBundle
{
get
{
if (this._assetBundle == null)
{
if (!this.WaitUntilDoneIfPossible())
{
return null;
}
if (this._uwr.isNetworkError)
{
return null;
}
DownloadHandlerAssetBundle downloadHandlerAssetBundle = this._uwr.downloadHandler as DownloadHandlerAssetBundle;
if (downloadHandlerAssetBundle != null)
{
this._assetBundle = downloadHandlerAssetBundle.assetBundle;
}
else
{
byte[] bytes = this.bytes;
if (bytes == null)
{
return null;
}
this._assetBundle = AssetBundle.LoadFromMemory(bytes);
}
}
return this._assetBundle;
}
}
// Token: 0x17000A49 RID: 2633
// (get) Token: 0x06002D6D RID: 11629 RVA: 0x00040798 File Offset: 0x0003E998
public byte[] bytes
{
get
{
byte[] array;
if (!this.WaitUntilDoneIfPossible())
{
array = new byte[0];
}
else if (this._uwr.isNetworkError)
{
array = null;
}
else
{
DownloadHandler downloadHandler = this._uwr.downloadHandler;
if (downloadHandler == null)
{
array = null;
}
else
{
array = downloadHandler.data;
}
}
return array;
}
}
// Token: 0x17000A4A RID: 2634
// (get) Token: 0x06002D6E RID: 11630 RVA: 0x000407FC File Offset: 0x0003E9FC
[Obsolete("WWW.size is obsolete. Please use WWW.bytesDownloaded instead")]
public int size
{
get
{
return this.bytesDownloaded;
}
}
// Token: 0x17000A4B RID: 2635
// (get) Token: 0x06002D6F RID: 11631 RVA: 0x00040818 File Offset: 0x0003EA18
public int bytesDownloaded
{
get
{
return (int)this._uwr.downloadedBytes;
}
}
// Token: 0x17000A4C RID: 2636
// (get) Token: 0x06002D70 RID: 11632 RVA: 0x0004083C File Offset: 0x0003EA3C
public string error
{
get
{
string text;
if (!this._uwr.isDone)
{
text = null;
}
else if (this._uwr.isNetworkError)
{
text = this._uwr.error;
}
else if (this._uwr.responseCode >= 400L)
{
text = string.Format("{0} {1}", this._uwr.responseCode, this.GetStatusCodeName(this._uwr.responseCode));
}
else
{
text = null;
}
return text;
}
}
// Token: 0x17000A4D RID: 2637
// (get) Token: 0x06002D71 RID: 11633 RVA: 0x000408D4 File Offset: 0x0003EAD4
public bool isDone
{
get
{
return this._uwr.isDone;
}
}
// Token: 0x17000A4E RID: 2638
// (get) Token: 0x06002D72 RID: 11634 RVA: 0x000408F4 File Offset: 0x0003EAF4
public float progress
{
get
{
float num = this._uwr.downloadProgress;
if (num < 0f)
{
num = 0f;
}
return num;
}
}
// Token: 0x17000A4F RID: 2639
// (get) Token: 0x06002D73 RID: 11635 RVA: 0x00040928 File Offset: 0x0003EB28
public Dictionary<string, string> responseHeaders
{
get
{
Dictionary<string, string> dictionary;
if (!this.isDone || this._uwr.isNetworkError)
{
dictionary = null;
}
else
{
if (this._responseHeaders == null)
{
this._responseHeaders = this._uwr.GetResponseHeaders();
this._responseHeaders["STATUS"] = string.Format("HTTP/1.1 {0} {1}", this._uwr.responseCode, this.GetStatusCodeName(this._uwr.responseCode));
}
dictionary = this._responseHeaders;
}
return dictionary;
}
}
// Token: 0x17000A50 RID: 2640
// (get) Token: 0x06002D74 RID: 11636 RVA: 0x000409C0 File Offset: 0x0003EBC0
[Obsolete("Please use WWW.text instead. (UnityUpgradable) -> text", true)]
public string data
{
get
{
return this.text;
}
}
// Token: 0x17000A51 RID: 2641
// (get) Token: 0x06002D75 RID: 11637 RVA: 0x000409DC File Offset: 0x0003EBDC
public string text
{
get
{
string text;
if (!this.WaitUntilDoneIfPossible())
{
text = "";
}
else if (this._uwr.isNetworkError)
{
text = "";
}
else
{
DownloadHandler downloadHandler = this._uwr.downloadHandler;
if (downloadHandler == null)
{
text = "";
}
else
{
text = downloadHandler.text;
}
}
return text;
}
}
// Token: 0x06002D76 RID: 11638 RVA: 0x00040A48 File Offset: 0x0003EC48
private Texture2D CreateTextureFromDownloadedData(bool markNonReadable)
{
Texture2D texture2D;
if (!this.WaitUntilDoneIfPossible())
{
texture2D = new Texture2D(2, 2);
}
else if (this._uwr.isNetworkError)
{
texture2D = null;
}
else
{
DownloadHandler downloadHandler = this._uwr.downloadHandler;
if (downloadHandler == null)
{
texture2D = null;
}
else
{
Texture2D texture2D2 = new Texture2D(2, 2);
texture2D2.LoadImage(downloadHandler.data, markNonReadable);
texture2D = texture2D2;
}
}
return texture2D;
}
// Token: 0x17000A52 RID: 2642
// (get) Token: 0x06002D77 RID: 11639 RVA: 0x00040ABC File Offset: 0x0003ECBC
public Texture2D texture
{
get
{
return this.CreateTextureFromDownloadedData(false);
}
}
// Token: 0x17000A53 RID: 2643
// (get) Token: 0x06002D78 RID: 11640 RVA: 0x00040AD8 File Offset: 0x0003ECD8
public Texture2D textureNonReadable
{
get
{
return this.CreateTextureFromDownloadedData(true);
}
}
// Token: 0x06002D79 RID: 11641 RVA: 0x00040AF4 File Offset: 0x0003ECF4
public void LoadImageIntoTexture(Texture2D texture)
{
if (this.WaitUntilDoneIfPossible())
{
if (this._uwr.isNetworkError)
{
Debug.LogError("Cannot load image: download failed");
}
else
{
DownloadHandler downloadHandler = this._uwr.downloadHandler;
if (downloadHandler == null)
{
Debug.LogError("Cannot load image: internal error");
}
else
{
texture.LoadImage(downloadHandler.data, false);
}
}
}
}
// Token: 0x17000A54 RID: 2644
// (get) Token: 0x06002D7A RID: 11642 RVA: 0x00040B64 File Offset: 0x0003ED64
// (set) Token: 0x06002D7B RID: 11643 RVA: 0x00040B80 File Offset: 0x0003ED80
public ThreadPriority threadPriority { get; set; }
// Token: 0x17000A55 RID: 2645
// (get) Token: 0x06002D7C RID: 11644 RVA: 0x00040B8C File Offset: 0x0003ED8C
public float uploadProgress
{
get
{
float num = this._uwr.uploadProgress;
if (num < 0f)
{
num = 0f;
}
return num;
}
}
// Token: 0x17000A56 RID: 2646
// (get) Token: 0x06002D7D RID: 11645 RVA: 0x00040BC0 File Offset: 0x0003EDC0
public string url
{
get
{
return this._uwr.url;
}
}
// Token: 0x17000A57 RID: 2647
// (get) Token: 0x06002D7E RID: 11646 RVA: 0x00040BE0 File Offset: 0x0003EDE0
public override bool keepWaiting
{
get
{
return !this._uwr.isDone;
}
}
// Token: 0x06002D7F RID: 11647 RVA: 0x00040C04 File Offset: 0x0003EE04
public void Dispose()
{
this._uwr.Dispose();
}
// Token: 0x06002D80 RID: 11648 RVA: 0x00040C14 File Offset: 0x0003EE14
internal Object GetAudioClipInternal(bool threeD, bool stream, bool compressed, AudioType audioType)
{
return WebRequestWWW.InternalCreateAudioClipUsingDH(this._uwr.downloadHandler, this._uwr.url, stream, compressed, audioType);
}
// Token: 0x06002D81 RID: 11649 RVA: 0x00040C48 File Offset: 0x0003EE48
internal object GetMovieTextureInternal()
{
return WebRequestWWW.InternalCreateMovieTextureUsingDH(this._uwr.downloadHandler);
}
// Token: 0x06002D82 RID: 11650 RVA: 0x00040C70 File Offset: 0x0003EE70
private bool WaitUntilDoneIfPossible()
{
bool flag;
if (this._uwr.isDone)
{
flag = true;
}
else if (this.url.StartsWith("file://", StringComparison.OrdinalIgnoreCase))
{
while (!this._uwr.isDone)
{
}
flag = true;
}
else
{
Debug.LogError("You are trying to load data from a www stream which has not completed the download yet.\nYou need to yield the download or wait until isDone returns true.");
flag = false;
}
return flag;
}
// Token: 0x06002D83 RID: 11651 RVA: 0x00040CE0 File Offset: 0x0003EEE0
private string GetStatusCodeName(long statusCode)
{
if (statusCode >= 400L && statusCode <= 416L)
{
switch ((int)(statusCode - 400L))
{
case 0:
return "Bad Request";
case 1:
return "Unauthorized";
case 2:
return "Payment Required";
case 3:
return "Forbidden";
case 4:
return "Not Found";
case 5:
return "Method Not Allowed";
case 6:
return "Not Acceptable";
case 7:
return "Proxy Authentication Required";
case 8:
return "Request Timeout";
case 9:
return "Conflict";
case 10:
return "Gone";
case 11:
return "Length Required";
case 12:
return "Precondition Failed";
case 13:
return "Request Entity Too Large";
case 14:
return "Request-URI Too Long";
case 15:
return "Unsupported Media Type";
case 16:
return "Requested Range Not Satisfiable";
}
}
if (statusCode >= 200L && statusCode <= 206L)
{
switch ((int)(statusCode - 200L))
{
case 0:
return "OK";
case 1:
return "Created";
case 2:
return "Accepted";
case 3:
return "Non-Authoritative Information";
case 4:
return "No Content";
case 5:
return "Reset Content";
case 6:
return "Partial Content";
}
}
if (statusCode >= 300L && statusCode <= 307L)
{
switch ((int)(statusCode - 300L))
{
case 0:
return "Multiple Choices";
case 1:
return "Moved Permanently";
case 2:
return "Found";
case 3:
return "See Other";
case 4:
return "Not Modified";
case 5:
return "Use Proxy";
case 7:
return "Temporary Redirect";
}
}
if (statusCode >= 500L && statusCode <= 505L)
{
switch ((int)(statusCode - 500L))
{
case 0:
return "Internal Server Error";
case 1:
return "Not Implemented";
case 2:
return "Bad Gateway";
case 3:
return "Service Unavailable";
case 4:
return "Gateway Timeout";
case 5:
return "HTTP Version Not Supported";
}
}
string text;
if (statusCode != 41L)
{
text = "";
}
else
{
text = "Expectation Failed";
}
return text;
}
// Token: 0x06002D84 RID: 11652 RVA: 0x00040FDC File Offset: 0x0003F1DC
public static string EscapeURL(string s)
{
return WWW.EscapeURL(s, Encoding.UTF8);
}
// Token: 0x06002D85 RID: 11653 RVA: 0x00040FFC File Offset: 0x0003F1FC
public static string EscapeURL(string s, Encoding e)
{
string text;
if (s == null)
{
text = null;
}
else if (s == "")
{
text = "";
}
else if (e == null)
{
text = null;
}
else
{
text = WWWTranscoder.URLEncode(s, e);
}
return text;
}
// Token: 0x06002D86 RID: 11654 RVA: 0x00041050 File Offset: 0x0003F250
public static string UnEscapeURL(string s)
{
return WWW.UnEscapeURL(s, Encoding.UTF8);
}
// Token: 0x06002D87 RID: 11655 RVA: 0x00041070 File Offset: 0x0003F270
public static string UnEscapeURL(string s, Encoding e)
{
string text;
if (s == null)
{
text = null;
}
else if (s.IndexOf('%') == -1 && s.IndexOf('+') == -1)
{
text = s;
}
else
{
text = WWWTranscoder.URLDecode(s, e);
}
return text;
}
// Token: 0x06002D88 RID: 11656 RVA: 0x000410BC File Offset: 0x0003F2BC
public static WWW LoadFromCacheOrDownload(string url, int version)
{
return WWW.LoadFromCacheOrDownload(url, version, 0U);
}
// Token: 0x06002D89 RID: 11657 RVA: 0x000410DC File Offset: 0x0003F2DC
public static WWW LoadFromCacheOrDownload(string url, int version, uint crc)
{
Hash128 hash = new Hash128(0U, 0U, 0U, (uint)version);
return WWW.LoadFromCacheOrDownload(url, hash, crc);
}
// Token: 0x06002D8A RID: 11658 RVA: 0x00041104 File Offset: 0x0003F304
public static WWW LoadFromCacheOrDownload(string url, Hash128 hash)
{
return WWW.LoadFromCacheOrDownload(url, hash, 0U);
}
// Token: 0x06002D8B RID: 11659 RVA: 0x00041124 File Offset: 0x0003F324
public static WWW LoadFromCacheOrDownload(string url, Hash128 hash, uint crc)
{
return new WWW(url, "", hash, crc);
}
// Token: 0x06002D8C RID: 11660 RVA: 0x00041148 File Offset: 0x0003F348
public static WWW LoadFromCacheOrDownload(string url, CachedAssetBundle cachedBundle, uint crc = 0U)
{
return new WWW(url, cachedBundle.name, cachedBundle.hash, crc);
}
// Token: 0x06002D8D RID: 11661 RVA: 0x00041174 File Offset: 0x0003F374
private static string[] FlattenedHeadersFrom(Dictionary<string, string> headers)
{
string[] array;
if (headers == null)
{
array = null;
}
else
{
string[] array2 = new string[headers.Count * 2];
int num = 0;
foreach (KeyValuePair<string, string> keyValuePair in headers)
{
array2[num++] = keyValuePair.Key.ToString();
array2[num++] = keyValuePair.Value.ToString();
}
array = array2;
}
return array;
}
// Token: 0x06002D8E RID: 11662 RVA: 0x00041214 File Offset: 0x0003F414
internal static Dictionary<string, string> ParseHTTPHeaderString(string input)
{
if (input == null)
{
throw new ArgumentException("input was null to ParseHTTPHeaderString");
}
Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
StringReader stringReader = new StringReader(input);
int num = 0;
for (;;)
{
string text = stringReader.ReadLine();
if (text == null)
{
break;
}
if (num++ == 0 && text.StartsWith("HTTP"))
{
dictionary["STATUS"] = text;
}
else
{
int num2 = text.IndexOf(": ");
if (num2 != -1)
{
string text2 = text.Substring(0, num2).ToUpper();
string text3 = text.Substring(num2 + 2);
string text4;
if (dictionary.TryGetValue(text2, out text4))
{
text3 = text4 + "," + text3;
}
dictionary[text2] = text3;
}
}
}
return dictionary;
}
// Token: 0x17000A58 RID: 2648
// (get) Token: 0x06002D8F RID: 11663 RVA: 0x000412F8 File Offset: 0x0003F4F8
[Obsolete("Obsolete msg (UnityUpgradable) -> * UnityEngine.WWWAudioExtensions.GetAudioClip(UnityEngine.WWW)", true)]
public Object audioClip
{
get
{
return null;
}
}
// Token: 0x17000A59 RID: 2649
// (get) Token: 0x06002D90 RID: 11664 RVA: 0x00041310 File Offset: 0x0003F510
[Obsolete("Obsolete msg (UnityUpgradable) -> * UnityEngine.WWWAudioExtensions.GetMovieTexture(UnityEngine.WWW)", true)]
public Object movie
{
get
{
return null;
}
}
// Token: 0x040008A8 RID: 2216
private UnityWebRequest _uwr;
// Token: 0x040008A9 RID: 2217
private AssetBundle _assetBundle;
// Token: 0x040008AA RID: 2218
private Dictionary<string, string> _responseHeaders;
}
}