Sorry for the delay.
"其实无论循环还是一次
性读取数据,在我没有把这些数据处理、存盘前,那么它们都是存放在内存里了。"
其实不是这样,数据还没从客户机传过来,ReadClient时才进行读取。
摘自MSDN:
(mk
MSITStore:C:/Program%20Files/Microsoft%20Visual%20Studio/MSDN98/98VS/2052/IISRef.chm::/devdoc/good/iishelp/iis/htm/sdk/appref_235g.htm)
The ReadClient function reads information from the body of the
Web client's HTTP request into the buffer supplied by the caller.
Thus, the call can be used to read data from an HTML form that
uses the POST method. If more than lpdwSize bytes are immediately
available to be read, ReadClient will block until some amount of
data has been returned, and will return with less than the requested
amount of data. In order to ensure that all data has been read,
your program should call ReadClient in a loop which continues to run
until the amount of data specified in lpdwSize has been read.
If the socket on which the server is listening to the client is closed,
ReadClient will return TRUE, but with zero bytes read.
从实际来说,"一次读取全部数据"和"使用循环去读取数据,其实是用小缓冲区处理大量数据",
也就是"能用"和"工作良好"的区别。
一次读取全部数据是能用,但消耗服务器资源过多,不太切合实际,但编写容易。
使用循环去读取数据,其实是用小缓冲区处理大量数据,编写困难,但是在实际应用中是
必须的,属于工作良好。
"再,我发觉几朋友提供的代码都是一次读取数据是不超过48K的,
也就是上传数据超过48K的的时候就要循环读取了。这个48K是ISAPI本身规定的吗?"
看看以下:
摘自MSDN:
(mk
MSITStore:C:/Program%20Files/Microsoft%20Visual%20Studio/MSDN98/98VS/2052/IISRef.chm::/devdoc/good/iishelp/iis/htm/sdk/filtoview_9svb.htm)
If the client is sending POST data with the request,
and all of the data was not read in the first step,
one or more SF_NOTIFY_READ_RAW_DATA notifications will occur here.
Data will be read until either 48K of data is received from the client,
or until all of the data is read, whichever occurs first.
The 48K read size is typical, but it may be varied. For example,
if the MD_UPLOAD_READAHEAD_SIZE in the metabase has been set to a value
other than 48k, IIS will attempt to read that amount of data.
Other factors can impact how much the server reads so filters
should not rely on this exact behavior.
......
If the handler calls ReadClient to continue reading POST data beyond 48K,
one or more additional SF_NOTIFY_READ_RAW_DATA notifications will occur.
其实说这么多,就是避免兼容性问题。
好像大于48KB,在IIS V4.0下就不时出现死锁。