public static void Main() { var client = new Xttp(); var request = new Request("http://api.lsong.org/ip/all"); Response response = client.Send(request).Result; Console.WriteLine(response.ToString()); Console.ReadLine(); }
/// <summary> /// Async Send HTTP Request /// </summary> /// <param name="request">request</param> /// <returns>response</returns> public async Task<Response> Send(Request request) { HttpResponseMessage response = new HttpResponseMessage(); switch (request.Method) { case Request.METHOD.GET: response = await client.GetAsync(request.Url.ToString()); break; case Request.METHOD.POST: var body = new FormUrlEncodedContent(request.Body); response = await client.PostAsync(request.Url.ToString(), body); break; } return new Response(response); }