---
name: "Ns_ConnReturnFile"
section: "3aolserver"
platform: "linux"
package: "aolserver4-dev"
version: "4.5.1-18.1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/Ns_ConnReturnFile/3aolserver"
---

# Ns\_ConnReturnFile(3aolserver)

Return a file as a complete response

```

```

## NAME

Ns\_ConnReturnFile - Return a file as a complete response

## SYNOPSIS

```
#include "ns.h"

int
Ns_ConnReturnFile(conn, status, type, file)
```

## ARGUMENTS

- Ns\_Conn *conn* (in)

  Pointer to open connection.

- char *\*file* (in)

  Pointer to filename string.

- int *status* (in)

  HTTP status code.

- char *\*type* (in)

  Pointer to mimetype string.

  ```

  ```

## DESCRIPTION

This routine is used to generate complete responses, including the HTTP status code specified by the *status* argument and appropriate headers followed by the contents of the file specified with the *file* argument.  This routine utilizes the underlying builtin file-server code (aka, "fastpath").  As such, it shares the fastpath capabilities to automatically cache pre-read or memory mapped copies of the files and can safely support multiple, simultaneous responses. The following headers are included in the output:

- Last-modified

  Constructed based on the modification time of the given file.

- Content-length

  Constructed based on the size of the give file.

- Content-type

  Constructed with the given *type* argument.  If *type* is NULL, the type will be determined based on the filename using the **Ns\_GetMimeType** routine

## SEE ALSO

Ns\_ConnFlush(3), [Ns\_ConnReturnOpenFd(3)](/Ns_ConnReturnOpenFd/3.md), [Ns\_GetMimeType(3)](/Ns_GetMimeType/3.md)

## KEYWORDS

connnection, response
