mod_xsendfile icon indicating copy to clipboard operation
mod_xsendfile copied to clipboard

Correction of 'XSendFilePath' configuration behavior.

Open alexsilva opened this issue 4 years ago • 0 comments

XSendFileRootPath - I created a new configuration that allows you to change the root path (this is important for non-standard installations).

As the test environment was windows I added the file 'CMakeLists.txt' to work with clion + cmake + vc17 with apache2 lounge.

The main fix is the behavior of the 'XSendFilePath' configuration that was not in accordance with the documentation.

Config:

Root: /var/www XSendFilePath: /tmp/videos

Given a relative file via header for the module, for example 'file.mp4', the result was always the directory /var/www/file.mp4. XSendFile Path was being ignored because the existence of the file in the root directory was not verified.

The code snippet below solves the problem because if the file does not exist in the root directory, it will be checked in the next directory that is XSendFile.

        // The path is only valid if it exists.
        // If it doesn't continue until you find a valid path on the white-list.
        apr_finfo_t info;
        rv = apr_stat(&info, *path, APR_FINFO_CSIZE, r->pool);
        if (rv == OK) {
            break;
        } else {
            continue;
        }
    }

alexsilva avatar May 14 '20 22:05 alexsilva