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

system.verbs.builtins.string.httpResultSplit

on httpResultSplit (s, adrheadertable=nil) { //break an HTTP result into its components
	local (ix = string.patternMatch ("\r\n\r\n", s));
	if adrheadertable != nil { //caller wants the header info
		new (tabletype, adrheadertable); //webserver.util.parseHeaders will accumulate duplicates into lists, we don't want that here
		webserver.util.parseHeaders (s, adrheadertable)};
	return (string.delete (s, 1, ix + 3))}
<<bundle //test code
	<<local (headers)
	<<new (tabletype, @headers)
	<<local (s = tcp.httpClient ("GET", "www.scripting.com", 80, "/"))
	<<local (body = httpResultSplit (s, @headers))
	<<wp.newtextobject (body, @scratchpad.requestbody)
	<<scratchpad.requestheaders = headers



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.