Changeset 6861


Ignore:
Timestamp:
Oct 7, 2008, 1:25:29 AM (13 years ago)
Author:
charles
Message:

(rpc) if libt can't find the Clutch files, give a helpful 404 message for end-users and binary packagers about how to use CLUTCH_HOME and PACKAGE_DATA_DIR.

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/platform.c

    r6795 r6861  
    611611        }
    612612
    613         if( !*path )
    614         {
    615             tr_strlcpy( path, "/dev/null", sizeof( path ) );
    616             tr_err( _(
    617                        "Couldn't find the web interface's files!  To customize this, set the CLUTCH_HOME environmental variable to the folder where index.html is located." ) );
    618         }
    619 
    620613        s = tr_strdup( path );
    621614    }
  • trunk/libtransmission/rpc-server.c

    r6856 r6861  
    7171    evbuffer_add_printf( body, "<h1>%d: %s</h1>", code, code_text );
    7272    if( text )
    73         evbuffer_add_printf( body, "<h2>%s</h2>", text );
     73        evbuffer_add_printf( body, "%s", text );
    7474    evhttp_send_reply( req, code, code_text, body );
    7575    evbuffer_free( body );
     
    321321               struct tr_rpc_server *  server )
    322322{
    323     char * pch;
    324     char * subpath;
    325     char * filename;
    326323    const char * clutchDir = tr_getClutchDir( server->session );
    327324
    328325    assert( !strncmp( req->uri, "/transmission/web/", 18 ) );
    329326
    330     subpath = tr_strdup( req->uri + 18 );
    331     if(( pch = strchr( subpath, '?' )))
    332         *pch = '\0';
    333 
    334     filename = *subpath
    335         ? tr_strdup_printf( "%s%s%s", clutchDir, TR_PATH_DELIMITER_STR, subpath )
    336         : tr_strdup_printf( "%s%s%s", clutchDir, TR_PATH_DELIMITER_STR, "index.html" );
    337 
    338     serve_file( req, filename );
    339 
    340     tr_free( filename );
    341     tr_free( subpath );
     327    if( !clutchDir || !*clutchDir )
     328    {
     329        send_simple_response( req, HTTP_NOTFOUND,
     330            "<p>Couldn't find Transmission's web interface files!</p>"
     331            "<p>Users: to tell Transmission where to look, "
     332            "set the TRANSMISSION_WEB_HOME environmental "
     333            "variable to the folder where the web interface's "
     334            "index.html is located.</p>"
     335            "<p>Package Builders: to set a custom default at compile time, "
     336            "#define PACKAGE_DATA_DIR in libtransmission/platform.c "
     337            "or tweak tr_getClutchDir() by hand.</p>" );
     338    }
     339    else
     340    {
     341        char * pch;
     342        char * subpath;
     343        char * filename;
     344
     345        subpath = tr_strdup( req->uri + 18 );
     346        if(( pch = strchr( subpath, '?' )))
     347            *pch = '\0';
     348
     349        filename = *subpath
     350            ? tr_strdup_printf( "%s%s%s", clutchDir, TR_PATH_DELIMITER_STR, subpath )
     351            : tr_strdup_printf( "%s%s%s", clutchDir, TR_PATH_DELIMITER_STR, "index.html" );
     352
     353        serve_file( req, filename );
     354
     355        tr_free( filename );
     356        tr_free( subpath );
     357    }
    342358}
    343359
Note: See TracChangeset for help on using the changeset viewer.