12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>ne_set_request_body_buffer</title><link rel="stylesheet" type="text/css" href="manual.css"><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot"><link rel="home" href="index.html" title="neon HTTP/WebDAV client library"><link rel="up" href="ref.html" title="neon API reference"><link rel="prev" href="refreqflags.html" title="ne_set_request_flag"><link rel="next" href="refreqtarget.html" title="ne_get_request_target"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="3" align="center">ne_set_request_body_buffer</th></tr><tr><td width="20%" align="left"><a accesskey="p" href="refreqflags.html">Prev</a> </td><th width="60%" align="center">neon API reference</th><td width="20%" align="right"> <a accesskey="n" href="refreqtarget.html">Next</a></td></tr></table><hr></div><div class="refentry"><a name="refreqbody"></a><div class="titlepage"></div><div class="refnamediv"><h2>Name</h2><p>ne_set_request_body_buffer, ne_set_request_body_fd, ne_set_request_body_provider — include a message body with a request</p></div><div class="refsynopsisdiv"><h2>Synopsis</h2><div class="funcsynopsis"><pre class="funcsynopsisinfo">#include <ne_request.h></pre><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">void <b class="fsfunc">ne_set_request_body_buffer</b>(</code></td><td>ne_request *<var class="pdparam">req</var>, </td></tr><tr><td> </td><td>const char *<var class="pdparam">buf</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">count</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">ne_set_request_body_fd</b>(</code></td><td>ne_request *<var class="pdparam">req</var>, </td></tr><tr><td> </td><td>int <var class="pdparam">fd</var>, </td></tr><tr><td> </td><td>ne_off_t <var class="pdparam">begin</var>, </td></tr><tr><td> </td><td>ne_off_t <var class="pdparam">length</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">typedef ssize_t (*<b class="fsfunc">ne_provide_body</b>)(</code></td><td>void *<var class="pdparam">userdata</var>, </td></tr><tr><td> </td><td>char *<var class="pdparam">data</var>, </td></tr><tr><td> </td><td>size_t <var class="pdparam">buflen</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div><table border="0" class="funcprototype-table" summary="Function synopsis" style="cellspacing: 0; cellpadding: 0;"><tr><td><code class="funcdef">int <b class="fsfunc">ne_set_request_body_provider</b>(</code></td><td>ne_request *<var class="pdparam">req</var>, </td></tr><tr><td> </td><td>ne_off_t <var class="pdparam">length</var>, </td></tr><tr><td> </td><td>ne_provide_body <var class="pdparam">provider</var>, </td></tr><tr><td> </td><td>void *<var class="pdparam">userdata</var><code>)</code>;</td></tr></table><div class="funcprototype-spacer"> </div></div></div><div class="refsect1"><a name="id3537"></a><h2>Description</h2><p>The <code class="function">ne_set_request_body_buffer</code>
- function specifies that a message body should be included with the
- body, which is stored in the <code class="parameter">count</code> bytes buffer
- <code class="parameter">buf</code>.</p><p>The <code class="function">ne_set_request_body_fd</code> 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
- <code class="parameter">fd</code>, which must be a associated with a seekable
- file (not a pipe, socket, or FIFO). <code class="parameter">count</code>
- bytes are read, beginning at offset <code class="parameter">begin</code>
- (hence, passing <code class="parameter">begin</code> as zero means the body is read
- from the beginning of the file).</p><p>For both above functions, the source of the request
- body must survive until the request has been dispatched;
- neither the memory buffer passed to
- <code class="function">ne_set_request_body_buffer</code> nor the file
- descriptor passed to
- <code class="function">ne_set_request_body_fd</code> are copied
- internally.</p><p>The <code class="function">ne_set_request_body_provider</code>
- 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 <code class="parameter">length</code> paramater must be
- positive, or if a chunked request body is required, as covered
- below, <code class="literal">-1</code> can be used.</p><p>Before sending the body, the callback is invoked once
- with the <code class="parameter">buflen</code> parameter as
- <code class="literal">0</code>. The body is then read by invoking the
- callback repeatedly until it returns <code class="literal">0</code>
- indicating the end-of-body. The callback return value must be
- as follows:
- </p><div class="variablelist"><table border="0" class="variablelist"><colgroup><col align="left" valign="top"><col></colgroup><tbody><tr><td><p><span class="term">less than <code class="literal">0</code></span></p></td><td>An error; the request will be
- aborted. The session error string must be set via
- <code class="function">ne_set_error</code>.</td></tr><tr><td><p><span class="term"><code class="literal">0</code></span></p></td><td>End of body.</td></tr><tr><td><p><span class="term">between <code class="literal">0</code> and
- <code class="constant">buflen</code></span></p></td><td>Number of bytes of request body data.</td></tr></tbody></table></div><div class="refsect2"><a name="id3578"></a><h3>Chunked request bodies</h3><p>Chunked request bodies are only sent when
- <code class="function">ne_set_request_body_provider</code> is used
- and <code class="literal">-1</code> is passed as the
- <code class="parameter">length</code>. 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
- <code class="literal">0</code> from the callback function.</p><p>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 <code class="function">ne_version_pre_http11</code>
- returns zero after performing an <code class="literal">OPTIONS</code>
- or <code class="literal">HEAD</code> request.</p></div></div><div class="refsect1"><a name="id3589"></a><h2>See also</h2><p><a class="xref" href="refreq.html#ne_request_create">ne_request_create</a>, <a class="xref" href="referr.html#ne_set_error">ne_set_error</a></p></div></div><div class="navfooter"><hr><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="refreqflags.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="ref.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="refreqtarget.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">ne_set_request_flag </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> ne_get_request_target</td></tr></table></div></body></html>
|