/// <summary> /// Sends a POST request. /// </summary> /// <param name="resource">The resource.</param> /// <param name="parameters">The parameters.</param> /// <param name="content">The payload for the content of the HTTP request.</param> /// <returns></returns> public async Task <HttpResponseMessage> PostAsync(string resource, HttpParams parameters = null, object content = null) { using (var client = HttpClientProvider.Create()) { return(await SendAsync(client, HttpMethod.Post, ApiUrl, resource, parameters, content)); } }
/// <summary> /// Sends a PUT request and deserialises the JSON response. /// </summary> /// <typeparam name="T">The class to use to deserialise the JSON response.</typeparam> /// <param name="resource">The resource.</param> /// <param name="parameters">The parameters.</param> /// <param name="content">The content.</param> /// <returns></returns> public async Task <T> PutAsync <T>(string resource, HttpParams parameters = null, object content = null) { using (var client = HttpClientProvider.Create()) { return(await SendAsync <T>(client, HttpMethod.Put, ApiUrl, resource, parameters, content)); } }
public async Task <string> SearchRAsync(string name, int page) { #region 方法一 HttpParams hp = new HttpParams() { Url = "http://api.xiami.com/web", Referer = "http://h.xiami.com/", Data = "key=" + HttpUtility.UrlEncode(name) + "&v=2.0&app_key=1&r=search/songs&page=" + page + "&limit=10", Agent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/55.0.2883.75 Safari/537.36" }; return(await HttpHelper.GetAsync(hp)); #endregion #region 方法二失败(指令[cookie]会过期) //HttpParams hp = new HttpParams() //{ // Url = "https://h5api.m.xiami.com/h5/mtop.alimusic.search.searchservice.searchsongs/1.0/", // //Referer = "http://m.xiami.com", // Data = "appKey=12574478&t=1538141651547&sign=2e0492c39e681e4c15ab504fd628d0d6&v=1.0&type=originaljson&dataType=json&api=mtop.alimusic.search.searchservice.searchsongs&data=%7B%22requestStr%22%3A%22%7B%5C%22header%5C%22%3A%7B%5C%22platformId%5C%22%3A%5C%22win%5C%22%2C%5C%22remoteIp%5C%22%3A%5C%22192.168.1.106%5C%22%2C%5C%22callId%5C%22%3A1538141651539%2C%5C%22sign%5C%22%3A%5C%22872e314826a9afefd3227ed492f7e3af%5C%22%2C%5C%22appId%5C%22%3A200%2C%5C%22deviceId%5C%22%3A%5C%225fd4d48586fc6093bbb8558cf949a43b2eb643d1e5b50f7a9ef1f8408a459cb8%5C%22%2C%5C%22network%5C%22%3A1%2C%5C%22appVersion%5C%22%3A3010200%2C%5C%22resolution%5C%22%3A%5C%221178*704%5C%22%2C%5C%22utdid%5C%22%3A%5C%225fd4d48586fc6093bbb8558cf949a43b2eb643d1e5b50f7a9ef1f8408a459cb8%5C%22%7D%2C%5C%22model%5C%22%3A%7B%5C%22key%5C%22%3A%5C%22%E4%BD%A0%E6%98%AF%5C%22%2C%5C%22pagingVO%5C%22%3A%7B%5C%22page%5C%22%3A1%7D%7D%7D%22%7D", // Agent = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) XIAMI-MUSIC/3.1.2 Chrome/56.0.2924.87 Electron/1.6.11 Safari/537.36", //}; //return await HttpHelper.GetAsync(hp); #endregion #region 方法三 // HttpParams hp = new HttpParams() //{ // Url = "https://www.xiami.com/search", // Data = "key=" + HttpUtility.UrlEncode(name) + "&pos=" + page, //}; //return await HttpHelper.GetAsync(hp); #endregion }
/// <summary> /// Sends a DELETE request and deserialises the JSON response. /// </summary> /// <typeparam name="T">The class to use to deserialise the JSON response.</typeparam> /// <param name="resource">The resource.</param> /// <param name="parameters">The parameters.</param> /// <returns></returns> public async Task <T> DeleteAsync <T>(string resource, HttpParams parameters = null) { using (var client = HttpClientProvider.Create()) { return(await SendAsync <T>(client, HttpMethod.Delete, ApiUrl, resource, parameters)); } }
public static async Task <string> PostAsync(HttpParams hp) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(hp.Url); // request.Headers.Add(HttpRequestHeader.Cookie, "_iuqxldmzr_=32; _ntes_nnid=cfb20d675b37ef82883687bed10b0f68,1533467251037; _ntes_nuid=cfb20d675b37ef82883687bed10b0f68; WM_TID=TkaWyJQS0UM8cqq7iCxEIqBzpfEF9AMQ; usertrack=ezq0pFuHk1U3p4UQBckbAg==; __f_=1535854971328; vjuids=737ea9cc5.1659fcb94f jsessioni8.0.908420a2b47f7; vjlast=1535984244.1535984244.30; vinfo_n_f_l_n3=954b8e5bcd63e6d7.1.0.1535984243979.0.1535984250209; hb_MA-9ADA-91BF1A6C9E06_source=www.google.com; mp_MA-9ADA-91BF1A6C9E06_hubble=%7B%22sessionReferrer%22%3A%20%22https%3A%2F%2Fcampus.163.com%2Fapp%2Fhy%2Flh%22%2C%22updatedTime%22%3A%201536561490090%2C%22sessionStartTime%22%3A%201536560972018%2C%22sendNumClass%22%3A%20%7B%22allNum%22%3A%203%2C%22errSendNum%22%3A%200%7D%2C%22deviceUdid%22%3A%20%220e9c86ef-0338-4c3d-a87f-b67f20309fc8%22%2C%22persistedTime%22%3A%201536560972009%2C%22LASTEVENT%22%3A%20%7B%22eventId%22%3A%20%22da_screen%22%2C%22time%22%3A%201536561490091%7D%2C%22sessionUuid%22%3A%20%228a2f1ffb-4854-4b86-aed8-dfc7ce8a8baf%22%7D; JSESSIONID-WYYY=%5C26JeRzJnXdr6MS39TovmAvR869vqAKafZu1ZH9hZfozdTvccBjshTIdTy0dS3NbcJ9pVwuJrDjYFGAhM7GGZzx%2Br51OIAk8eyc7orjp39hffDKV7aM4tvi5eYEO8YJy5VbifIP2DTW9dBjQIHi4G1tluv4kzrvViMsYMAT9tH2VhM2l%3A1537696218369; WM_NI=yrWHuZoW1g%2FcANgvcm3jqJgrG%2BPXt1fpyfOykUaesXPxX6o3S3NTVtqVqOiIOkuhcIEX%2B5IKV%2F23lwFxuaII%2FIMieCVn24Mt0rGvXdfXfzsa%2BB%2FpC5xryg9S4qyEo8BITnc%3D; WM_NIKE=9ca17ae2e6ffcda170e2e6eed2c64891ad8cb7f144f2bc8aa6d44a939b8b84bc6b928efd9bbc62a9ae86b5b72af0fea7c3b92abbae99a9f852ad89ff88ae698392a997e267f1b6bfabe67a85f5a0b9f73ba6b0b787ce73a98baf86f25494a898d7ee3991ed82b5d580b38abfb0ec438db5bb89e2438788e5d6cc4196f1fed4ef7d86a8bb82cc43ed97838ae84996b2fed5d080f4ae8997db70a688aa9bf26be99ee191c23fbcaeb788bc59f8afb7a6ee3482979c8fe237e2a3; __remember_me=true;MUSIC_U=457f1c671a49ed2bccd53d319c01f8b8f42d0c452979f5610acb7aac9f21921dc3c1140b5735a834269c8ca95be0a91f31b299d667364ed3; __csrf=64110e6ce458515052955efc9357c556"); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.Referer = hp.Referer; request.UserAgent = hp.Agent; request.CookieContainer = cookie; //要吗 不能直接这样,会把 = 一并给encode了 //string data = HttpUtility.UrlEncode(hp.Data); byte[] daby = Encoding.ASCII.GetBytes(hp.Data); using (Stream stream = request.GetRequestStream()) { stream.Write(daby, 0, daby.Length); } HttpWebResponse response = (HttpWebResponse)await request.GetResponseAsync(); //保存cookie response.Cookies = cookie.GetCookies(response.ResponseUri); return(new StreamReader(response.GetResponseStream()).ReadToEnd()); //Stream myResposeStream = response.GetResponseStream(); //StreamReader myStreamReader = new StreamReader(myResposeStream); //string responseStr = myStreamReader.ReadToEnd(); //myStreamReader.Close(); //myResposeStream.Close(); }
/// <summary>Create a new HTTP service.</summary> /// <remarks>Create a new HTTP service.</remarks> /// <param name="processor">the processor to use on requests and responses</param> /// <param name="connStrategy">the connection reuse strategy</param> /// <param name="responseFactory">the response factory</param> /// <param name="handlerResolver">the handler resolver. May be null.</param> /// <param name="params">the HTTP parameters</param> /// <since>4.1</since> [System.ObsoleteAttribute(@"(4.3) use HttpService(HttpProcessor, Org.Apache.Http.ConnectionReuseStrategy, Org.Apache.Http.HttpResponseFactory, HttpRequestHandlerMapper)")] public HttpService(HttpProcessor processor, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory, HttpRequestHandlerResolver handlerResolver, HttpParams @params) : this(processor, connStrategy, responseFactory, new HttpService.HttpRequestHandlerResolverAdapter (handlerResolver), null) { this.@params = @params; }
/// <summary> /// Requests an access and refresh token from the code provided by the mercado libre callback. /// </summary> /// <param name="code">The code.</param> /// <param name="redirectUri">The redirect URI.</param> /// <returns> /// Return True when the operation is successful. /// </returns> public async Task <bool> AuthorizeAsync(string code, string redirectUri) { if (Credentials == null) { throw new ApplicationException("Credentials property not initalised."); } var success = false; var parameters = new HttpParams().Add("grant_type", "authorization_code") .Add("client_id", Credentials.ClientId) .Add("client_secret", Credentials.ClientSecret) .Add("code", code) .Add("redirect_uri", redirectUri); using (var client = HttpClientProvider.Create(false)) { var tokens = await SendAsync <TokenResponse>(client, HttpMethod.Post, ApiUrl, "/oauth/token", parameters); if (tokens != null) { Credentials.SetTokens(tokens); success = true; } } return(success); }
/// <summary>Copies the locally defined parameters to the argument parameters.</summary> /// <remarks> /// Copies the locally defined parameters to the argument parameters. /// This method is called from /// <see cref="Clone()">Clone()</see> /// . /// </remarks> /// <param name="target">the parameters to which to copy</param> /// <since>4.2</since> public virtual void CopyParams(HttpParams target) { foreach (KeyValuePair <string, object> me in this.parameters.EntrySet()) { target.SetParameter(me.Key, me.Value); } }
public async static Task<HttpResult> HttpGetWithCode(String url, HttpParams httpParams = null) { if (httpParams == null) httpParams = HttpParams.Default; HttpClient client = null; if (String.IsNullOrEmpty(httpParams.Proxy)) { client = new HttpClient() { Timeout = httpParams.Timeout }; } else { var httpClientHandler = new HttpClientHandler { Proxy = new WebProxy(httpParams.Proxy, false), UseProxy = true }; client = new HttpClient(httpClientHandler) { Timeout = httpParams.Timeout }; } using (client) { var response = await client.GetAsync(url); var responseText = await response.Content.ReadAsStringAsync(); // преобразуем Html-символы if (httpParams.Decode) responseText = WebUtility.HtmlDecode(responseText); return new HttpResult { Code = response.StatusCode, Result = responseText }; } }
public DefaultHttpResponseParser(SessionInputBuffer buffer, LineParser parser, HttpResponseFactory responseFactory, HttpParams @params) : base(buffer, parser, @params) { Args.NotNull(responseFactory, "Response factory"); this.responseFactory = responseFactory; this.lineBuf = new CharArrayBuffer(128); }
/// <summary>Creates an instance of this class.</summary> /// <remarks>Creates an instance of this class.</remarks> /// <param name="buffer">the session input buffer.</param> /// <param name="lineParser">the line parser.</param> /// <param name="requestFactory"> /// the factory to use to create /// <see cref="Org.Apache.Http.IHttpRequest">Org.Apache.Http.IHttpRequest</see> /// s. /// </param> /// <param name="params">HTTP parameters.</param> [System.ObsoleteAttribute(@"(4.3) useDefaultHttpRequestParser(Org.Apache.Http.IO.SessionInputBuffer, Org.Apache.Http.Message.LineParser, Org.Apache.Http.HttpRequestFactory, Org.Apache.Http.Config.MessageConstraints)")] public DefaultHttpRequestParser(SessionInputBuffer buffer, LineParser lineParser, HttpRequestFactory requestFactory, HttpParams @params) : base(buffer, lineParser , @params) { this.requestFactory = Args.NotNull(requestFactory, "Request factory"); this.lineBuf = new CharArrayBuffer(128); }
/// <summary>Creates an instance of AbstractMessageWriter.</summary> /// <remarks>Creates an instance of AbstractMessageWriter.</remarks> /// <param name="buffer">the session output buffer.</param> /// <param name="formatter">the line formatter.</param> /// <param name="params">HTTP parameters.</param> [System.ObsoleteAttribute(@"(4.3) useAbstractMessageWriter{T}.AbstractMessageWriter(Org.Apache.Http.IO.SessionOutputBuffer, Org.Apache.Http.Message.LineFormatter)")] public AbstractMessageWriter(SessionOutputBuffer buffer, LineFormatter formatter, HttpParams @params) : base() { Args.NotNull(buffer, "Session input buffer"); this.sessionBuffer = buffer; this.lineBuf = new CharArrayBuffer(128); this.lineFormatter = (formatter != null) ? formatter : BasicLineFormatter.Instance; }
public virtual HttpParams GetParams() { if (this.@params == null) { this.@params = new BasicHttpParams(); } return(this.@params); }
public MinimalHttpClient(HttpClientConnectionManager connManager) : base() { this.connManager = Args.NotNull(connManager, "HTTP connection manager"); this.requestExecutor = new MinimalClientExec(new HttpRequestExecutor(), connManager , DefaultConnectionReuseStrategy.Instance, DefaultConnectionKeepAliveStrategy.Instance ); this.@params = new BasicHttpParams(); }
public string GetRequestString(HttpParams httpParam, string postData, ref CookieContainer cookieContainer, X509Certificate2Collection X509) { var stream = _httpMethod.HttpBaseStep(httpParam, postData, ref cookieContainer, X509); var value = _httpMethod.GetResponseText(stream, httpParam.ResponseEncode); stream.Close(); return(value); }
//这个可以多个一起 然而是mv的 //public static string GetMusicInfo(string[] ids) // { // using (WebClient wc = new WebClient()) // { // string url = "https://u.y.qq.com/cgi-bin/musicu.fcg"; // //这个"=" ... // //string param = "{\"mv\":{\"module\":\"MvService.MvInfoProServer\",\"method\":\"GetMvBySongid\",\"param\":{\"mids\":[\"002RkFPr1R58Z8\"]}}}"; // string build = ""; // for (int i = 0; i < ids.Length-1; i++) // { // build += "\""+ids[i]+"\"" + ","; // } // build += "\""+ids[ids.Length - 1]+"\""; // string param = "{\"mv\":{\"module\":\"MvService.MvInfoProServer\",\"method\":\"GetMvBySongid\",\"param\":{\"mids\":["+build+"]}}}"; // param = HttpUtility.UrlEncode(param); // //param = "data=%7B%22mv%22%3A%7B%22module%22%3A%22MvService.MvInfoProServer%22%2C%22method%22%3A%22GetMvBySongid%22%2C%22param%22%3A%7B%22mids%22%3A%5B%22002RkFPr1R58Z8%22%5D%7D%7D%7D"; // string result = wc.DownloadString(url+"?data="+param); // return result; // } // } #endregion /// <summary> /// 返回html页面 /// </summary> /// <param name="id">mid</param> /// <returns></returns> public static async Task <string> GetMusicInfoAsync(string id) { HttpParams hp = new HttpParams() { Url = "https://y.qq.com/n/yqq/song/" + id + ".html", }; return(await HttpHelper.GetAsync(hp)); }
public Stream HttpBaseStep(HttpParams httpParam, string postData, ref CookieContainer cookieContainer, X509Certificate2Collection X509) { var request = GetRequest(httpParam, postData, cookieContainer, X509); var response = GetResponse(request); var cookie = GetCookie(response); cookieContainer = GetCookieContainer(cookieContainer, cookie, "http://localhost:59803/"); return(GetResponseStream(response)); }
/// <summary>Create a new HTTP service.</summary> /// <remarks>Create a new HTTP service.</remarks> /// <param name="processor">the processor to use on requests and responses</param> /// <param name="connStrategy">the connection reuse strategy</param> /// <param name="responseFactory">the response factory</param> /// <param name="handlerResolver">the handler resolver. May be null.</param> /// <param name="expectationVerifier">the expectation verifier. May be null.</param> /// <param name="params">the HTTP parameters</param> /// <since>4.1</since> [System.ObsoleteAttribute(@"(4.3) use HttpService(HttpProcessor, Org.Apache.Http.ConnectionReuseStrategy, Org.Apache.Http.HttpResponseFactory, HttpRequestHandlerMapper, HttpExpectationVerifier)")] public HttpService(HttpProcessor processor, ConnectionReuseStrategy connStrategy, HttpResponseFactory responseFactory, HttpRequestHandlerResolver handlerResolver, HttpExpectationVerifier expectationVerifier, HttpParams @params) : this(processor , connStrategy, responseFactory, new HttpService.HttpRequestHandlerResolverAdapter (handlerResolver), expectationVerifier) { // provided injected dependencies are immutable and deprecated methods are not used this.@params = @params; }
/// <summary> /// Sends a DELETE request and deserialises the JSON response. /// </summary> /// <typeparam name="T">The class to use to deserialise the JSON response.</typeparam> /// <param name="resource">The resource.</param> /// <param name="parameters">The parameters.</param> /// <param name="handler">The handler.</param> /// <returns></returns> public async Task <T> DeleteAsync <T>(string resource, HttpParams parameters = null, HttpClientHandler handler = null) { handler = handler ?? new HttpClientHandler(); using (var client = HttpClientProvider.Create(handler)) { return(await SendAsync <T>(client, HttpMethod.Delete, ApiUrl, resource, parameters)); } }
public static SocketConfig GetSocketConfig(HttpParams @params) { return(SocketConfig.Custom().SetSoTimeout(@params.GetIntParameter(CoreConnectionPNames .SoTimeout, 0)).SetSoReuseAddress(@params.GetBooleanParameter(CoreConnectionPNames .SoReuseaddr, false)).SetSoKeepAlive(@params.GetBooleanParameter(CoreConnectionPNames .SoKeepalive, false)).SetSoLinger(@params.GetIntParameter(CoreConnectionPNames.SoLinger , -1)).SetTcpNoDelay(@params.GetBooleanParameter(CoreConnectionPNames.TcpNodelay , true)).Build()); }
/// <summary> /// Sends a PUT request. /// </summary> /// <param name="resource">The resource.</param> /// <param name="parameters">The parameters.</param> /// <param name="content">The content.</param> /// <param name="handler">The handler.</param> /// <returns></returns> public async Task <HttpResponseMessage> PutAsync(string resource, HttpParams parameters = null, object content = null, HttpClientHandler handler = null) { handler = handler ?? new HttpClientHandler(); using (var client = HttpClientProvider.Create(handler)) { return(await SendAsync(client, HttpMethod.Put, ApiUrl, resource, parameters, content)); } }
/// <summary> /// Generate an URL to get an access token for other users. /// </summary> /// <param name="clientId">The client identifier (meli app ID).</param> /// <param name="site">The site.</param> /// <param name="redirectUri">The call back URI redirect URL to (Mercado Libre with append ?code=YOUR_SECRET_CODE to this URL).</param> /// <returns> /// The authentication URL to redirect your user to. /// </returns> public string GetAuthUrl(long clientId, MeliSite site, string redirectUri) { var parameters = new HttpParams().Add("response_type", "code") .Add("client_id", clientId) .Add("redirect_uri", redirectUri); var domain = site.ToDomain(); return($"https://auth.{domain}/authorization?{parameters}"); }
public async Task <string> GetLrcRAsync(string url) { HttpParams hp = new HttpParams() { Url = url, Referer = "http://music.baidu.com/song/" }; return(await HttpHelper.GetAsync(hp, "")); }
public async Task <string> GetLrcRAsync(string url) { HttpParams hp = new HttpParams() { Url = url.Contains("http")?url:"http:" + url }; string lrcStr = await HttpHelper.GetAsync(hp, ""); return(Regex.Replace(lrcStr, "<\\d+>", "")); }
/// <exception cref="System.IO.IOException"></exception> [System.ObsoleteAttribute(@"(4.3) no longer used.")] protected internal virtual HttpClientConnection Create(Socket socket, HttpParams @params) { int bufsize = @params.GetIntParameter(CoreConnectionPNames.SocketBufferSize, 8 * 1024); DefaultBHttpClientConnection conn = new DefaultBHttpClientConnection(bufsize); conn.Bind(socket); return(conn); }
/// <summary> /// Request a new token. /// </summary> /// <param name="originalRequest">The original request.</param> /// <param name="httpResponseMessage">The HTTP response message.</param> /// <returns> /// True to tell <see cref="RetryDelegatingHandler" /> to retry the original request. /// </returns> /// <remarks> /// Hook called automatically (set in constructor) by HttpClient after each request. /// </remarks> private async Task <bool> RequestNewToken(HttpRequestMessage originalRequest, HttpResponseMessage httpResponseMessage) { var shouldRetry = false; refreshTokenAttempt++; // Retry only once and if we have a refresh token and the token is invalid if (!httpResponseMessage.IsSuccessStatusCode && Credentials != null && !string.IsNullOrEmpty(Credentials.RefreshToken) && refreshTokenAttempt <= 1) { var content = await httpResponseMessage.Content.ReadAsStringAsync(); var response = JsonConvert.DeserializeObject <ErrorResponse>(content); if (response.Message == "invalid_token") { var parameters = new HttpParams().Add("grant_type", "refresh_token") .Add("client_id", Credentials.ClientId) .Add("client_secret", Credentials.ClientSecret) .Add("refresh_token", Credentials.RefreshToken); using (var client = new HttpClient()) { var request = new HttpRequestMessage { RequestUri = new Uri($"{ApiUrl}oauth/token?{parameters}"), Method = HttpMethod.Post, }; var tokenResponse = await client.SendAsync(request); if (tokenResponse.IsSuccessStatusCode) { var json = await tokenResponse.Content.ReadAsStringAsync(); var newTokens = JsonConvert.DeserializeObject <TokenResponse>(json); if (newTokens != null) { Credentials.SetTokens(newTokens); ReplaceAccessToken(originalRequest, newTokens.AccessToken); shouldRetry = true; } } } } } return(shouldRetry); }
public async Task <string> SearchRAsync(string name, int page) { HttpParams hp = new HttpParams() { Url = "http://musicapi.qianqian.com/v1/restserver/ting", Referer = "http://music.baidu.com/", Data = "method=baidu.ting.search.common&query=" + HttpUtility.UrlEncode(name) + "&format=json&page_size=10&page_no=" + page }; return(await HttpHelper.GetAsync(hp)); }
public BasicConnFactory(SSLSocketFactory sslfactory, HttpParams @params) : base() { Args.NotNull(@params, "HTTP params"); this.plainfactory = null; this.sslfactory = sslfactory; this.connectTimeout = @params.GetIntParameter(CoreConnectionPNames.ConnectionTimeout , 0); this.sconfig = HttpParamConfig.GetSocketConfig(@params); this.connFactory = new DefaultBHttpClientConnectionFactory(HttpParamConfig.GetConnectionConfig (@params)); }
//添加会员登录后的cookie,下载高品质音乐及付费音乐 //public Kugou() //{ // HttpHelper.cookie.Add(new Uri("kugou.com"),new Cookie("name", "path")); //} public async Task <string> GetSongByIdRAsync(string id) { HttpParams hp = new HttpParams() { Url = "http://m.kugou.com/app/i/getSongInfo.php", Referer = "http://m.kugou.com/play/info/" + id, Data = "cmd=playInfo&hash=" + id, }; return(await HttpHelper.GetAsync(hp)); }
public async Task <string> GetLrcRAsync(string id) { HttpParams hp = new HttpParams() { Url = "http://m.kugou.com/app/i/krc.php", Referer = "http://m.kugou.com/play/info/" + id, Data = "cmd=100&timelength=999999&hash=" + id, }; return(await HttpHelper.GetAsync(hp)); }
/// <summary>Creates an instance of AbstractMessageParser.</summary> /// <remarks>Creates an instance of AbstractMessageParser.</remarks> /// <param name="buffer">the session input buffer.</param> /// <param name="parser">the line parser.</param> /// <param name="params">HTTP parameters.</param> [System.ObsoleteAttribute(@"(4.3) use AbstractMessageParser{T}.AbstractMessageParser(Org.Apache.Http.IO.SessionInputBuffer, Org.Apache.Http.Message.LineParser, Org.Apache.Http.Config.MessageConstraints)")] public AbstractMessageParser(SessionInputBuffer buffer, LineParser parser, HttpParams @params) : base() { Args.NotNull(buffer, "Session input buffer"); Args.NotNull(@params, "HTTP parameters"); this.sessionBuffer = buffer; this.messageConstraints = HttpParamConfig.GetMessageConstraints(@params); this.lineParser = (parser != null) ? parser : BasicLineParser.Instance; this.headerLines = new AList <CharArrayBuffer>(); this.state = HeadLine; }
/// <summary> /// Выполнить GET-запрос /// </summary> public async static Task<String> HttpGet(String url, HttpParams httpParams = null) { var result = await HttpGetWithCode(url, httpParams); return result.Result; }
/// <summary> /// 异步:Post方法请求并返回消息 ,可配超时 /// </summary> /// <param name="url">包含查询字符串的Url地址</param> /// <param name="urlParameters">参数集合</param> /// <param name="timeout">超时,豪秒</param> /// <param name="callback">结束后的回调</param> /// <returns></returns> public static bool AsyncPost(string url, HttpParams urlParameters, int timeout, AsyncHttpCallback callback) { var sync = new AsyncHttp(timeout); return sync.HttpPost(url, urlParameters, callback); }
/// <summary> /// Post方法请求并返回消息 ,可配超时 /// </summary> /// <param name="url">包含查询字符串的Url地址</param> /// <param name="urlParameters">参数集合</param> /// <param name="timeout">超时,豪秒</param> /// <returns></returns> public static string Post(string url, HttpParams urlParameters, int timeout) { var sync = new SyncHttp(timeout); return sync.HttpPost(url, urlParameters); }