HTTP 請求 工具類

2021-08-06 06:00:58 字數 3272 閱讀 6848

using system;

using system.collections;

using system.collections.generic;

using system.io;

using system.net;

using system.text;

using system.web;

namespace inte***cecommon.common

// set

//}/// /// 執行http post請求。

///

/// 請求位址

/// 請求引數

/// http響應

public static string dopost(string url, idictionaryparameters)

/// /// 執行http get請求。

///

/// 請求位址

/// 請求引數

/// http響應

}/// /// 執行帶檔案上傳的http post請求。

///

/// 請求位址

/// 請求文字引數

/// 請求檔案引數

/// http響應

public static string dopost(string url, idictionarytextparams, idictionaryfileparams)

string boundary = datetime.now.ticks.tostring("x"); // 隨機分隔線

// 組裝文字請求引數

string texttemplate = "content-disposition:form-data;name=\"\"\r\ncontent-type:text/plain\r\n\r\n";

ienumerator> textenum = textparams.getenumerator();

while (textenum.movenext())

// 組裝檔案請求引數

/// /// 把響應流轉換為文字。

///

/// 響應流物件

/// 編碼方式

/// 響應文字

}/// /// 組裝get請求url。

///

/// 請求位址

/// 請求引數

/// 帶引數的get請求url

public static string buildgeturl(string url, idictionaryparameters)

else

}return url;

}/// /// 組裝普通文字請求引數。

///

/// key-value形式請求引數字典

/// url編碼後的請求資料

public static string buildquery(idictionaryparameters)

hasparam = true;}}

return postdata.tostring();}}

}

http請求工具類

簡單的http請求,短連線,請求完成之後就結束了,post請求 用於key value格式的引數 post請求 用於請求json格式的引數 param url param params return public static string dopost string url,string para...

Http網路請求工具類

獲取網路 字串 param address 後台提供的介面 return string public static string getstringfromnet final string address try catch exception e return response.tostring ...

http請求的工具類

即將改造的 import requests 登陸url message header res requests.post url,data message,headers header print res.status code print res.cookies 檢視日記 url chakan h...