At 10:25 PM +0800 22/3/01, LiangTyan Fui wrote:
>This might be re-inventing the wheel of exiting "put url" and "load url"
>commands but here goes:
>
>I was trying to query web site with the "put url" command, but this command
>lock the process when the internet link was less than perfect (I am on
>dialup most of the time).
>
>So I changed the query method to "load url x with message y" -- helps a
>little, but still hog from time to time when the connection was real poor.
>The "load url" pause for few seconds (occasionally to a minute)
>
>So I took the trouble to write my own method by using socket, and opened up
>a Pandora box.
>
>A typical http session returns something as follow:
>
>HTTP/1.1 200 OK
>Server: MetaCard/2.3 ID/11222
>MIME-Version: 1.0
>Content-type: text/html
>Content-Length: 102
>
>And follow by the content of the file.
>However, not many http server returns the "Content-Length" header in many
>cases (special CGI generated result). So I have problem to determine how
>many bytes to read with:
>read from socket x for y chars
>
>Anyone out there has better idea of how can I deal with it?

Hi

In the cases where no "Content-Length" is returned, is the data 
returned in "chunked" style. I've never worked on such data, but I 
think you can check for a "transfer-coding = chunked" line in the 
header. If so, the length of each "chunk" is contained within the 
chunk itself, I think. (Check the HTTP 1.1 RFC for details).

In my own endeavors, I haven't come across any servers that don't 
return a "Content-Length" field, but I'm working with a limited 
number of servers.

Cheers
Dave Cragg

Archives: http://www.mail-archive.com/[email protected]/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to