Пример #1
0
 public string PostFormat(string url, string data, TypeHttpMethod method)
 {
     if (Headers)
     {
         return(string.Format("client.NotGet(\"{0}\",{1},\"{2}\",whc);", url, data, method.ToString()));
     }
     else
     {
         return(string.Format("client.NotGet(\"{0}\",{1},\"{2}\");", url, data, method.ToString()));
     }
 }
Пример #2
0
        private void cbHttpMethod_SelectedIndexChanged(object sender, EventArgs e)
        {
            TypeHttpMethod typeSelected = this.GetHttpMethodInComboBox();

            if (typeSelected == TypeHttpMethod.GET)
            {
                this.txtDataJson.Enabled = false;
            }
            else
            {
                this.txtDataJson.Enabled = true;
            }
        }
Пример #3
0
        public async Task <string> DoRequest(string url, string datas, TypeHttpMethod typeHttpMethod)
        {
            try
            {
                HttpContent httpContent = null;
                if (typeHttpMethod != TypeHttpMethod.GET && typeHttpMethod != TypeHttpMethod.DELETE)
                {
                    httpContent = this.BuildHttpContent(datas);
                }

                HttpResponseMessage responseMessage = await this.Execute(url, httpContent, typeHttpMethod);

                return(await this.BuildReturn(responseMessage));
            }
            catch (Exception e)
            {
                return($"Exception: {e.Message}");
            }
        }
Пример #4
0
        private async void DoRequest(string url)
        {
            try
            {
                this.IncrementProgress();
                TypeHttpMethod typeHttpMethod = this.GetHttpMethodInComboBox();
                this.IncrementProgress();
                string datasToSend = this.GetDatasToSend();
                this.IncrementProgress();
                string responseHttp = await this._requestHttp.DoRequest(url, datasToSend, typeHttpMethod);

                this.FnishIncrementProgress();
                this.txtResponse.Text = responseHttp;
            }
            catch (Exception)
            {
                this.FnishIncrementProgress();
                MessageBox.Show("Selecione um método", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Пример #5
0
 public string PostFormat(string url, string data, TypeHttpMethod method)
 {
     return(string.Format("await client.NotGet(\"{0}\",{1},\"{2}\");", url, data, method));
 }
Пример #6
0
 public MethodHttp(TypeHttpMethod typeHttpMethod)
 {
     this.LabelMethod = typeHttpMethod.ToString();
     this.ValueMathod = typeHttpMethod;
 }
Пример #7
0
        private async Task <HttpResponseMessage> Execute(string url, HttpContent httpContent, TypeHttpMethod typeHttpMethod)
        {
            IgnoreCertificate();

            switch (typeHttpMethod)
            {
            case TypeHttpMethod.POST:
                return(await httpClient.PostAsync(url, httpContent));

            case TypeHttpMethod.PUT:
                return(await httpClient.PutAsync(url, httpContent));

            case TypeHttpMethod.DELETE:
                return(await httpClient.DeleteAsync(url));

            case TypeHttpMethod.GET:
                return(await httpClient.GetAsync(url));

            default:
                return(null);
            }
        }