iOS web browser with a focus on security and privacy
1/*
2 * Endless
3 * Copyright (c) 2014-2015 joshua stein <jcs@jcs.org>
4 *
5 * Originally created by Mike Abdullah on 17/03/2009.
6 * Copyright 2009 Karelia Software. All rights reserved.
7 *
8 * Originally from ConnectionKit 2.0 branch; source at:
9 * http://www.opensource.utr-software.com/source/connection/branches/2.0/CKHTTPConnection.m
10 * (CKHTTPConnection.m last updated rev 1242, 2009-06-16 09:40:21 -0700, by mabdullah)
11 *
12 * Under Modified BSD License, as per description at
13 * http://www.opensource.utr-software.com/
14 */
15
16#import <Foundation/Foundation.h>
17#import "SSLCertificate.h"
18
19@protocol CKHTTPConnectionDelegate;
20
21@class CKHTTPAuthenticationChallenge;
22
23@interface CKHTTPConnection : NSObject
24{
25 @private
26 __weak id <CKHTTPConnectionDelegate> _delegate;
27
28 CFHTTPMessageRef _HTTPRequest;
29 NSInputStream *_HTTPStream;
30 NSInputStream *_HTTPBodyStream;
31 BOOL _haveReceivedResponse;
32 CKHTTPAuthenticationChallenge *_authenticationChallenge;
33 NSInteger _authenticationAttempts;
34
35 BOOL socketReady;
36 BOOL retriedSocket;
37}
38
39+ (CKHTTPConnection *)connectionWithRequest:(NSURLRequest *)request delegate:(id <CKHTTPConnectionDelegate>)delegate;
40- (id)initWithRequest:(NSURLRequest *)request delegate:(id <CKHTTPConnectionDelegate>)delegate;
41- (void)cancel;
42
43@end
44
45
46@protocol CKHTTPConnectionDelegate
47
48- (void)HTTPConnection:(CKHTTPConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
49- (void)HTTPConnection:(CKHTTPConnection *)connection didReceiveAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
50- (void)HTTPConnection:(CKHTTPConnection *)connection didCancelAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;
51
52- (void)HTTPConnection:(CKHTTPConnection *)connection didReceiveResponse:(NSHTTPURLResponse *)response;
53- (void)HTTPConnection:(CKHTTPConnection *)connection didReceiveData:(NSData *)data;
54
55- (void)HTTPConnection:(CKHTTPConnection *)connection didReceiveSecTrust:(SecTrustRef)secTrustRef certificate:(SSLCertificate *)certificate;
56
57- (void)HTTPConnectionDidFinishLoading:(CKHTTPConnection *)connection;
58- (void)HTTPConnection:(CKHTTPConnection *)connection didFailWithError:(NSError *)error;
59
60@end
61
62
63@interface NSURLRequest (CKHTTPURLRequest)
64- (CFHTTPMessageRef)makeHTTPMessage;
65@end