On 9/22/21 3:49 PM, Evgeny Kotkov wrote:
> Ruediger Pluem <rpl...@apache.org> writes:
>
>> Does the attached patch solve your issue?
>
> It does appear to solve the problem with missing errors, thanks!
>
> I haven't checked that in detail, but I think there might be a discrepancy
> in how `err` is handled in the patch and for example when calling the
> method_precondition() hook.
>
> With the patch, `err` is checked even if all hooks DECLINE the operation.
> Not too sure if that's intended, because the variable could potentially
> contain an arbitrary value or a leftover from some previous call.
The below new version should address the case that there was a left over in err
from
calling dav_run_method_precondition by resetting err to NULL.
If we should ignore err if all hooks return DECLINED but set err, to be honest
I don't know. I hope for someone with more DAV
insights to comment and tell me, what is correct here :-).
Depending on this it should be easy to adjust the patch accordingly if needed.
Index: modules/dav/main/mod_dav.c
===================================================================
--- modules/dav/main/mod_dav.c (revision 1893507)
+++ modules/dav/main/mod_dav.c (working copy)
@@ -4403,10 +4403,32 @@
/* set up defaults for the report response */
r->status = HTTP_OK;
ap_set_content_type(r, DAV_XML_CONTENT_TYPE);
+ err = NULL;
/* run report hook */
result = dav_run_deliver_report(r, resource, doc,
r->output_filters, &err);
+ if (err != NULL) {
+
+ if (! r->sent_bodyct) {
+ /* No data has been sent to client yet; throw normal error. */
+ return dav_handle_err(r, err, NULL);
+ }
+
+ /* If an error occurred during the report delivery, there's
+ basically nothing we can do but abort the connection and
+ log an error. This is one of the limitations of HTTP; it
+ needs to "know" the entire status of the response before
+ generating it, which is just impossible in these streamy
+ response situations. */
+ err = dav_push_error(r->pool, err->status, 0,
+ "Provider encountered an error while streaming"
+ " a REPORT response.", err);
+ dav_log_err(r, err, APLOG_ERR);
+ r->connection->aborted = 1;
+
+ return DONE;
+ }
switch (result) {
case OK:
return DONE;
@@ -4414,27 +4436,7 @@
/* No one handled the report */
return HTTP_NOT_IMPLEMENTED;
default:
- if ((err) != NULL) {
-
- if (! r->sent_bodyct) {
- /* No data has been sent to client yet; throw normal error. */
- return dav_handle_err(r, err, NULL);
- }
-
- /* If an error occurred during the report delivery, there's
- basically nothing we can do but abort the connection and
- log an error. This is one of the limitations of HTTP; it
- needs to "know" the entire status of the response before
- generating it, which is just impossible in these streamy
- response situations. */
- err = dav_push_error(r->pool, err->status, 0,
- "Provider encountered an error while
streaming"
- " a REPORT response.", err);
- dav_log_err(r, err, APLOG_ERR);
- r->connection->aborted = 1;
-
- return DONE;
- }
+ return DONE;
}
return DONE;