Sry.Framework.Web/HttpPostWriter.cs
(完整代码) 1KBusing System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Sry.Framework.Web
{
public class HttpPostWriter
{
private Dictionary<string, string> dict = new Dictionary<string, string>();
public void Clear() {
dict.Clear();
}
/// <summary>
/// 写入数据
/// </summary>
public void Add(string key, string value)
{
if (!dict.Keys.Contains(key))
dict.Add(key, value);
}
public string Post(string url) {
if (dict == null || dict.Count == 0)
throw new ArgumentNullException("数据字典不能为空,POST必须要有DATA参数");
StringBuilder sb = new StringBuilder();
foreach (KeyValuePair<string, string> pair in dict) {
sb.AppendFormat("&{0}={1}", pair.Key, pair.Value);
}
return HttpUtils.PostData(url, "utf-8", true, sb.ToString());
}
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。