/// <summary> /// 停止下载 /// 取消当前正在下载的资源 /// 清空整个队列 /// </summary> public void StopDownload() { if (null != httpClient) { httpClient.Abort(); } downloadSortSet.Clear(); }
public void CloseConnection(string s) { if (Client != null) { Client.Abort(); IsConnected = false; Debug.Console(1, this, "Client Disconnected"); } }
public string FanTo0() { var request = new HttpClientRequest(); request.Url.Parse("http://" + ip + "/control"); request.RequestType = RequestType.Post; request.Header.SetHeaderValue("content-type", "application/x-www-form-urlencoded"); request.Header.SetHeaderValue("content-length", "17"); request.Header.SetHeaderValue("connection", "close"); request.ContentString = "fan=0"; var response = client.Dispatch(request); client.Abort(); // TODO: Fb Handler return(response.ContentString.ToString()); }
public IDisposable HttpPatch(string url, Dictionary <string, string> headers, Dictionary <string, string> contentDict, Action <string> onResponse) { var httpClient = new HttpClient(); if (headers.IsNotNull()) { headers.ForEach((key, value) => { httpClient.Headers.Add(key, value); }); } var jsonForm = new JObject(); contentDict.ForEach((key, value) => { jsonForm[key] = value; }); var content = new ByteArrayContent(Encoding.UTF8.GetBytes(jsonForm.ToString()), "application/json"); httpClient.Patch(new Uri(url), content, (responseContent) => { onResponse(responseContent.Data); }); return(Disposable.Create(() => httpClient.Abort())); }
protected override void OnReset() { m_sent = false; m_client.Abort(); }