示例#1
0
static Dir *getDirObj(MaState *state)
{
    HttpRoute   *route;
    Dir         *dir, *parent;

    route = state->route;
    dir = httpGetRouteData(route, DIR_NAME);
    if (route->parent) {
        /*
            If the parent route has the same route data, then force a clone so the parent route does not get modified
         */ 
        parent = httpGetRouteData(route->parent, DIR_NAME);
        if (dir == parent) {
            dir = 0;
        }
    }
    if (dir == 0) {
        if (route->parent && (parent = httpGetRouteData(route->parent, DIR_NAME)) != 0) {
            dir = cloneDir(parent, route);
        } else {
            dir = allocDir(route);
        }
    }
    assert(dir);
    return dir;
}
示例#2
0
/*
    Test if this request is for a directory listing. This routine is called directly by the fileHandler.
    Directory listings are enabled in a route via "Options Indexes".
 */
PUBLIC bool maRenderDirListing(HttpConn *conn)
{
    HttpRx      *rx;
    HttpTx      *tx;
    Dir         *dir;

    tx = conn->tx;
    rx = conn->rx;
    assert(tx->filename);
    assert(tx->fileInfo.checked);

    if ((dir = httpGetRouteData(rx->route, DIR_NAME)) == 0) {
        return 0;
    }
    if (dir->enabled && tx->fileInfo.isDir && sends(rx->pathInfo, "/")) {
        conn->data = dir;
        return 1;
    }
    return 0;
}
示例#3
0
/*
    Match if the filename maps to a directory and directory listings are enabled via "Options Indexes"
 */
int maMatchDir(HttpConn *conn, HttpRoute *route, int direction)
{
    HttpRx      *rx;
    HttpTx      *tx;
    Dir         *dir;

    tx = conn->tx;
    rx = conn->rx;
    mprAssert(tx->filename);
    mprAssert(tx->fileInfo.checked);

    if (direction & HTTP_STAGE_TX) {
        if ((dir = httpGetRouteData(rx->route, DIR_NAME)) == 0) {
            return HTTP_ROUTE_REJECT;
        }
        if (dir->enabled && tx->fileInfo.isDir && sends(rx->pathInfo, "/")) {
            conn->data = dir;
            return HTTP_ROUTE_OK;
        }
    }
    return HTTP_ROUTE_REJECT;
}