ad_general_link_get_title

one of the documented procedures in this installation of the ACS
Usage:
ad_general_link_get_title   url
What it does:
gets a link title from a url
Defined in: /web/philip/tcl/ad-general-links.tcl

Source code:



    # strip off any trailing #foo section directives to browsers
    set complete_url $url
    regexp {^(.*/?[^/]+)\#[^/]+$} $complete_url match complete_url
    if [catch { set response [get_http_status $complete_url 0] } errmsg ] {
	# we got an error (probably a dead server)
	return ""
    } elseif {$response == 404 || $response == 405 || $response == 500 } {
	# we should try again with a full GET 
	# because a lot of program-backed servers return 404 for HEAD
	# when a GET works fine
	if [catch { set response [get_http_status $complete_url 1] } errmsg] {
	    # probably the foreign server isn't responding
	    return ""
	} 
    }

    if { $response != 200 && $response != 302 } {
	return ""
    } else {
	if {![catch {ns_httpget $complete_url 3 1} url_content]} {
	    
	    set link_title ""
	    
	    regexp -nocase {<title>(.*)</title} $url_content match link_title

	    # process and truncate outrageously long titles

	    if {[string length $link_title]>100} {
		set link_title "[string range $link_title 0 96]..."
	    }
	} else {
	    return ""
	}
    }

    return $link_title



philg@mit.edu