Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Replicator now proactively sends auth credentials on every request.

I think this will fix the remaining Cloudant errors (timeout / socket-closed errors pushing large docs).
Speculatively fixes #185.
  • Loading branch information...
commit f56210b0b190f93ed93f528ee0151d73a387111d 1 parent 2658f99
@snej snej authored
View
4 Source/TDAuthorizer.h
@@ -34,6 +34,10 @@
/** Initialize given a credential object that contains a username and password. */
- (id) initWithCredential: (NSURLCredential*)credential;
+/** Initialize given a URL alone -- will use a baked-in username/password in the URL,
+ or look up a credential from the keychain. */
+- (id)initWithURL: (NSURL*)url;
+
@end
View
11 Source/TDAuthorizer.m
@@ -31,6 +31,17 @@ - (id) initWithCredential: (NSURLCredential*)credential {
}
+- (id)initWithURL: (NSURL*)url
+{
+ Log(@"TDBasicAuthorizer initWith <%@>", url);//TEMP
+ NSURLCredential *cred = [url my_credentialForRealm: nil
+ authenticationMethod: NSURLAuthenticationMethodHTTPBasic];
+ if (!cred)
+ return nil;
+ return [self initWithCredential: cred];
+}
+
+
- (NSString*) authorizeURLRequest: (NSMutableURLRequest*)request
forRealm: (NSString*)realm
{
View
2  Source/TDRemoteRequest.m
@@ -213,7 +213,7 @@ - (void)connection:(NSURLConnection *)connection
LogTo(RemoteRequest, @"Got challenge: %@ (%@)", challenge, authMethod);
if ($equal(authMethod, NSURLAuthenticationMethodHTTPBasic)) {
_challenged = true;
- if (challenge.previousFailureCount == 0) {
+ if (!_authorizer && challenge.previousFailureCount == 0) {
NSURLCredential* cred = [_request.URL my_credentialForRealm: space.realm
authenticationMethod: authMethod];
if (cred) {
View
4 Source/TDReplicator.m
@@ -215,6 +215,10 @@ - (void) start {
}
];
+ // If client didn't set an authorizer, use basic auth if credential is available:
+ if (!_authorizer)
+ _authorizer = [[TDBasicAuthorizer alloc] initWithURL: _remote];
+
self.running = YES;
_startTime = CFAbsoluteTimeGetCurrent();
Please sign in to comment.
Something went wrong with that request. Please try again.