Changeset 9705


Ignore:
Timestamp:
Dec 10, 2009, 9:13:08 AM (12 years ago)
Author:
charles
Message:

(trunk libT) fix errors in tr_httpParseURL()

Location:
trunk/libtransmission
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/utils-test.c

    r9696 r9705  
    320320}
    321321
     322static int
     323test_url( void )
     324{
     325    int port;
     326    char * host;
     327    char * path;
     328    const char * url;
     329
     330    url = "http://www.some-tracker.org/some/path";
     331    check( !tr_httpParseURL( url, -1, &host, &port, &path ) )
     332    check( !strcmp( host, "www.some-tracker.org" ) )
     333    check( !strcmp( path, "/some/path" ) )
     334    check( port == 80 )
     335
     336    url = "http://www.some-tracker.org:80/some/path";
     337    check( !tr_httpParseURL( url, -1, &host, &port, &path ) )
     338    check( !strcmp( host, "www.some-tracker.org" ) )
     339    check( !strcmp( path, "/some/path" ) )
     340    check( port == 80 )
     341
     342
     343    return 0;
     344}
     345
    322346int
    323347main( void )
     
    366390    if( ( i = test_array( ) ) )
    367391        return i;
     392    if( ( i = test_url( ) ) )
     393        return i;
    368394
    369395    /* test that tr_cryptoRandInt() stays in-bounds */
  • trunk/libtransmission/utils.c

    r9696 r9705  
    985985        protocol = tmp;
    986986        pch += 3;
    987 /*fprintf( stderr, "protocol is [%s]... what's left is [%s]\n", protocol, pch
    988   );*/
     987/*fprintf( stderr, "protocol is [%s]... what's left is [%s]\n", protocol, pch);*/
    989988        if( ( n = strcspn( pch, ":/" ) ) )
    990989        {
     
    10181017    {
    10191018        if( setme_host ){ ( (char*)host )[-3] = ':'; *setme_host =
    1020                               tr_strdup( protocol ); }
    1021         if( setme_path ){ ( (char*)path )[-1] = '/'; *setme_path =
    1022                               tr_strdup( path - 1 ); }
     1019                              tr_strdup( host ); }
     1020        if( setme_path ){ if( path[0] == '/' ) *setme_path = tr_strdup( path );
     1021                          else { ( (char*)path )[-1] = '/'; *setme_path = tr_strdup( path - 1 ); } }
    10231022        if( setme_port ) *setme_port = port;
    10241023    }
Note: See TracChangeset for help on using the changeset viewer.