MCPcopy Create free account
hub / github.com/apache/httpd / ssl_io_buffer_fill

Function ssl_io_buffer_fill

modules/ssl/ssl_engine_io.c:2023–2120  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2021};
2022
2023int ssl_io_buffer_fill(request_rec *r, apr_size_t maxlen)
2024{
2025 conn_rec *c = r->connection;
2026 struct modssl_buffer_ctx *ctx;
2027 apr_bucket_brigade *tempb;
2028 apr_off_t total = 0; /* total length buffered */
2029 int eos = 0; /* non-zero once EOS is seen */
2030
2031 /* Create the context which will be passed to the input filter;
2032 * containing a setaside pool and a brigade which constrain the
2033 * lifetime of the buffered data. */
2034 ctx = apr_palloc(r->pool, sizeof *ctx);
2035 ctx->bb = apr_brigade_create(r->pool, c->bucket_alloc);
2036
2037 /* ... and a temporary brigade. */
2038 tempb = apr_brigade_create(r->pool, c->bucket_alloc);
2039
2040 ap_log_cerror(APLOG_MARK, APLOG_TRACE4, 0, c, "filling buffer, max size "
2041 "%" APR_SIZE_T_FMT " bytes", maxlen);
2042
2043 do {
2044 apr_status_t rv;
2045 apr_bucket *e, *next;
2046
2047 /* The request body is read from the protocol-level input
2048 * filters; the buffering filter will reinject it from that
2049 * level, allowing content/resource filters to run later, if
2050 * necessary. */
2051
2052 rv = ap_get_brigade(r->proto_input_filters, tempb, AP_MODE_READBYTES,
2053 APR_BLOCK_READ, 8192);
2054 if (rv) {
2055 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(02015)
2056 "could not read request body for SSL buffer");
2057 return ap_map_http_request_error(rv, HTTP_INTERNAL_SERVER_ERROR);
2058 }
2059
2060 /* Iterate through the returned brigade: setaside each bucket
2061 * into the context's pool and move it into the brigade. */
2062 for (e = APR_BRIGADE_FIRST(tempb);
2063 e != APR_BRIGADE_SENTINEL(tempb) && !eos; e = next) {
2064 const char *data;
2065 apr_size_t len;
2066
2067 next = APR_BUCKET_NEXT(e);
2068
2069 if (APR_BUCKET_IS_EOS(e)) {
2070 eos = 1;
2071 } else if (!APR_BUCKET_IS_METADATA(e)) {
2072 rv = apr_bucket_read(e, &data, &len, APR_BLOCK_READ);
2073 if (rv != APR_SUCCESS) {
2074 ap_log_rerror(APLOG_MARK, APLOG_ERR, rv, r, APLOGNO(02016)
2075 "could not read bucket for SSL buffer");
2076 return HTTP_INTERNAL_SERVER_ERROR;
2077 }
2078 total += len;
2079 }
2080

Callers 1

fill_reneg_bufferFunction · 0.85

Calls 4

ap_get_brigadeFunction · 0.85
ap_remove_input_filterFunction · 0.85
ap_add_input_filterFunction · 0.85

Tested by

no test coverage detected