NE_SET_REQUEST_BODY_(3)
okay bestie, this is NE_SET_REQUEST_BODY_(3) β the neon API reference page all about putting a message body on a request, and we're gonna make it make sense π β¨
π 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 π
So ne_set_request_body_buffer says: yes, include a message body, and that body 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 that's read from a file descriptor. The body is read from the file descriptor fd, which must be associated with a seekable file β not a pipe, socket, or FIFO, bestie π count bytes are read, beginning at offset begin (so passing begin as zero means the body is read from the beginning of the file π).
for real though: for both of the above functions, the source of the request body must survive until the request has been dispatched. neither the memory buffer passed tone_set_request_body_buffernor the file descriptor passed tone_set_request_body_fdare copied internally. keep that source alive, periodt π
The ne_set_request_body_provider function can be used to include a message body with a request that's provided by a callback function. The body length passed in the length parameter 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
0andbuflenβ 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_set_error(3)
π COPYRIGHT π
Copyright Β© 2001-2026 Joe Orton
that's a wrap, bestie π«Ά this glow-up comes from neon, dated 03/20/2026, and it's the NE_SET_REQUEST_BODY_(3) manual β periodt π
π¦ where this page comes from
- arch rolling: neon 0.37.1-1 Β· LGPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms