ne_set_request_body_buffer.3 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  1. '\" t
  2. .\" Title: ne_set_request_body_buffer
  3. .\" Author:
  4. .\" Generator: DocBook XSL Stylesheets vsnapshot <http://docbook.sf.net/>
  5. .\" Date: 15 April 2025
  6. .\" Manual: neon API reference
  7. .\" Source: neon 0.34.2
  8. .\" Language: English
  9. .\"
  10. .TH "NE_SET_REQUEST_BODY_" "3" "15 April 2025" "neon 0.34.2" "neon API reference"
  11. .\" -----------------------------------------------------------------
  12. .\" * Define some portability stuff
  13. .\" -----------------------------------------------------------------
  14. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. .\" http://bugs.debian.org/507673
  16. .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
  17. .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  18. .ie \n(.g .ds Aq \(aq
  19. .el .ds Aq '
  20. .\" -----------------------------------------------------------------
  21. .\" * set default formatting
  22. .\" -----------------------------------------------------------------
  23. .\" disable hyphenation
  24. .nh
  25. .\" disable justification (adjust text to left margin only)
  26. .ad l
  27. .\" -----------------------------------------------------------------
  28. .\" * MAIN CONTENT STARTS HERE *
  29. .\" -----------------------------------------------------------------
  30. .SH "NAME"
  31. ne_set_request_body_buffer, ne_set_request_body_fd, ne_set_request_body_provider \- include a message body with a request
  32. .SH "SYNOPSIS"
  33. .sp
  34. .ft B
  35. .nf
  36. #include <ne_request\&.h>
  37. .fi
  38. .ft
  39. .HP \w'void\ ne_set_request_body_buffer('u
  40. .BI "void ne_set_request_body_buffer(ne_request\ *" "req" ", const\ char\ *" "buf" ", size_t\ " "count" ");"
  41. .HP \w'int\ ne_set_request_body_fd('u
  42. .BI "int ne_set_request_body_fd(ne_request\ *" "req" ", int\ " "fd" ", ne_off_t\ " "begin" ", ne_off_t\ " "length" ");"
  43. .HP \w'typedef\ ssize_t\ (*ne_provide_body)('u
  44. .BI "typedef ssize_t (*ne_provide_body)(void\ *" "userdata" ", char\ *" "data" ", size_t\ " "buflen" ");"
  45. .HP \w'int\ ne_set_request_body_provider('u
  46. .BI "int ne_set_request_body_provider(ne_request\ *" "req" ", ne_off_t\ " "length" ", ne_provide_body\ " "provider" ", void\ *" "userdata" ");"
  47. .SH "DESCRIPTION"
  48. .PP
  49. The
  50. \fBne_set_request_body_buffer\fR
  51. function specifies that a message body should be included with the body, which is stored in the
  52. \fIcount\fR
  53. bytes buffer
  54. \fIbuf\fR\&.
  55. .PP
  56. The
  57. \fBne_set_request_body_fd\fR
  58. 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
  59. \fIfd\fR, which must be a associated with a seekable file (not a pipe, socket, or FIFO)\&.
  60. \fIcount\fR
  61. bytes are read, beginning at offset
  62. \fIbegin\fR
  63. (hence, passing
  64. \fIbegin\fR
  65. as zero means the body is read from the beginning of the file)\&.
  66. .PP
  67. For both above functions, the source of the request body must survive until the request has been dispatched; neither the memory buffer passed to
  68. \fBne_set_request_body_buffer\fR
  69. nor the file descriptor passed to
  70. \fBne_set_request_body_fd\fR
  71. are copied internally\&.
  72. .PP
  73. The
  74. \fBne_set_request_body_provider\fR
  75. 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
  76. \fIlength\fR
  77. paramater must be positive, or if a chunked request body is required, as covered below,
  78. \-1
  79. can be used\&.
  80. .PP
  81. Before sending the body, the callback is invoked once with the
  82. \fIbuflen\fR
  83. parameter as
  84. 0\&. The body is then read by invoking the callback repeatedly until it returns
  85. 0
  86. indicating the end\-of\-body\&. The callback return value must be as follows:
  87. .PP
  88. less than 0
  89. .RS 4
  90. An error; the request will be aborted\&. The session error string must be set via
  91. \fBne_set_error\fR\&.
  92. .RE
  93. .PP
  94. 0
  95. .RS 4
  96. End of body\&.
  97. .RE
  98. .PP
  99. between 0 and \fBbuflen\fR
  100. .RS 4
  101. Number of bytes of request body data\&.
  102. .RE
  103. .SS "Chunked request bodies"
  104. .PP
  105. Chunked request bodies are only sent when
  106. \fBne_set_request_body_provider\fR
  107. is used and
  108. \-1
  109. is passed as the
  110. \fIlength\fR\&. 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
  111. 0
  112. from the callback function\&.
  113. .PP
  114. 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
  115. \fBne_version_pre_http11\fR
  116. returns zero after performing an
  117. OPTIONS
  118. or
  119. HEAD
  120. request\&.
  121. .SH "SEE ALSO"
  122. .PP
  123. ne_request_create,
  124. ne_set_error
  125. .SH "COPYRIGHT"
  126. .br
  127. Copyright \(co 2001-2024 Joe Orton
  128. .br