Sry.Framework.Web/HttpPostReader.cs
(开头部分) 3KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;
using System.Web;
namespace Sry.Framework.Web
{
public class HttpPostReader
{
private string data;
private Dictionary<string,string> dict;
public string Data
{
get
{
if (data == null)
{
var context = HttpContext.Current;
if (context == null) throw new ArgumentNullException("httpcontext is null.");
if (context.Request.RequestType.ToUpper() == "GET")
{
throw new ArgumentOutOfRangeException("request type error, please use post type!");
}
Stream stream = null;
StreamReader reader = null;
StringBuilder result = new StringBuilder();
try
{
// 以字符流的方式读取HTTP响应
stream = context.Request.InputStream;
reader = new StreamReader(stream, Encoding.UTF8);
// 每次读取不大于256个字符,并写入字符串
char[] buffer = new char[256];
int readBytes = 0;
while ((readBytes = reader.Read(buffer, 0, buffer.Length)) > 0)
{
result.Append(buffer, 0, readBytes);
}
data = result.ToString();
return data;
}
catch (WebException ex)
{
throw ex;
}
finally
{
// 释放资源
if (reader != null) reader.Close();
后面还有 43 行代码,购买后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。