我正在开发一个网页,需要接收一个HTTP Post请求,并将其读入字节数组进行进一步处理.我有点纠结于如何做到这一点,我被什么是最好的实现方式难住了.以下是我目前的代码:
public override void ProcessRequest(HttpContext curContext)
{
if (curContext != null)
{
int totalBytes = curContext.Request.TotalBytes;
string encoding = curContext.Request.ContentEncoding.ToString();
int reqLength = curContext.Request.ContentLength;
long inputLength = curContext.Request.InputStream.Length;
Stream str = curContext.Request.InputStream;
}
}
我正在判断请求的长度及其总字节数,它等于128.现在,我是否只需要使用Stream对象将其转换为byte[]格式?我走的方向对吗?不确定如何继续.任何建议都是很棒的.我需要将整个HTTP请求放入byte[]字段.
谢谢!