updates: should really return 401 for bad auth instead of 404
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
|
||||
#import <Security/Security.h>
|
||||
#import "HTTPMessage.h"
|
||||
#import "GCDAsyncSocket.h"
|
||||
|
||||
@interface HTTPConnection (/* INTERNAL */)
|
||||
- (BOOL)isAuthenticated;
|
||||
@@ -139,6 +140,14 @@
|
||||
if (![self isAuthenticated] && ![queryAuthToken isValid]) {
|
||||
NSLog(@"Websocket: auth invalid, rejecting.");
|
||||
NSLog(@"Query Token: %@, raw: %@", queryAuthToken, authTokenString);
|
||||
|
||||
|
||||
// Respond with 401 unauthorized
|
||||
HTTPMessage *response = [[HTTPMessage alloc] initResponseWithStatusCode:401 description:nil version:HTTPVersion1_1];
|
||||
[response setHeaderField:@"Content-Length" value:@"0"];
|
||||
|
||||
NSData *responseData = [self preprocessErrorResponse:response];
|
||||
[asyncSocket writeData:responseData withTimeout:30 tag:90];
|
||||
return nil;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user