For some reason SecureTransport doesn't do wildcard matching of hostnames in SSL certs (e.g. "*.iriscouch.com") so in the prior commit I had to turn off hostname matching. But that's unsafe. So in this commit I enable matching by doing the work myself. After the connection opens, read the common-name out of the server's cert and compare it against the intended hostname, obeying wildcards. I had to bring in some source files from my MYCrypto library that do X.509 cert parsing, since iOS doesn't have SecCertificateCopyCommonName.
Disable TLS 1.2 in TDSocketChangeTracker because some servers are incompatible with it. Fixes #75.
TDSocketChangeTracker wasn't getting any Authorization header value to put in the request. Added API to TDPuller, and made it look up the credential from the default credential store. If a username/password has been added for this domain in the Keychain, it'll be used. This partly takes care of #58, although it doesn't include lenkawell's proposed support for using a username/password baked into the URL. I'll add that later.
(Yeah, I already did this, but for some reason it wasn't recorded as a merge!) Conflicts: Source/ChangeTracker/TDChangeTracker.m Source/ChangeTracker/TDSocketChangeTracker.m Source/TDBody.m Source/TDCanonicalJSON.m Source/TDCollateJSON.m Source/TDDatabase+Attachments.h Source/TDDatabase+Insertion.m Source/TDDatabase+LocalDocs.m Source/TDDatabase.h Source/TDDatabase.m Source/TDDatabaseManager.m Source/TDJSON.m Source/TDMisc.m Source/TDMultipartDocumentReader.h Source/TDMultipartDocumentReader.m Source/TDPusher.m Source/TDRemoteRequest.m Source/TDReplicatorManager.h Source/TDReplicator_Tests.m Source/TDRouter+Handlers.m Source/TDRouter.h Source/TDRouter.m Source/TDRouter_Tests.m Source/TDServer.m Source/TDURLProtocol.m Source/TDView.m TouchDB.xcodeproj/project.pbxproj
Conflicts: Source/ChangeTracker/TDChangeTracker.m Source/ChangeTracker/TDSocketChangeTracker.m Source/TDBody.m Source/TDCollateJSON.m Source/TDDatabase+Attachments.h Source/TDDatabase+Insertion.m Source/TDDatabase+LocalDocs.m Source/TDDatabase.m Source/TDJSON.h Source/TDJSON.m Source/TDMisc.m Source/TDMultipartDownloader.m Source/TDPuller.m Source/TDPusher.m Source/TDRemoteRequest.m Source/TDReplicatorManager.h Source/TDReplicator_Tests.m Source/TDRouter+Handlers.m Source/TDRouter.h Source/TDRouter.m Source/TDRouter_Tests.m Source/TDServer.m Source/TDURLProtocol.m Source/TDView.m TouchDB.xcodeproj/project.pbxproj
Most of these only become apparent when trying to close a CouchServer or TDServer.
Wasn't being used at all anymore, now that TDServer and TDRouter manage their own threading.
If a doc has two attachments with identical data, or if two docs with identical attachments are pulled in the same "batch", then insertion would fail because the second instance of the attachment couldn't be found (its writer having already been removed from the _pendingAttachments dictionary.) Fixed this by leaving the attachment's key (digest) behind in the dictionary for the use of subsequent insertions of the same content. This fixes #67.
The README now points out that Xcode 4.3 is required (because of the use of forward references to methods.)
There were a couple of problems in the situation where you're indexing a new revision that conflicts with an already-indexed revision. (a) If the new revision is the 'winner', the previously-emitted view rows for the earlier revision need to be removed, because that revision's not visible anymore. Otherwise you can have two revs of the same document showing up in the index. (b) If the new revision is the 'loser', the *older* revision needs to be indexed again, with the new emitted rows *replacing* the old ones. This is because the map function needs to see the new _conflicts array in the doc properties. This fixes #65, which reported case (a). Case (b) I noticed on my own and fixed at the same time.
Small cleanup for the next commit, which needs TDCompareRevIDs.
A TDReplicator can be given a TDAuthorizer object, which is given access to requests before they're sent and can add authorization headers. TDAuthorizer is just a protocol, which can be implemented to do anything from basic auth to OAuth. A TDBasicAuthorizer is provided for basic auth.
…e list of conflicts.
…cts on the first indexing attempt.
…e list of conflicts.
Attachment metadata without a digest property is a problem in multipart downloads because we can't figure out how to match the metadata with the MIME bodies. But the case where there's only one attachment is easy, since no mixup is possible. This is a partial workaround for issue #61.