本人忘记了是哪个开源组件了,只知道有以下代码的有类名为Multipartparser的,希望大家知道的话提供源码: IServiceProvider provider = (IServiceProvider) HttpContext.Current;
HttpWorkerRequest wr = (HttpWorkerRequest) provider.GetService(typeof(HttpWorkerRequest));
byte[] bs = wr.GetPreloadedEntityBody();
….
if (!wr.IsEntireEntityBodyIsPreloaded())
{
int n = 1024;
byte[] bs2 = new byte[n];
while (wr.ReadEntityBody(bs2,n) >0)
{
…..
}
}
Multipartparser.cs //修改构造函数,增加contentEncoding参数
public MultipartParser(Stream s, string boundary, int contentLength, System.Text.Encoding contentEncoding)//添加新函数,解决Header中的编码问题
protected string ReadHeaderLine(Stream s)
{
// TODO: chunk
const byte cr = (byte)’\r’;
const byte cn = (byte)’\n’;
byte[] tempValues = new byte[2048];
int ii=0;
byte current = (byte)s.ReadByte();
while (current != cr && current != cn)
{
ii++;
tempValues[ii-1]=current;
current = (byte)s.ReadByte();
}if (current == cr)
s.ReadByte();
byte[] newValues = new byte[ii];
Array.Copy(tempValues,newValues,(long)(ii));
return _contentEncoding.GetString(newValues);
} //将调用ReadLine的地方修改成ReadHeaderLine
protected NameValueCollection ReadHeaders()
{
NameValueCollection headers = new NameValueCollection();//string line = ReadLine(_s);
string line = ReadHeaderLine(_s);// TODO: Handle continuations – lines starting with whitespace
while (line.Length > 0)
{
int pos = line.IndexOf(‘:’);headers[line.Substring(0, pos)] = line.Substring(pos + 1);//line = ReadLine(_s);
line = ReadHeaderLine(_s);
}return headers;
}
HttpWorkerRequest wr = (HttpWorkerRequest) provider.GetService(typeof(HttpWorkerRequest));
byte[] bs = wr.GetPreloadedEntityBody();
….
if (!wr.IsEntireEntityBodyIsPreloaded())
{
int n = 1024;
byte[] bs2 = new byte[n];
while (wr.ReadEntityBody(bs2,n) >0)
{
…..
}
}
Multipartparser.cs //修改构造函数,增加contentEncoding参数
public MultipartParser(Stream s, string boundary, int contentLength, System.Text.Encoding contentEncoding)//添加新函数,解决Header中的编码问题
protected string ReadHeaderLine(Stream s)
{
// TODO: chunk
const byte cr = (byte)’\r’;
const byte cn = (byte)’\n’;
byte[] tempValues = new byte[2048];
int ii=0;
byte current = (byte)s.ReadByte();
while (current != cr && current != cn)
{
ii++;
tempValues[ii-1]=current;
current = (byte)s.ReadByte();
}if (current == cr)
s.ReadByte();
byte[] newValues = new byte[ii];
Array.Copy(tempValues,newValues,(long)(ii));
return _contentEncoding.GetString(newValues);
} //将调用ReadLine的地方修改成ReadHeaderLine
protected NameValueCollection ReadHeaders()
{
NameValueCollection headers = new NameValueCollection();//string line = ReadLine(_s);
string line = ReadHeaderLine(_s);// TODO: Handle continuations – lines starting with whitespace
while (line.Length > 0)
{
int pos = line.IndexOf(‘:’);headers[line.Substring(0, pos)] = line.Substring(pos + 1);//line = ReadLine(_s);
line = ReadHeaderLine(_s);
}return headers;
}
解决方案 »
- 请问,这种算法,怎么写?
- 【在线等】provider: SSL Provider, error: 0 - 内存不足,无法完成请求
- c#插入数据库的问题(中文)
- 初次安装vs2010遇到的问题
- 在.net2005中使用Remoting编程
- 水晶报表的问题
- Dataset.xsd中字段的Caption才能和datagrid列显示内容结合起来?
- 除了大家喜爱的csdn,还有什么比较好的讨论.net技术的论坛呢?
- !新手求助,C#中openFileDialog控件使用问题
- 请问怎样实现自定义类的位置属性
- 请问通过Windows Service如何去运行一个CMD命令文件?
- C# pdf控件AxAcroPDFLib 资料收集,凡提供有用的资料,均加分
SlickUpload来上传大文件(1)
SlickUpload来上传大文件(2)
本人目的是要搞清楚源码,SilckUpload好像不是,没有Multipartparser类