Changeset 3700

Show
Ignore:
Timestamp:
07/07/07 11:42:50 (1 year ago)
Author:
timothy
Message:

Return 403 errors in places where we failed silently with a 200 status code before.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/Plug-Ins/Web Interface/JVWebInterfacePlugin.m

    r3699 r3700  
    365365 
    366366        http_req_t *req = [[arguments objectForKey:JVWebInterfaceRequest] pointerValue]; 
    367         if( ! req || ! req->content ) return; 
     367        if( ! req || ! req->content ) { 
     368                resp -> status_code = 500; 
     369                resp -> reason_phrase = "Insufficient Information"; 
     370                return; 
     371        } 
    368372 
    369373        NSString *identifier = [arguments objectForKey:JVWebInterfaceClientIdentifier]; 
     
    396400 
    397401        if( passwordMatches ) { 
    398                 if( rememberMe ) 
    399                         resp -> add_cookie( resp, (char *)[[NSString stringWithFormat:@"identifier=%@; path=/; expires=Wed, 1 Jan 2014 23:59:59 UTC", identifier] UTF8String] ); 
    400                 else 
    401                         resp -> add_cookie( resp, (char *)[[NSString stringWithFormat:@"identifier=%@; path=/", identifier] UTF8String] ); 
     402                @synchronized( _clients ) { 
     403                        [_clients setObject:[NSMutableDictionary dictionary] forKey:identifier]; 
     404                } 
     405 
     406                if( rememberMe ) resp -> add_cookie( resp, (char *)[[NSString stringWithFormat:@"identifier=%@; path=/; expires=Wed, 1 Jan 2014 23:59:59 UTC", identifier] UTF8String] ); 
     407                else resp -> add_cookie( resp, (char *)[[NSString stringWithFormat:@"identifier=%@; path=/", identifier] UTF8String] ); 
     408 
    402409                resp -> content_type = "text/plain"; 
    403410                resp -> write( resp, "authenticated", 13 ); 
     
    409416        if( ! resp ) return; 
    410417 
    411         NSMutableDictionary *info = [NSMutableDictionary dictionary]; 
    412418        NSString *identifier = [arguments objectForKey:JVWebInterfaceClientIdentifier]; 
    413         if( ! identifier ) return; 
    414  
    415         NSXMLDocument *doc = [NSXMLDocument documentWithRootElement:[NSXMLElement elementWithName:@"queue"]]; 
    416         [info setObject:doc forKey:@"activityQueue"]; 
    417  
    418         NSMutableDictionary *styles = [NSMutableDictionary dictionary]; 
    419         [info setObject:styles forKey:@"styles"]; 
    420  
    421         NSString *overrideStyle = [arguments objectForKey:JVWebInterfaceOverrideStyle]; 
    422         if( [overrideStyle length] ) 
    423                 [info setObject:overrideStyle forKey:@"overrideStyle"]; 
    424  
    425         doc = [NSXMLDocument documentWithRootElement:[NSXMLElement elementWithName:@"setup"]]; 
     419        if( ! identifier ) { 
     420                resp -> status_code = 403; 
     421                resp -> reason_phrase = "Access Forbidden"; 
     422                return; 
     423        } 
     424 
     425        @synchronized( _clients ) { 
     426                NSMutableDictionary *info = [_clients objectForKey:identifier]; 
     427                if( ! info ) { 
     428                        resp -> status_code = 403; 
     429                        resp -> reason_phrase = "Access Forbidden"; 
     430                        return; 
     431                } 
     432 
     433                // reset everything 
     434                [info removeAllObjects]; 
     435 
     436                NSXMLDocument *doc = [NSXMLDocument documentWithRootElement:[NSXMLElement elementWithName:@"queue"]]; 
     437                [info setObject:doc forKey:@"activityQueue"]; 
     438         
     439                NSMutableDictionary *styles = [NSMutableDictionary dictionary]; 
     440                [info setObject:styles forKey:@"styles"]; 
     441         
     442                NSString *overrideStyle = [arguments objectForKey:JVWebInterfaceOverrideStyle]; 
     443                if( [overrideStyle length] ) 
     444                        [info setObject:overrideStyle forKey:@"overrideStyle"]; 
     445        } 
     446 
     447        NSXMLDocument *doc = [NSXMLDocument documentWithRootElement:[NSXMLElement elementWithName:@"setup"]]; 
    426448        NSXMLElement *node = [NSXMLElement elementWithName:@"panels"]; 
    427449        [[doc rootElement] addChild:node]; 
     
    453475        } 
    454476 
    455         @synchronized( _clients ) { 
    456                 [_clients setObject:info forKey:identifier]; 
    457         } 
    458  
    459477        resp -> content_type = "text/xml"; 
    460478 
     
    472490        @synchronized( _clients ) { 
    473491                NSDictionary *info = [_clients objectForKey:identifier]; 
    474                 if( ! info ) return; 
     492                if( ! info ) { 
     493                        resp -> status_code = 403; 
     494                        resp -> reason_phrase = "Access Forbidden"; 
     495                        return; 
     496                } 
    475497 
    476498                JVDirectChatPanel *panel = [self panelForIdentifier:[arguments objectForKey:@"panel"]]; 
     
    503525 
    504526        NSString *identifier = [arguments objectForKey:JVWebInterfaceClientIdentifier]; 
    505         if( ! identifier ) return; 
     527        if( ! identifier ) { 
     528                resp -> status_code = 403; 
     529                resp -> reason_phrase = "Access Forbidden"; 
     530                return; 
     531        } 
    506532 
    507533        @synchronized( _clients ) { 
     
    515541 
    516542        NSString *identifier = [arguments objectForKey:JVWebInterfaceClientIdentifier]; 
    517         if( ! identifier ) return; 
     543        if( ! identifier ) { 
     544                resp -> status_code = 403; 
     545                resp -> reason_phrase = "Access Forbidden"; 
     546                return; 
     547        } 
     548 
     549        @synchronized( _clients ) { 
     550                NSDictionary *info = [_clients objectForKey:identifier]; 
     551                if( ! info ) { 
     552                        resp -> status_code = 403; 
     553                        resp -> reason_phrase = "Access Forbidden"; 
     554                        return; 
     555                } 
     556        } 
    518557 
    519558        JVDirectChatPanel *panel = [self panelForIdentifier:[arguments objectForKey:@"panel"]]; 
     
    560599 
    561600        NSString *identifier = [arguments objectForKey:JVWebInterfaceClientIdentifier]; 
    562         if( ! identifier ) return; 
     601        if( ! identifier ) { 
     602                resp -> status_code = 403; 
     603                resp -> reason_phrase = "Access Forbidden"; 
     604                return; 
     605        } 
    563606 
    564607        @synchronized( _clients ) { 
    565608                NSDictionary *info = [_clients objectForKey:identifier]; 
    566                 if( ! info ) return; 
     609                if( ! info ) { 
     610                        resp -> status_code = 403; 
     611                        resp -> reason_phrase = "Access Forbidden"; 
     612                        return; 
     613                } 
    567614 
    568615                NSXMLDocument *doc = [info objectForKey:@"activityQueue"]; 
  • trunk/Plug-Ins/Web Interface/nanohttpd/http_resp.c

    r3552 r3700  
    124124        http_resp_send_headers( me ); 
    125125 
    126         me -> netbuf -> printf( me -> netbuf, "The document can be found here: <a href = \"%s\">%s</a>", location, location ); 
     126        me -> netbuf -> printf( me -> netbuf, "The document can be found here: <a href=\"%s\">%s</a>", location, location ); 
    127127 
    128128        return 0;