Monday, November 08, 2010 at 12:07 AM.


on getEnclosureData (url, adrenclosure) {
		<<1/10/01; 12:38:16 PM by DW
			<<Make an HTTP request to get the header info for the indicated url and store it in the enclosure table. If it worked, the table will have url, length and type elements. If it failed it will have url and error (containing the error string).
		<<1/17/01; 6:56:47 AM by DW
			<<Ooops, length must be a number.
	table.emptytable (adrenclosure);
	adrenclosure^.url = url;
	try {
		local (urllist = string.urlSplit (url), server = urllist [2], path = urllist [3], headers);
		string.httpResultSplit (tcp.httpClient (server:server, path:path, flJustHeaders:true), @headers);
		adrenclosure^.length = number (headers.["Content-Length"]);
		adrenclosure^.type = headers.["Content-Type"]}
	else {
		adrenclosure^.error = tryError}}
<<bundle //test code
	<<getEnclosureData ("", @myUserLandData.stories.["00008242"].enclosure)

This listing is for code that runs in the OPML Editor environment. I created these listings because I wanted the search engines to index it, so that when I want to look up something in my codebase I don't have to use the much slower search functionality in my object database. Dave Winer.