View | Details | Raw Unified | Return to bug 22104
Collapse All | Expand All

(-)modules/dav/main/mod_dav.c (-38 / +55 lines)
Lines 896-902 Link Here
896
    const char *body;
896
    const char *body;
897
    dav_error *err;
897
    dav_error *err;
898
    dav_error *err2;
898
    dav_error *err2;
899
    int result;
900
    dav_stream_mode mode;
899
    dav_stream_mode mode;
901
    dav_stream *stream;
900
    dav_stream *stream;
902
    dav_response *multi_response;
901
    dav_response *multi_response;
Lines 904-913 Link Here
904
    apr_off_t range_start;
903
    apr_off_t range_start;
905
    apr_off_t range_end;
904
    apr_off_t range_end;
906
905
907
    if ((result = ap_setup_client_block(r, REQUEST_CHUNKED_DECHUNK)) != OK) {
908
        return result;
909
    }
910
911
    /* Ask repository module to resolve the resource */
906
    /* Ask repository module to resolve the resource */
912
    err = dav_get_resource(r, 0 /* label_allowed */, 0 /* use_checked_in */,
907
    err = dav_get_resource(r, 0 /* label_allowed */, 0 /* use_checked_in */,
913
                           &resource);
908
                           &resource);
Lines 982-1020 Link Here
982
    }
977
    }
983
978
984
    if (err == NULL) {
979
    if (err == NULL) {
985
        if (ap_should_client_block(r)) {
980
        apr_bucket_brigade *bb;
986
            char *buffer = apr_palloc(r->pool, DAV_READ_BLOCKSIZE);
981
        apr_bucket *b;
987
            long len;
982
        int seen_eos = 0;
988
983
989
            /*
984
        bb = apr_brigade_create(r->pool, r->connection->bucket_alloc);
990
             * Once we start reading the request, then we must read the
985
991
             * whole darn thing. ap_discard_request_body() won't do anything
986
        if (!bb) {
992
             * for a partially-read request.
987
            err = dav_new_error(r->pool, HTTP_INTERNAL_SERVER_ERROR, 0,
993
             */
988
                                "Could not create bucket brigade");
994
989
        }
995
            while ((len = ap_get_client_block(r, buffer,
990
        else {
996
                                              DAV_READ_BLOCKSIZE)) > 0) {
991
            do {
997
                   if (err == NULL) {
992
                apr_status_t rc;
998
                       /* write whatever we read, until we see an error */
993
999
                       err = (*resource->hooks->write_stream)(stream,
994
                rc = ap_get_brigade(r->input_filters, bb, AP_MODE_READBYTES,
1000
                                                              buffer, len);
995
                                    APR_BLOCK_READ, DAV_READ_BLOCKSIZE);
1001
                   }
996
1002
            }
997
                if (rc != APR_SUCCESS) {
1003
998
                    err = dav_new_error(r->pool, HTTP_INTERNAL_SERVER_ERROR, 0,
1004
            /*
999
                                        "Could not get next bucket brigade");
1005
             * ### what happens if we read more/less than the amount
1000
                    break;
1006
             * ### specified in the Content-Range? eek...
1001
                }
1007
             */
1002
1008
1003
                APR_BRIGADE_FOREACH(b, bb) {
1009
            if (len == -1) {
1004
                    const char *data;
1010
                /*
1005
                    apr_size_t len;
1011
                 * Error reading request body. This has precedence over
1006
1012
                 * prior errors.
1007
                    if (APR_BUCKET_IS_EOS(b)) {
1013
                 */
1008
                        seen_eos = 1;
1014
                err = dav_new_error(r->pool, HTTP_BAD_REQUEST, 0,
1009
                        break;
1015
                                    "An error occurred while reading the "
1010
                    }
1016
                                    "request body.");
1011
1017
            }
1012
                    if (APR_BUCKET_IS_METADATA(b)) {
1013
                        continue;
1014
                    }
1015
1016
                    rc = apr_bucket_read(b, &data, &len, APR_BLOCK_READ);
1017
                    if (rc != APR_SUCCESS) {
1018
                        err = dav_new_error(r->pool, HTTP_BAD_REQUEST, 0,
1019
                                            "An error occurred while reading "
1020
                                            "the request body.");
1021
                        break;
1022
                    }
1023
1024
                    if (err == NULL) {
1025
                        /* write whatever we read, until we see an error */
1026
                        err = (*resource->hooks->write_stream)(stream, data,
1027
                                                               len);
1028
                    }
1029
                }
1030
1031
                apr_brigade_cleanup(bb);
1032
            } while (!seen_eos);
1033
1034
            apr_brigade_destroy(bb);
1018
        }
1035
        }
1019
1036
1020
        err2 = (*resource->hooks->close_stream)(stream,
1037
        err2 = (*resource->hooks->close_stream)(stream,

Return to bug 22104