我正在开发一个需要接受 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[] 字段。
谢谢!