ns_geturl(3)

ns_geturl3

Commands

Usage

ns_geturl URL ?headersSetId?


    


    


    

Overview

This command retrieves the contents of the specified URL. The URL must be a remote http server, or a file relative to the pageroot (begins with /). It does not handle a relative request or follow redirects. The headerSetId option is a variable containing an ns_set Id (not expanded with a $) used to store the remote server headers (see example). ns_geturl only support HTTP version 1.0.

Examples

set page [ns_geturl "www.aolserver.com"]
ns_return 200 text/html $page

This fetches the contents of www.aolserver.com and returns that page to the client.

set headers [ns_set new]
set page [ns_geturl "www.aolserver.com" headers]
for {set i 0} {$i < [ns_set size $headers]} {incr i} {
   ns_puts "Key: [ns_set key $headers $i]"
   ns_puts "Value: [ns_set value $headers $i]"
}

This time, a blank headerset is passed to ns_geturl so we can retrieve the headers of the remote page, which we print out to the client.

set file [ns_geturl "/foo/bar.html"]
ns_return 200 text/html $file

This example fetches the /foo/bar.html file relative to the pageroot and returns it to the client.

Keywords

Releases

Unchanged in 2 releases since Debian 3.1 (Sarge).

  1. 3.1–4.0

From aolserver4 4.0.10-7 in Debian 4.0 (Etch). Parsed by carta from the page's man source.