using System; using UnityEngine; using System.Collections.Generic; using UnityEngine.Networking; namespace Proyecto26 { [Serializable] public class ResponseHelper { /// /// The UnityWebRequest used in the current request. /// public UnityWebRequest Request { get; private set; } public ResponseHelper(UnityWebRequest request) { Request = request; } /// /// The numeric HTTP response code returned by the server. /// public long StatusCode { get { return Request.responseCode; } } /// /// Returns the raw bytes downloaded from the remote server, or null. /// public byte[] Data { get { byte[] _data; try { _data = Request.downloadHandler.data; } catch (Exception) { _data = null; } return _data; } } /// /// Returns the bytes from data interpreted as a UTF8 string. /// public string Text { get { string _text; try { _text = Request.downloadHandler.text; } catch (Exception) { _text = string.Empty; } return _text; } } /// /// A human-readable string describing any system errors encountered by the UnityWebRequest object of this response while handling HTTP requests or responses. /// public string Error { get { return Request.error; } } /// /// Get response headers /// public Dictionary Headers { get { return Request.GetResponseHeaders(); } } /// /// Get the value of a header /// /// The string value of the header. /// The name of the header. public string GetHeader(string name) { return this.Request.GetResponseHeader(name); } public override string ToString() { return JsonUtility.ToJson(this, true); } } }