32°

聊聊HTTP请求那一些事_HttpWebRequest_一篇就够了

​最近工作比较忙,很久没有写东西了,今天抽点时间整体一下最近工作的一个知识点小结。http请求对我们来说一点都不模式,程序员的我们有可能天天就是和这一些打交道。无论是BS架构的程序,前后端的数据交互,已经后台服务之间的数据交互,http还是主流。

 

最近接触的一个新项目,其项目是一个祖传项目,经历很多波小伙伴的手,代码风格也各不相同,重复性的代码一大波一大波的堆砌。在接手熟悉整理过程的,开始对一些公用方法进行封装打包,现在我就分享其中一个间的模块,那么就是对接口间的http请求处理封装。

 

当然了,其实http请求对绝大部分小伙伴来说都是家常便饭的熟悉,但是我今天还是要写出来,其目的是为了做一次知识总结和分享,也为了一个项目的统一,避免重复的造不同的轮子。在文中如有有说的不好的,或者错误的地方,希望你能够指点指点,谢谢!

 

言归正传,回到主题上来哈。至于http请的详细介绍,我就不在此啰嗦了,也免得占用大家时间。在实际使用过中,get和post是两种最常见不过的方式,下面也主要围绕这两个方式介绍。本文中主要是针对HttpWebRequest的封装进行分享。

 

一、聊聊Content-Type几种常见类

 

在聊http请求操作,首先需要了解的就是content-type(内容类型)关键,简单的说就是文档数据交互方法,其常见的主要有如下3种。

A:application/x-www-form-urlencoded

最常见的提交数据的方式,也是默认数据提交方式,其数据传递最终会转换为键值对的方式传递,key1=val1&key2=val2

 

B:multipart/form-data

表单方式提交,也是比较常见的提交方式。

 

C、application/json

该方式越来越流行,已json方式交互,很多开发接口数据交互都是json方式。

 

二、聊聊PAI的常见参数接收方式

其实我们在说http请求,API是离不开的话题,这也是本次分享的主要原因。尤其是现在都在提倡微服务,服务间的自调用就在所难免。那么下面我将简单总结一下常见的PAI数据接收方式:

 

按照有无参数分类,分了两大类,有参接口、无参接口。

其中,无参接口最为简单,没有什么好说的。下面主要说一下有参接口数据接收方式。

 

FromQuery:这一种比较简单的实现方式,也就是我们常见的url地址上的键值对方式传递接受,比如:url?key1=value1&key2=value2。该方式适用于get和post两种方式

 

FromRoute:路由参数,简单的说就是参数就是url地址的一部分。根据路由规则解析对应的参数。比如:urls/value1/value2。该方式适用于get和post两种方式

 

FromForm:表单方式传递,通过from表单方式接受参数,直接提交一个from表单。该方式使用与post。

 

FromBody:以json方式提交数据,接受时以一个对应的实体模型接收。该方式使用post

嗯,上面几种方式是我们常见的方式,了解了这一些方式,能解决掉90%的http请求。其他的方式就不在此详聊。

 

三、Content-Type与PAI常见参数接收方式对应关系

 

Content-Type

参数接收方式

使用类型

application/x-www-form-urlencoded

FromQuery

FromRoute

get、post

multipart/form-data

FromForm

post

application/json

FromBody

post

四、http请求返回接收方式

 

其实严格的意义来说法不正确,其实接收方式都是一个字符串方式。我说的方式,是指在接收到请求结果后,其自己对数据的处理方式,也就两种方式,其一,请求结果字符串;其二、请求结果转换为对应的实体模型。

 

五、HttpWebRequest封装

 

结合上面的几点分析,下面主要针对这几种情况进行封装说明。

针对FromQuery参数:在封装中,通过字典方式交互

针对FromRoute参数:在封装中,通过list字符串集合交互

针对FromForm参数:在封装中,通过字典方式交互

针对FromBody参数:在分装中,通过数据模型方式交互

在每一种交互方式上,根据编码方式、过期时间、返回类型,又重载了几个方法

下面直接上代码:

get方式封装部分代码:

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;

namespace XYH.Tools.HttpTool { /// <summary> /// http get 请求相关的操作帮助类 /// </summary> public partial class HttpTool : HttpToolBase { #region 无参

    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,不单独带有参数(返回一个泛型实体)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">请求地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpGet&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, List&lt;MHeadParamet&gt; headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForGet&lt;TReturn&gt;<span style="color: #000000;">(url, defaultEncodType, defaultTimeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,不单独带有参数(返回一个字符串)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">请求地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpGet(<span style="color: #0000ff;">string</span> url, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForGet(url, defaultEncodType, defaultTimeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,不单独带有参数 (返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">请求地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpGet&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, Encoding encodType, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForGet&lt;TReturn&gt;<span style="color: #000000;">(url, encodType, defaultTimeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,不单独带有参数(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">请求地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpGet(<span style="color: #0000ff;">string</span> url, Encoding encodType, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForGet(url, encodType, defaultTimeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,不单独带有参数 (返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">请求地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpGet&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForGet&lt;TReturn&gt;<span style="color: #000000;">(url, defaultEncodType, timeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,不单独带有参数(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">请求地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpGet(<span style="color: #0000ff;">string</span> url, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForGet(url, defaultEncodType, timeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,不单独带有参数 (返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">请求地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpGet&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForGet&lt;TReturn&gt;<span style="color: #000000;">(url, encodType, timeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,不单独带有参数(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">请求地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpGet(<span style="color: #0000ff;">string</span> url, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForGet(url, encodType, timeout, headerKeyValue);
    }

    </span><span style="color: #0000ff;">#endregion</span>

    <span style="color: #0000ff;">#region</span> 参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)

    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个字符串)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">请求参数字典</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpGetDic(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForGet(url, defaultEncodType, defaultTimeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典(键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">请求参数字典</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpGetDic&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForGet&lt;TReturn&gt;<span style="color: #000000;">(url, defaultEncodType, defaultTimeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">请求参数字典</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpGetDic(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForGet(url, encodType, defaultTimeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">请求参数字典</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpGetDic&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForGet&lt;TReturn&gt;<span style="color: #000000;">(url, encodType, defaultTimeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">参数集合</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpGetDic(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForGet(url, defaultEncodType, timeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">参数集合</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpGetDic&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForGet&lt;TReturn&gt;<span style="color: #000000;">(url, defaultEncodType, timeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">参数集合</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpGetDic(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForGet(url, encodType, timeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">参数集合</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpGetDic&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForGet&lt;TReturn&gt;<span style="color: #000000;">(url, encodType, timeout, headerKeyValue);
    }

    </span><span style="color: #0000ff;">#endregion</span>

    <span style="color: #0000ff;">#region</span> rout路由参数

    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpGetRout&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForGet&lt;TReturn&gt;<span style="color: #000000;">(url, defaultEncodType, defaultTimeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个字符串)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpGetRout(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForGet(url, defaultEncodType, defaultTimeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpGetRout&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForGet&lt;TReturn&gt;<span style="color: #000000;">(url, encodType, defaultTimeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpGetRout(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForGet(url, encodType, defaultTimeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpGetRout&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForGet&lt;TReturn&gt;<span style="color: #000000;">(url, defaultEncodType, timeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpGetRout(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForGet(url, defaultEncodType, timeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpGetRout&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForGet&lt;TReturn&gt;<span style="color: #000000;">(url, encodType, timeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpGetRout(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForGet(url, encodType, timeout, headerKeyValue);
    }

    </span><span style="color: #0000ff;">#endregion</span>

    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 获取请求结果(返回一个泛型实体)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">url</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果返回值</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> TReturn GetResponseResultForGet&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #0000ff;">return</span> GetResponseResult&lt;TReturn&gt;(url, <span style="color: #0000ff;">string</span>.Empty, <span style="color: #800000;">"</span><span style="color: #800000;">get</span><span style="color: #800000;">"</span>, <span style="color: #0000ff;">string</span><span style="color: #000000;">.Empty, encodType, timeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 获取请求结果(返回一个泛型实体)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">url</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果返回值</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> GetResponseResultForGet(<span style="color: #0000ff;">string</span> url, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #0000ff;">return</span> GetResponseResult(url, <span style="color: #0000ff;">string</span>.Empty, <span style="color: #800000;">"</span><span style="color: #800000;">get</span><span style="color: #800000;">"</span>, <span style="color: #0000ff;">string</span><span style="color: #000000;">.Empty, encodType, timeout, headerKeyValue);
    }
}

}

 

post方式封装部分代码:

using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Net;
using System.Text;

namespace XYH.Tools.HttpTool { /// <summary> /// http请求相关的操作帮助类 /// </summary> public partial class HttpTool : HttpToolBase { #region 无参

    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> POST请求,无参 (返回一个泛型实体)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="requestData"&gt;</span><span style="color: #008000;">请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPost&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;">获得接口返回值</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn&gt;<span style="color: #000000;">(url, defaultEncodType, defaultTimeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> POST请求,无参 (返回一个字符串)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="requestData"&gt;</span><span style="color: #008000;">请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPost(<span style="color: #0000ff;">string</span> url, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;">获得接口返回值</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForPost(url, defaultEncodType, defaultTimeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> POST请求,无参 (返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式,默认为utf-8</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPost&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, Encoding encodType, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;">获得接口返回值</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn&gt;<span style="color: #000000;">(url, encodType, defaultTimeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> POST请求,无参 (返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式,默认为utf-8</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPost(<span style="color: #0000ff;">string</span> url, Encoding encodType, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;">获得接口返回值</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForPost(url, encodType, defaultTimeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> POST请求,无参 (返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPost&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;">获得接口返回值</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn&gt;<span style="color: #000000;">(url, defaultEncodType, timeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> POST请求,无参 (返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPost(<span style="color: #0000ff;">string</span> url, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;">获得接口返回值</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForPost(url, defaultEncodType, timeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> POST请求,无参 (返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式,默认为utf-8</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPost&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;">获得接口返回值</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn&gt;<span style="color: #000000;">(url, encodType, timeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> POST请求,无参 (返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式,默认为utf-8</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPost(<span style="color: #0000ff;">string</span> url, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;">获得接口返回值</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForPost(url, encodType, timeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #0000ff;">#endregion</span>

    <span style="color: #0000ff;">#region</span> 参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)

    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个字符串)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">请求参数字典</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="isAcceptForm"&gt;</span><span style="color: #008000;">参数是否来自Form, true:代表来自Form false:来自url 默认为false</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPostDic(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, <span style="color: #0000ff;">bool</span> isAcceptForm = <span style="color: #0000ff;">false</span>, List&lt;MHeadParamet&gt; headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #0000ff;">if</span> (!<span style="color: #000000;">isAcceptForm)
        {
            </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
            url =<span style="color: #000000;"> GetRequestPath(url, parameters);

            </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
            <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForPost(url, defaultEncodType, defaultTimeout, headerKeyValue: headerKeyValue);
        }
        </span><span style="color: #0000ff;">else</span><span style="color: #000000;">
        {
            </span><span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt;&gt;<span style="color: #000000;">(url, defaultEncodType, defaultTimeout, parameters, headerKeyValue: headerKeyValue);
        }
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典(键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">请求参数字典</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPostDic&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, <span style="color: #0000ff;">bool</span> isAcceptForm = <span style="color: #0000ff;">false</span>, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #0000ff;">if</span> (!<span style="color: #000000;">isAcceptForm)
        {
            </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数 multipart/form-data</span>
            url =<span style="color: #000000;"> GetRequestPath(url, parameters);

            </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
            <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn&gt;<span style="color: #000000;">(url, defaultEncodType, defaultTimeout, headerKeyValue: headerKeyValue);
        }
        </span><span style="color: #0000ff;">else</span><span style="color: #000000;">
        {
            </span><span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn&gt;(url, defaultEncodType, defaultTimeout, GetRequestData(parameters), <span style="color: #800000;">"</span><span style="color: #800000;">application/x-www-form-urlencoded;charset=utf-8</span><span style="color: #800000;">"</span><span style="color: #000000;">, headerKeyValue: headerKeyValue);
        }
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">请求参数字典</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPostDic(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForPost(url, encodType, defaultTimeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">请求参数字典</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPostDic&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn&gt;<span style="color: #000000;">(url, encodType, defaultTimeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">参数集合</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPostDic(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForPost(url, defaultEncodType, timeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">参数集合</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPostDic&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn&gt;<span style="color: #000000;">(url, defaultEncodType, timeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">参数集合</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPostDic(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForPost(url, encodType, timeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有请求参数字典 (键值对参数 path?kay1=value1&amp;kay12=value2...)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">参数集合</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPostDic&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, Dictionary&lt;<span style="color: #0000ff;">string</span>, <span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn&gt;<span style="color: #000000;">(url, encodType, timeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #0000ff;">#endregion</span>

    <span style="color: #0000ff;">#region</span> rout路由参数

    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPostRout&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn&gt;<span style="color: #000000;">(url, defaultEncodType, defaultTimeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个字符串)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPostRout(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForPost(url, defaultEncodType, defaultTimeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPostRout&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn&gt;<span style="color: #000000;">(url, encodType, defaultTimeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPostRout(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForPost(url, encodType, defaultTimeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPostRout&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn&gt;<span style="color: #000000;">(url, defaultEncodType, timeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPostRout(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForPost(url, defaultEncodType, timeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPostRout&lt;TReturn&gt;(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn&gt;<span style="color: #000000;">(url, encodType, timeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,并带有list集合请求参数(rout路由参数)(返回一个字符串)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="parameters"&gt;</span><span style="color: #008000;">list集合请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPostRout(<span style="color: #0000ff;">string</span> url, List&lt;<span style="color: #0000ff;">string</span>&gt; parameters, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 构建请求参数</span>
        url =<span style="color: #000000;"> GetRequestPath(url, parameters);

        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span><span style="color: #000000;"> GetResponseResultForPost(url, encodType, timeout, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #0000ff;">#endregion</span>

    <span style="color: #0000ff;">#region</span> json参数

    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,参数为实体对象 (返回一个泛型实体)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="inputParamet"&gt;</span><span style="color: #008000;">请求参数模型</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPostModel&lt;TReturn, TInput&gt;(<span style="color: #0000ff;">string</span> url, TInput inputParamet, <span style="color: #0000ff;">bool</span> isAcceptForm = <span style="color: #0000ff;">false</span>, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn, TInput&gt;<span style="color: #000000;">(url, defaultEncodType, defaultTimeout, inputParamet, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,参数为实体对象 (返回一个字符串)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="inputParamet"&gt;</span><span style="color: #008000;">请求参数模型</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPostModel&lt;TInput&gt;(<span style="color: #0000ff;">string</span> url, TInput inputParamet, List&lt;MHeadParamet&gt; headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TInput&gt;<span style="color: #000000;">(url, defaultEncodType, defaultTimeout, inputParamet, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,参数为实体对象(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="inputParamet"&gt;</span><span style="color: #008000;">请求参数模型</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPostModel&lt;TReturn, TInput&gt;(<span style="color: #0000ff;">string</span> url, TInput inputParamet, Encoding encodType, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn, TInput&gt;<span style="color: #000000;">(url, encodType, defaultTimeout, inputParamet, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,参数为实体对象(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="inputParamet"&gt;</span><span style="color: #008000;">请求参数模型</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> TReturn HttpPostModel&lt;TReturn, TInput&gt;(<span style="color: #0000ff;">string</span> url, TInput inputParamet, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TReturn, TInput&gt;<span style="color: #000000;">(url, encodType, timeout, inputParamet, headerKeyValue: headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> http请求,参数为实体对象(返回一个泛型实体)
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义编码方式
    </span><span style="color: #808080;">///</span><span style="color: #008000;"> 自定义超时时间 单位毫秒 默认为1分钟
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">地址</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="inputParamet"&gt;</span><span style="color: #008000;">请求参数模型</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求处理结果</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">public</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> HttpPostModel&lt;TInput&gt;(<span style="color: #0000ff;">string</span> url, TInput inputParamet, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #008000;">//</span><span style="color: #008000;"> 发起请求</span>
        <span style="color: #0000ff;">return</span> GetResponseResultForPost&lt;TInput&gt;<span style="color: #000000;">(url, encodType, timeout, inputParamet, headerKeyValue);
    }

    </span><span style="color: #0000ff;">#endregion</span>

    <span style="color: #0000ff;">#region</span> 帮助方法

    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 获取请求结果(返回一个泛型实体)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">url</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="requestData"&gt;</span><span style="color: #008000;">请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="contentType"&gt;</span><span style="color: #008000;">请求参数传递方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果返回值</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> T GetResponseResultForPost&lt;T&gt;(<span style="color: #0000ff;">string</span> url, Encoding encodType, <span style="color: #0000ff;">int</span> timeout, <span style="color: #0000ff;">string</span> requestData = <span style="color: #800000;">""</span><span style="color: #000000;">,
        </span><span style="color: #0000ff;">string</span> contentType = <span style="color: #800000;">""</span>, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #0000ff;">return</span> GetResponseResult&lt;T&gt;(url, requestData, <span style="color: #800000;">"</span><span style="color: #800000;">post</span><span style="color: #800000;">"</span><span style="color: #000000;">, contentType, encodType, timeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 获取请求结果(返回一个字符串)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">url</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="requestData"&gt;</span><span style="color: #008000;">请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="contentType"&gt;</span><span style="color: #008000;">请求参数传递方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果返回值</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> GetResponseResultForPost(<span style="color: #0000ff;">string</span> url, Encoding encodType, <span style="color: #0000ff;">int</span><span style="color: #000000;"> timeout,
        </span><span style="color: #0000ff;">string</span> requestData = <span style="color: #800000;">""</span>, <span style="color: #0000ff;">string</span> contentType = <span style="color: #800000;">""</span>, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #0000ff;">return</span> GetResponseResult(url, requestData, <span style="color: #800000;">"</span><span style="color: #800000;">post</span><span style="color: #800000;">"</span><span style="color: #000000;">, contentType, encodType, timeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 获取请求结果(返回一个泛型实体)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">url</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="requestData"&gt;</span><span style="color: #008000;">请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="contentType"&gt;</span><span style="color: #008000;">请求参数传递方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果返回值</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> TReturn GetResponseResultForPost&lt;TReturn, TInput&gt;(<span style="color: #0000ff;">string</span> url, Encoding encodType, <span style="color: #0000ff;">int</span><span style="color: #000000;"> timeout, TInput inputParamet,
        </span><span style="color: #0000ff;">bool</span> isAcceptForm = <span style="color: #0000ff;">false</span>, List&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #0000ff;">return</span> GetResponseResult&lt;TReturn&gt;(url, JsonConvert.SerializeObject(inputParamet), <span style="color: #800000;">"</span><span style="color: #800000;">post</span><span style="color: #800000;">"</span>, isAcceptForm ? <span style="color: #800000;">"</span><span style="color: #800000;">application/x-www-form-urlencoded;charset=utf-8</span><span style="color: #800000;">"</span> : <span style="color: #800000;">"</span><span style="color: #800000;">application/json</span><span style="color: #800000;">"</span><span style="color: #000000;">, encodType, timeout, headerKeyValue);
    }

    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;summary&gt;</span>
    <span style="color: #808080;">///</span><span style="color: #008000;"> 获取请求结果(返回一个字符串)
    </span><span style="color: #808080;">///</span> <span style="color: #808080;">&lt;/summary&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="url"&gt;</span><span style="color: #008000;">url</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="encodType"&gt;</span><span style="color: #008000;">编码方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="timeout"&gt;</span><span style="color: #008000;">超时时间</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="requestData"&gt;</span><span style="color: #008000;">请求参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="contentType"&gt;</span><span style="color: #008000;">请求参数传递方式</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;param name="headerKeyValue"&gt;</span><span style="color: #008000;">头部键值对参数</span><span style="color: #808080;">&lt;/param&gt;</span>
    <span style="color: #808080;">///</span> <span style="color: #808080;">&lt;returns&gt;</span><span style="color: #008000;">请求结果返回值</span><span style="color: #808080;">&lt;/returns&gt;</span>
    <span style="color: #0000ff;">private</span> <span style="color: #0000ff;">static</span> <span style="color: #0000ff;">string</span> GetResponseResultForPost&lt;TInput&gt;(<span style="color: #0000ff;">string</span> url, Encoding encodType, <span style="color: #0000ff;">int</span><span style="color: #000000;"> timeout, TInput requestData,
        List</span>&lt;MHeadParamet&gt;  headerKeyValue = <span style="color: #0000ff;">null</span><span style="color: #000000;">)
    {
        </span><span style="color: #0000ff;">return</span> GetResponseResult(url, JsonConvert.SerializeObject(requestData), <span style="color: #800000;">"</span><span style="color: #800000;">post</span><span style="color: #800000;">"</span>, <span style="color: #800000;">"</span><span style="color: #800000;">application/json</span><span style="color: #800000;">"</span><span style="color: #000000;">, encodType, timeout, headerKeyValue);
    }

    </span><span style="color: #0000ff;">#endregion</span><span style="color: #000000;">
}

}

 

总结:

我已经将源码上传到GitHub上,里面级包括封装组件源码、测试接口、测试调用

源码地址:https://github.com/xuyuanhong0902/XYH.Tools.HttpTool

 

同时,我也将生产包上传至NuGet上,有需要的可以直接使用:XYH.Tools.HttpTool

 

今天就写到这了,明天还得早起上班码砖呢。。。哈哈哈,快过年了,祝你新年快乐。谢谢阅读!

 

END
为了更高的交流,欢迎大家关注我的公众号,扫描下面二维码即可关注,谢谢:

本文转载自博客园,原文链接:https://www.cnblogs.com/xiaoXuZhi/p/XYH_Tools_HttpTool.html

全部评论: 0

    我有话说: