/// <summary> /// 以Restful进行请求 /// </summary> /// <param name="method">方法类型</param> /// <param name="action">请求行为</param> /// <param name="body">包体数据</param> public void Restful(Restfuls method, string action, byte[] body) { var request = new HttpWebRequestEntity(url + action, method); request.SetBody(body).SetContentType("application/octet-stream"); queue.Enqueue(request); }
/// <summary> /// 以Restful请求 /// </summary> /// <param name="method">方法类型</param> /// <param name="action">请求行为</param> /// <param name="form">包体数据</param> public void Restful(Restfuls method, string action, WWWForm form) { var request = new HttpWebRequestEntity(url + action, method); request.SetBody(form.data).SetContentType("application/x-www-form-urlencoded"); queue.Enqueue(request); }
public void Restful(Restfuls method, string action, WWWForm form) { if (method == Restfuls.Post) { UnityWebRequest request = UnityWebRequest.Post(url + action, form); queue.Enqueue(request); } else { Restful(method, action, form.data); } }
public void Restful(Restfuls method, string action, byte[] body) { UnityWebRequest request = null; switch (method) { case Restfuls.Get: request = UnityWebRequest.Get(url + action); break; case Restfuls.Put: request = UnityWebRequest.Put(url + action, body); break; case Restfuls.Delete: request = UnityWebRequest.Delete(url + action); break; case Restfuls.Head: request = UnityWebRequest.Head(url + action); break; default: throw new Exception("this component is not support [" + method.ToString() + "] restful"); } queue.Enqueue(request); }
/// <summary> /// 构建一个请求实体 /// </summary> /// <param name="uri">uri</param> public HttpWebRequestEntity(string uri) { this.uri = uri; method = Restfuls.Get; }
/// <summary> /// 设定请求方法 /// </summary> /// <param name="method">方法</param> /// <returns>当前实例</returns> public HttpWebRequestEntity SetMethod(Restfuls method) { this.method = method; return(this); }
/// <summary> /// 构建一个请求实体 /// </summary> /// <param name="uri">uri</param> /// <param name="method">方法</param> public HttpWebRequestEntity(string uri, Restfuls method) { this.uri = uri; this.method = method; }
public void Restful(Restfuls method, string action) { UnityWebRequest request = new UnityWebRequest(url + action, method.ToString()); queue.Enqueue(request); }
/// <summary> /// 以Restful请求 /// </summary> /// <param name="method">方法类型</param> /// <param name="action">请求行为</param> public void Restful(Restfuls method, string action) { var request = new HttpWebRequestEntity(url + action, method); queue.Enqueue(request); }