summaryrefslogtreecommitdiff
path: root/include/http_protocol.h
diff options
context:
space:
mode:
authorYann Ylavic <ylavic@apache.org>2018-04-20 14:30:19 +0000
committerYann Ylavic <ylavic@apache.org>2018-04-20 14:30:19 +0000
commit57383650238006fdeed8e7900a8cfa4a807c0cf3 (patch)
tree35e37c0a23de9285b2a2affa76c78fdd58d59b6f /include/http_protocol.h
parent15facfd9c996c361eb958b7b33b2aa3cbaabf79a (diff)
downloadhttpd-57383650238006fdeed8e7900a8cfa4a807c0cf3.tar.gz
http: add ap_fgetline() and AP_GETLINE_NONBLOCK flag.
It allows to read a line directly from an input filter, in blocking mode or not. Since no request_rec is needed, a pool may be given. Existing ap_[r]getline() function are now based off ap_fgetline() by calling: ap_fgetline(s, n, read, r->proto_input_filters, flags, bb, r->pool); Will follow up with a new ap_get_mime_headers_*() flavor which can be used by any filter that needs non-blocking and not necessarily has a request_rec (e.g. ap_http_filter() to read proxied response trailers). git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1829659 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'include/http_protocol.h')
-rw-r--r--include/http_protocol.h68
1 files changed, 39 insertions, 29 deletions
diff --git a/include/http_protocol.h b/include/http_protocol.h
index f38b413b83..bf15f9837b 100644
--- a/include/http_protocol.h
+++ b/include/http_protocol.h
@@ -630,19 +630,18 @@ AP_DECLARE(apr_status_t) ap_get_basic_auth_components(const request_rec *r,
*/
AP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri);
-#define AP_GETLINE_FOLD 1 /* Whether to merge continuation lines */
-#define AP_GETLINE_CRLF 2 /* Whether line ends must be in the form CR LF */
-#define AP_GETLINE_NOSPC_EOL 4 /* Whether to consume up to and including the
- end of line on APR_ENOSPC */
+#define AP_GETLINE_FOLD (1 << 0) /* Whether to merge continuation lines */
+#define AP_GETLINE_CRLF (1 << 1) /* Whether line ends must be CRLF */
+#define AP_GETLINE_NOSPC_EOL (1 << 2) /* Whether to consume up to and including
+ the end of line on APR_ENOSPC */
+#define AP_GETLINE_NONBLOCK (1 << 3) /* Whether to read non-blocking */
/**
* Get the next line of input for the request
* @param s The buffer into which to read the line
* @param n The size of the buffer
* @param r The request
- * @param flags Bit flag of multiple parsing options
- * AP_GETLINE_FOLD Whether to merge continuation lines
- * AP_GETLINE_CRLF Whether line ends must be in the form CR LF
+ * @param flags Bit mask of AP_GETLINE_* options
* @return The length of the line, if successful
* n, if the line is too big to fit in the buffer
* -1 for miscellaneous errors
@@ -650,45 +649,56 @@ AP_CORE_DECLARE(void) ap_parse_uri(request_rec *r, const char *uri);
AP_DECLARE(int) ap_getline(char *s, int n, request_rec *r, int flags);
/**
- * Get the next line of input for the request
- *
- * Note: on ASCII boxes, ap_rgetline is a macro which simply calls
- * ap_rgetline_core to get the line of input.
- *
- * on EBCDIC boxes, ap_rgetline is a wrapper function which
- * translates ASCII protocol lines to the local EBCDIC code page
- * after getting the line of input.
+ * Get the next line from an input filter
*
* @param s Pointer to the pointer to the buffer into which the line
* should be read; if *s==NULL, a buffer of the necessary size
- * to hold the data will be allocated from the request pool
+ * to hold the data will be allocated from \p p
* @param n The size of the buffer
* @param read The length of the line.
- * @param r The request
- * @param flags Bit flag of multiple parsing options
- * AP_GETLINE_FOLD Whether to merge continuation lines
- * AP_GETLINE_CRLF Whether line ends must be in the form CR LF
+ * @param f Input filter to read from
+ * @param flags Bit mask of AP_GETLINE_* options
* @param bb Working brigade to use when reading buckets
+ * @param p The pool to allocate the buffer from (if needed)
* @return APR_SUCCESS, if successful
* APR_ENOSPC, if the line is too big to fit in the buffer
* Other errors where appropriate
*/
+AP_DECLARE(apr_status_t) ap_fgetline(char **s, apr_size_t n,
+ apr_size_t *read, ap_filter_t *f,
+ int flags, apr_bucket_brigade *bb,
+ apr_pool_t *p);
+
+/**
+ * @see ap_fgetline
+ *
+ * Note: genuinely calls, ap_fgetline(s, n, read, r->proto_input_filters,
+ * flags, bb, r->pool)
+ */
+AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
+ apr_size_t *read, request_rec *r,
+ int flags, apr_bucket_brigade *bb);
+
+/**
+ * @see ap_rgetline_core
+ *
+ * Note: on ASCII boxes, ap_rgetline is a macro which simply calls
+ * ap_rgetline_core to get the line of input.
+ *
+ * on EBCDIC boxes, ap_rgetline is a wrapper function which
+ * translates ASCII protocol lines to the local EBCDIC code page
+ * after getting the line of input.
+ *
+ */
#if APR_CHARSET_EBCDIC
AP_DECLARE(apr_status_t) ap_rgetline(char **s, apr_size_t n,
- apr_size_t *read,
- request_rec *r, int flags,
- apr_bucket_brigade *bb);
+ apr_size_t *read, request_rec *r,
+ int flags, apr_bucket_brigade *bb);
#else /* ASCII box */
#define ap_rgetline(s, n, read, r, flags, bb) \
ap_rgetline_core((s), (n), (read), (r), (flags), (bb))
#endif
-/** @see ap_rgetline */
-AP_DECLARE(apr_status_t) ap_rgetline_core(char **s, apr_size_t n,
- apr_size_t *read,
- request_rec *r, int flags,
- apr_bucket_brigade *bb);
-
/**
* Get the method number associated with the given string, assumed to
* contain an HTTP method. Returns M_INVALID if not recognized.