Lines 982-1022
Link Here
|
982 |
} |
982 |
} |
983 |
|
983 |
|
984 |
if (err == NULL) { |
984 |
if (err == NULL) { |
985 |
if (ap_should_client_block(r)) { |
985 |
apr_status_t rv; |
986 |
char *buffer = apr_palloc(r->pool, DAV_READ_BLOCKSIZE); |
986 |
apr_bucket_brigade *bb; |
987 |
long len; |
987 |
apr_bucket *b; |
|
|
988 |
const char *buf; |
989 |
apr_ssize_t len; |
988 |
|
990 |
|
|
|
991 |
bb = apr_brigade_create(r->pool, r->connection->bucket_alloc); |
992 |
if (bb == NULL) { |
993 |
err = dav_new_error(r->pool, HTTP_INTERNAL_SERVER_ERROR, 0, |
994 |
"Could not create brigade."); |
995 |
goto done; |
996 |
} |
997 |
for (;;) { |
998 |
rv = ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES, |
999 |
APR_BLOCK_READ, DAV_READ_BLOCKSIZE); |
1000 |
if (rv != APR_SUCCESS) { |
1001 |
err = dav_new_error(r->pool, HTTP_INTERNAL_SERVER_ERROR, 0, |
1002 |
"Could not get brigade."); |
1003 |
goto done; |
1004 |
} |
989 |
/* |
1005 |
/* |
990 |
* Once we start reading the request, then we must read the |
1006 |
* Once we start reading the request, then we must read the |
991 |
* whole darn thing. ap_discard_request_body() won't do anything |
1007 |
* whole darn thing. ap_discard_request_body() won't do anything |
992 |
* for a partially-read request. |
1008 |
* for a partially-read request. |
993 |
*/ |
1009 |
*/ |
994 |
|
1010 |
APR_BRIGADE_FOREACH(b, bb) { |
995 |
while ((len = ap_get_client_block(r, buffer, |
1011 |
if (APR_BUCKET_IS_EOS(b)) |
996 |
DAV_READ_BLOCKSIZE)) > 0) { |
1012 |
goto done; |
997 |
if (err == NULL) { |
1013 |
if ((rv = apr_bucket_read(b, (const char **)&buf, &len, |
998 |
/* write whatever we read, until we see an error */ |
1014 |
APR_BLOCK_READ)) != APR_SUCCESS && |
999 |
err = (*resource->hooks->write_stream)(stream, |
1015 |
err == NULL) |
1000 |
buffer, len); |
1016 |
err = dav_new_error(r->pool, HTTP_BAD_REQUEST, 0, |
1001 |
} |
1017 |
"An error occurred while reading the " |
1002 |
} |
1018 |
"request body."); |
1003 |
|
1019 |
if (err == NULL) |
1004 |
/* |
1020 |
/* write whatever we read, until we see an error */ |
1005 |
* ### what happens if we read more/less than the amount |
1021 |
err = (*resource->hooks->write_stream)(stream, |
1006 |
* ### specified in the Content-Range? eek... |
1022 |
buf, len); |
1007 |
*/ |
1023 |
} |
1008 |
|
|
|
1009 |
if (len == -1) { |
1010 |
/* |
1011 |
* Error reading request body. This has precedence over |
1012 |
* prior errors. |
1013 |
*/ |
1014 |
err = dav_new_error(r->pool, HTTP_BAD_REQUEST, 0, |
1015 |
"An error occurred while reading the " |
1016 |
"request body."); |
1017 |
} |
1018 |
} |
1024 |
} |
1019 |
|
1025 |
done: |
|
|
1026 |
if (bb != NULL) |
1027 |
apr_brigade_destroy(bb); |
1020 |
err2 = (*resource->hooks->close_stream)(stream, |
1028 |
err2 = (*resource->hooks->close_stream)(stream, |
1021 |
err == NULL /* commit */); |
1029 |
err == NULL /* commit */); |
1022 |
if (err2 != NULL && err == NULL) { |
1030 |
if (err2 != NULL && err == NULL) { |