---
name: "ns_geturl"
section: "3"
platform: "linux"
package: "aolserver4"
version: "4.0.10-7"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/ns_geturl"
---

# ns\_geturl(3)

commands

```

```

## NAME

ns\_geturl - commands

## SYNOPSIS

**ns\_geturl** *URL* ?*headersSetId*?

```

```

## DESCRIPTION

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.

## SEE ALSO

nsd(1), [info(n)](/info/n.md), ns\_set(n), ns\_httpget(n)

## KEYWORDS
