http响应的有关问题?

http响应的问题????????
http的响应有   Connection:   close   字段,没有Content-Length:字段,我如何知道后续数据的大小?

如;第一个包为
HTTP/1.0   200   OK
Date:   Fri,   24   Aug   2007   16:22:50   GMT
Server:   Boa/0.93.15
Connection:   close
Content-Type:   text/html

第二个为:
{ "challenge ": "991236299 "}

我怎么知道第二个包有多长?

------解决方案--------------------

The transfer-length of a message is the length of the message-body as
it appears in the message; that is, after any transfer-codings have
been applied. When a message-body is included with a message, the
transfer-length of that body is determined by one of the following
(in order of precedence):

1.Any response message which "MUST NOT " include a message-body (such
as the 1xx, 204, and 304 responses and any response to a HEAD
request) is always terminated by the first empty line after the
header fields, regardless of the entity-header fields present in
the message.

2.If a Transfer-Encoding header field (section 14.41) is present and
has any value other than "identity ", then the transfer-length is
defined by use of the "chunked " transfer-coding (section 3.6),
unless the message is terminated by closing the connection.

3.If a Content-Length header field (section 14.13) is present, its
decimal value in OCTETs represents both the entity-length and the
transfer-length. The Content-Length header field MUST NOT be sent
if these two lengths are different (i.e., if a Transfer-Encoding
header field is present). If a message is received with both a
Transfer-Encoding header field and a Content-Length header field,
the latter MUST be ignored.

4.If the message uses the media type "multipart/byteranges ", and the
ransfer-length is not otherwise specified, then this self-
elimiting media type defines the transfer-length. This media type
UST NOT be used unless the sender knows that the recipient can arse
it; the presence in a request of a Range header with ultiple byte-
range specifiers from a 1.1 client implies that the lient can parse
multipart/byteranges responses.

A range header might be forwarded by a 1.0 proxy that does not
understand multipart/byteranges; in this case the server MUST
delimit the message using methods defined in items 1,3 or 5 of
this section.

5.By the server closing the connection. (Closing the connection
cannot be used to indicate the end of a request body, since that
would leave no possibility for the server to send back a response.)
这个是第五种情况
------解决方案--------------------
晕 他不一定是 第2个包

你如果是GET的话 发送一个Connection: close报文过去

当对方关闭 socket的时候 表示 文件下载完毕 也就是说 你不用管文件多长

只要对方关闭socket你就可以 保存文件 关闭文件句柄了


给分 我做过这个