Ignore:
Timestamp:
Aug 6, 2008, 12:24:05 AM (15 years ago)
Author:
charles
Message:

#1129 alternate fix: / should redirect to, not replace, /transmission/web

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/rpc-server.c

    r6428 r6430  
    235235        pruneBuf( s, cbuf );
    236236    }
     237}
     238
     239static void
     240handle_root( struct shttpd_arg * arg )
     241{
     242    const char * redirect = "HTTP/1.1 200 OK""\r\n"
     243                            "Content-Type: text/html" "\r\n"
     244                            "\r\n"
     245                            "<html><head>" "\r\n"
     246                            "  <meta http-equiv=\"Refresh\" content=\"2; url=/transmission/web\">" "\r\n"
     247                            "</head><body>" "\r\n"
     248                            "  <p>redirecting to <a href=\"/transmission/web\">/transmission/web</a></p>" "\r\n"
     249                            "</body></html>" "\r\n";
     250    const size_t n = strlen( redirect );
     251    memcpy( arg->out.buf, redirect, n );
     252    arg->in.num_bytes = arg->in.len;
     253    arg->out.num_bytes = n;
     254    arg->flags |= SHTTPD_END_OF_OUTPUT;
    237255}
    238256
     
    366384        {
    367385            tr_inf( _( "Serving the web interface files from \"%s\"" ), clutchDir );
    368             argv[argc++] = tr_strdup( "-root" );
    369             argv[argc++] = tr_strdup( clutchDir );
     386            argv[argc++] = tr_strdup( "-aliases" );
     387            argv[argc++] = tr_strdup_printf( "%s=%s,%s=%s",
     388                                             "/transmission/clutch", clutchDir,
     389                                             "/transmission/web", clutchDir );
    370390        }
    371391
     
    375395        shttpd_register_uri( server->ctx, "/transmission/rpc", handle_rpc, server );
    376396        shttpd_register_uri( server->ctx, "/transmission/upload", handle_upload, server );
     397        shttpd_register_uri( server->ctx, "/", handle_root, server );
    377398
    378399        evtimer_set( &server->timer, rpcPulse, server );
Note: See TracChangeset for help on using the changeset viewer.