Exemple #1
0
        /// <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);
        }
Exemple #2
0
        /// <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);
        }
Exemple #3
0
 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);
     }
 }
Exemple #4
0
        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);
        }
Exemple #5
0
 /// <summary>
 /// 构建一个请求实体
 /// </summary>
 /// <param name="uri">uri</param>
 public HttpWebRequestEntity(string uri)
 {
     this.uri = uri;
     method   = Restfuls.Get;
 }
Exemple #6
0
 /// <summary>
 /// 设定请求方法
 /// </summary>
 /// <param name="method">方法</param>
 /// <returns>当前实例</returns>
 public HttpWebRequestEntity SetMethod(Restfuls method)
 {
     this.method = method;
     return(this);
 }
Exemple #7
0
 /// <summary>
 /// 构建一个请求实体
 /// </summary>
 /// <param name="uri">uri</param>
 /// <param name="method">方法</param>
 public HttpWebRequestEntity(string uri, Restfuls method)
 {
     this.uri    = uri;
     this.method = method;
 }
Exemple #8
0
        public void Restful(Restfuls method, string action)
        {
            UnityWebRequest request = new UnityWebRequest(url + action, method.ToString());

            queue.Enqueue(request);
        }
Exemple #9
0
        /// <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);
        }