mirror of
https://github.com/transmission/transmission
synced 2025-02-03 21:12:05 +00:00
#1129 alternate fix: / should redirect to, not replace, /transmission/web
This commit is contained in:
parent
74dd613895
commit
b068dc07a6
1 changed files with 23 additions and 2 deletions
|
@ -236,6 +236,24 @@ handle_upload( struct shttpd_arg * arg )
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
handle_root( struct shttpd_arg * arg )
|
||||
{
|
||||
const char * redirect = "HTTP/1.1 200 OK""\r\n"
|
||||
"Content-Type: text/html" "\r\n"
|
||||
"\r\n"
|
||||
"<html><head>" "\r\n"
|
||||
" <meta http-equiv=\"Refresh\" content=\"2; url=/transmission/web\">" "\r\n"
|
||||
"</head><body>" "\r\n"
|
||||
" <p>redirecting to <a href=\"/transmission/web\">/transmission/web</a></p>" "\r\n"
|
||||
"</body></html>" "\r\n";
|
||||
const size_t n = strlen( redirect );
|
||||
memcpy( arg->out.buf, redirect, n );
|
||||
arg->in.num_bytes = arg->in.len;
|
||||
arg->out.num_bytes = n;
|
||||
arg->flags |= SHTTPD_END_OF_OUTPUT;
|
||||
}
|
||||
|
||||
static void
|
||||
handle_rpc( struct shttpd_arg * arg )
|
||||
{
|
||||
|
@ -365,8 +383,10 @@ startServer( tr_rpc_server * server )
|
|||
if( clutchDir && *clutchDir )
|
||||
{
|
||||
tr_inf( _( "Serving the web interface files from \"%s\"" ), clutchDir );
|
||||
argv[argc++] = tr_strdup( "-root" );
|
||||
argv[argc++] = tr_strdup( clutchDir );
|
||||
argv[argc++] = tr_strdup( "-aliases" );
|
||||
argv[argc++] = tr_strdup_printf( "%s=%s,%s=%s",
|
||||
"/transmission/clutch", clutchDir,
|
||||
"/transmission/web", clutchDir );
|
||||
}
|
||||
|
||||
argv[argc] = NULL; /* shttpd_init() wants it null-terminated */
|
||||
|
@ -374,6 +394,7 @@ startServer( tr_rpc_server * server )
|
|||
server->ctx = shttpd_init( argc, argv );
|
||||
shttpd_register_uri( server->ctx, "/transmission/rpc", handle_rpc, server );
|
||||
shttpd_register_uri( server->ctx, "/transmission/upload", handle_upload, server );
|
||||
shttpd_register_uri( server->ctx, "/", handle_root, server );
|
||||
|
||||
evtimer_set( &server->timer, rpcPulse, server );
|
||||
evtimer_add( &server->timer, &tv );
|
||||
|
|
Loading…
Reference in a new issue