12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System.IO;
- using System.Net;
- using System.Text;
- namespace MemberWeb.Commonss
- {
- public static class ClickHouseUtil
- {
- static string conentUrl = "http://139.159.192.185:8123/?user=default&password=79B084A8D7363488DEBFA5D151CCC9B1";
- public static string HttpClickHouseGet(string url)
- {
- url = conentUrl + "&query=" + url;
- WebRequest myWebRequest = WebRequest.Create(url);
- WebResponse myWebResponse = myWebRequest.GetResponse();
- myWebRequest.Timeout = 60000;
- Stream ReceiveStream = myWebResponse.GetResponseStream();
- string responseStr = "";
- if (ReceiveStream != null)
- {
- StreamReader reader = new StreamReader(ReceiveStream, Encoding.UTF8);
- responseStr = reader.ReadToEnd();
- reader.Close();
- }
- myWebResponse.Close();
- return responseStr;
- }
- public static string HttpClickHousePost(string body, string contentType)
- {
- string url = conentUrl;
- HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url);
- httpWebRequest.ContentType = contentType;
- httpWebRequest.Method = "POST";
- httpWebRequest.Timeout = 20000;
- byte[] btBodys = Encoding.UTF8.GetBytes(body);
- httpWebRequest.ContentLength = btBodys.Length;
- httpWebRequest.GetRequestStream().Write(btBodys, 0, btBodys.Length);
- HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse();
- StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream());
- string responseContent = streamReader.ReadToEnd();
- httpWebResponse.Close();
- streamReader.Close();
- httpWebRequest.Abort();
- httpWebResponse.Close();
- return responseContent;
- }
- }
- }
|