下面是我是在VC6下获取收到的回应包,如何确定这个头的长度??
如果是Content-Length形式的可以直接获取后面的值,Transfer-Encoding的一个如何呢?
望高人指点一二。
谢谢了 HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.4; JBoss-4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)/Tomcat-5.5
Transfer-Encoding: chunked
Date: Wed, 19 Aug 2009 01:25:19 GMT33
return=0;money=10.0;YDcount=0;LTcount=0;XLTcount=0;
如果是Content-Length形式的可以直接获取后面的值,Transfer-Encoding的一个如何呢?
望高人指点一二。
谢谢了 HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
X-Powered-By: Servlet 2.4; JBoss-4.2.2.GA (build: SVNTag=JBoss_4_2_2_GA date=200710221139)/Tomcat-5.5
Transfer-Encoding: chunked
Date: Wed, 19 Aug 2009 01:25:19 GMT33
return=0;money=10.0;YDcount=0;LTcount=0;XLTcount=0;
解决方案 »
- 才发现这几个函数,isdigit,isalpha,isxdigit,isalnum!
- 求教Matlab语音识别的程序修改问题
- 求助:VC2005的配置问题
- 一个调用对象的问题
- ¥¥¥¥¥我动态创建的view为什么得不到焦点??
- CFileDialog中的Save As如何自动添加文件类型的扩张名?
- 在vc中怎样利用控件的失去焦点的信息?????
- 现在学习VC++6.0还有前途吗???
- 怎样求一幅图像进行傅立叶变换后和原图像的比值
- alphagx 老兄,大恩不言谢,既然这样你好人作到底,再帮我一次吧!我想用图片代替滚动条,帮帮我吧!
- VC IE 编程 选择 自动编码 代码怎么写
- 有关多个PICTURE控件的问题
如果是接收网页的话,还可以判断收到</html>时为结束.
那就只能根据"\r\n\r\n"来获取呢??
那如何判断我数据的总长度已经接受完了呢?\r\n\r\n 后面还有数据
response header中才会有Content-Length。可以根据后面的值判断文件的大小
我觉得应该参照2楼的朋友处理方法,HTTP有时候是使用chunked传输方式的.
楼主可以GOOGLE下关于chunked的接收方法.
3.6.1 Chunked Transfer Coding The chunked encoding modifies the body of a message in order to
transfer it as a series of chunks, each with its own size indicator,
followed by an OPTIONAL trailer containing entity-header fields. This
allows dynamically produced content to be transferred along with the
information necessary for the recipient to verify that it has
received the full message. Chunked-Body = *chunk
last-chunk
trailer
CRLF chunk = chunk-size [ chunk-extension ] CRLF
chunk-data CRLF
chunk-size = 1*HEX
last-chunk = 1*("0") [ chunk-extension ] CRLF chunk-extension= *( ";" chunk-ext-name [ "=" chunk-ext-val ] )
chunk-ext-name = token
chunk-ext-val = token | quoted-string
chunk-data = chunk-size(OCTET)
trailer = *(entity-header CRLF) The chunk-size field is a string of hex digits indicating the size of
the chunk. The chunked encoding is ended by any chunk whose size is
zero, followed by the trailer, which is terminated by an empty line. The trailer allows the sender to include additional HTTP header
fields at the end of the message. The Trailer header field can be
used to indicate which header fields are included in a trailer (see
section 14.40).
A server using chunked transfer-coding in a response MUST NOT use the
trailer for any header fields unless at least one of the following is
true: a)the request included a TE header field that indicates "trailers" is
acceptable in the transfer-coding of the response, as described in
section 14.39; or, b)the server is the origin server for the response, the trailer
fields consist entirely of optional metadata, and the recipient
could use the message (in a manner acceptable to the origin server)
without receiving this metadata. In other words, the origin server
is willing to accept the possibility that the trailer fields might
be silently discarded along the path to the client. This requirement prevents an interoperability failure when the
message is being received by an HTTP/1.1 (or later) proxy and
forwarded to an HTTP/1.0 recipient. It avoids a situation where
compliance with the protocol would have necessitated a possibly
infinite buffer on the proxy. An example process for decoding a Chunked-Body is presented in
appendix 19.4.6. All HTTP/1.1 applications MUST be able to receive and decode the
"chunked" transfer-coding, and MUST ignore chunk-extension extensions
they do not understand.
const int READ_BUFFER_SIZE = 1<<16;
DWORD cbRead;
LPBYTE buffer=(LPBYTE)LocalAlloc(LPTR, READ_BUFFER_SIZE);
BOOL rc;
DWORD dwTotalBytes=0;
do
{
cbRead=READ_BUFFER_SIZE;
if(!ReadClient(buffer, &cbRead)) return FALSE;
// do sth.
dwTotalBytes+=cbRead;
}while(cbRead>0);//do sth.return TRUE;