apr_file_pipe_timeout_set(script_in, 0);
apr_file_pipe_timeout_set(script_err, 0);
- /* if r is a subrequest, ensure that the bucket only references
- * r->main, since it may last longer than the subreq. */
- b = cgi_bucket_create(r->main ? r->main : r, script_in, script_err,
- c->bucket_alloc);
+ b = cgi_bucket_create(r, script_in, script_err, c->bucket_alloc);
#else
b = apr_bucket_pipe_create(script_in, c->bucket_alloc);
#endif
e = APR_BUCKET_NEXT(e))
{
rv = apr_bucket_setaside(e, p);
- if (rv != APR_SUCCESS
- /* ### this ENOTIMPL will go away once we implement setaside
- ### for all bucket types. */
- && rv != APR_ENOTIMPL) {
+
+ /* If the bucket type does not implement setaside, then
+ * (hopefully) morph it into a bucket type which does, and set
+ * *that* aside... */
+ if (rv == APR_ENOTIMPL) {
+ const char *s;
+ apr_size_t n;
+
+ rv = apr_bucket_read(e, &s, &n, APR_BLOCK_READ);
+ if (rv == APR_SUCCESS) {
+ rv = apr_bucket_setaside(e, p);
+ }
+ }
+
+ if (rv != APR_SUCCESS) {
return rv;
}
}