zoukankan      html  css  js  c++  java
  • 使用HttpClient发送GET请求

    HttpRequestMessage http_req_msg = new HttpRequestMessage();
    http_req_msg.Method = HttpMethod.Get;
    http_req_msg.Headers.Add("user-agent", "Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0)");
    http_req_msg.RequestUri = new Uri("http://webservices.amazon.com/AWSECommerceService/AWSECommerceService.wsdl");                       
    
    HttpClient httpclient;            
    HttpClientHandler httphandler;            
    
    httphandler = new HttpClientHandler();
    httphandler.AllowAutoRedirect = false;
    httphandler.UseCookies = false;
    
    httpclient = new HttpClient(httphandler);
    var task = httpclient.SendAsync(http_req_msg);
    task.Result.EnsureSuccessStatusCode();
    
    HttpResponseMessage response = task.Result;
    
    var result = response.Content.ReadAsStringAsync();
    string responseBodyAsText = result.Result;
    responseBodyAsText = responseBodyAsText.Replace("<br>", Environment.NewLine); // Insert new lines
    
    MessageBox.Show(responseBodyAsText);
  • 相关阅读:
    CodeForces
    4.15随笔
    oracle新建用户并赋予权限等
    catch时,获取异常信息
    ORACLE 判断是否为数字类型
    UNION ALL用法
    2019.11.7随笔
    oracle 查询锁表和解锁
    2019.11.1随笔
    oracle拼接子查询返回的多个结果
  • 原文地址:https://www.cnblogs.com/lijiu/p/3834296.html
Copyright © 2011-2022 走看看