---
name: "ne_set_request_body_buffer"
section: "3"
platform: "linux"
package: "neon"
version: "0.37.1-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/ne_set_request_body_buffer"
---

# ne\_set\_request\_body\_buffer(3)

include a message body with a request

## NAME

ne\_set\_request\_body\_buffer, ne\_set\_request\_body\_fd, ne\_set\_request\_body\_provider - include a message body with a request

## SYNOPSIS

```
#include <ne_request.h>
```

**void ne\_set\_request\_body\_buffer(ne\_request \****req***, const char \****buf***, size\_t** *count***);**

**int ne\_set\_request\_body\_fd(ne\_request \****req***, int** *fd***, ne\_off\_t** *begin***, ne\_off\_t** *length***);**

**typedef ssize\_t (\*ne\_provide\_body)(void \****userdata***, char \****data***, size\_t** *buflen***);**

**int ne\_set\_request\_body\_provider(ne\_request \****req***, ne\_off\_t** *length***, ne\_provide\_body** *provider***, void \****userdata***);**

## DESCRIPTION

The **ne\_set\_request\_body\_buffer** function specifies that a message body should be included with the body, which is stored in the *count* bytes buffer *buf*.

The **ne\_set\_request\_body\_fd** function can be used to include a message body with a request which is read from a file descriptor. The body is read from the file descriptor *fd*, which must be a associated with a seekable file (not a pipe, socket, or FIFO). *count* bytes are read, beginning at offset *begin* (hence, passing *begin* as zero means the body is read from the beginning of the file).

For both above functions, the source of the request body must survive until the request has been dispatched; neither the memory buffer passed to **ne\_set\_request\_body\_buffer** nor the file descriptor passed to **ne\_set\_request\_body\_fd** are copied internally.

The **ne\_set\_request\_body\_provider** function can be used to include a message body with a request which is provided by a callback function. The body length passed in the *length* paramater must be positive, or if a chunked request body is required, as covered below, -1 can be used.

Before sending the body, the callback is invoked once with the *buflen* parameter as 0. The body is then read by invoking the callback repeatedly until it returns 0 indicating the end-of-body. The callback return value must be as follows:

less than 0

An error; the request will be aborted. The session error string must be set via **ne\_set\_error**.

0

End of body.

between 0 and **buflen**

Number of bytes of request body data.

### Chunked request bodies

Chunked request bodies are only sent when **ne\_set\_request\_body\_provider** is used and -1 is passed as the *length*. In this case, the length of the request body does not have to be determined ahead of time. The end of the request body is indicated by returning 0 from the callback function.

Before using a chunked request body, the caller must determine that HTTP/1.1 is supported (by the origin server and any HTTP proxy server configured). This can be done by testing that **ne\_version\_pre\_http11** returns zero after performing an OPTIONS or HEAD request.

## SEE ALSO

[**ne\_request\_create**(3)](/ne_request_create/3.md), [**ne\_set\_error**(3)](/ne_set_error/3.md)

## COPYRIGHT

Copyright © 2001-2026 Joe Orton\
