forked from GetiPlayerAutomator/get-iplayer-automator
-
Notifications
You must be signed in to change notification settings - Fork 26
/
HTTPProxy.m
34 lines (29 loc) · 903 Bytes
/
HTTPProxy.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
// HTTPProxy.m
// Get_iPlayer GUI
//
#import "HTTPProxy.h"
@implementation HTTPProxy
- (instancetype)initWithURL:(NSURL *)aURL
{
if (self = [super init]) {
_url = [aURL copy];
if ([_url.scheme.lowercaseString isEqualToString:@"https"])
_type = (NSString *)kCFProxyTypeHTTPS;
else
_type = (NSString *)kCFProxyTypeHTTP;
_host = [_url.host copy];
_port = _url.port.integerValue;
_user = [_url.user copy];
_password = [_url.password copy];
}
return self;
}
- (instancetype)initWithString:(NSString *)aString
{
if ([aString.lowercaseString hasPrefix:@"http://"] || [aString.lowercaseString hasPrefix:@"https://"])
return [self initWithURL:[NSURL URLWithString:aString]];
else
return [self initWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"http://%@", aString]]];
}
@end