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())); } }
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; } }
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}"); } }
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); } }
public string PostFormat(string url, string data, TypeHttpMethod method) { return(string.Format("await client.NotGet(\"{0}\",{1},\"{2}\");", url, data, method)); }
public MethodHttp(TypeHttpMethod typeHttpMethod) { this.LabelMethod = typeHttpMethod.ToString(); this.ValueMathod = typeHttpMethod; }
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); } }