mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 21:17:03 +00:00
33 lines
1007 B
Objective-C
33 lines
1007 B
Objective-C
//
|
|
// AppController+WebResourceLoadDelegate.m
|
|
// NativeHost
|
|
//
|
|
// Created by Francisco Tolmasky on 7/28/09.
|
|
// Copyright 2009 280 North, Inc.. All rights reserved.
|
|
//
|
|
|
|
#import "AppController.h"
|
|
#import "SSCrypto.h"
|
|
|
|
NSString *authHeader = nil;
|
|
|
|
@implementation AppController (WebResourceLoadDelegate)
|
|
|
|
- (NSURLRequest *)webView:(WebView *)aSender resource:(id)anIdentifier willSendRequest:(NSURLRequest *)aRequest redirectResponse:(NSURLResponse *)aRedirectResponse fromDataSource:(WebDataSource *)aDataSource
|
|
{
|
|
aRequest = [[aRequest mutableCopy] autorelease];
|
|
|
|
if (!authHeader)
|
|
{
|
|
NSString *plaintext = [NSString stringWithFormat:@"%@:%@", SERVER_USER, SERVER_PASSWORD];
|
|
NSData *data = [plaintext dataUsingEncoding:NSASCIIStringEncoding];
|
|
authHeader = [[NSString alloc] initWithFormat:@"Basic %@", [data encodeBase64WithNewlines:NO]];
|
|
}
|
|
|
|
[(NSMutableURLRequest *)aRequest setValue:authHeader forHTTPHeaderField:@"Authorization"];
|
|
|
|
return aRequest;
|
|
}
|
|
|
|
@end
|