// Uploads the revision as JSON instead of multipart. private void UploadJsonRevision(RevisionInternal originalRev) { // Expand all attachments inline: var rev = originalRev.Copy(originalRev.DocID, originalRev.RevID); try { LocalDatabase.ExpandAttachments(rev, 0, false, false); } catch (Exception e) { LastError = e; RevisionFailed(); return; } var path = string.Format("/{0}?new_edits=false", Uri.EscapeUriString(rev.DocID)); SendAsyncRequest(HttpMethod.Put, path, rev.GetProperties(), (result, e) => { if (e != null) { LastError = e; RevisionFailed(); } else { Log.To.Sync.V(TAG, "{0} sent {1} (JSON), response={2}", this, rev, new LogJsonString(result)); SafeIncrementCompletedChangesCount(); RemovePending(rev); } }); }
// Uploads the revision as JSON instead of multipart. private void UploadJsonRevision(RevisionInternal originalRev) { // Expand all attachments inline: var rev = originalRev.Copy(originalRev.DocID, originalRev.RevID); try { LocalDatabase.ExpandAttachments(rev, 0, false, false); } catch (Exception e) { LastError = e; RevisionFailed(); return; } var path = string.Format("/{0}?new_edits=false", Uri.EscapeUriString(rev.DocID)); _remoteSession.SendAsyncRequest(HttpMethod.Put, path, rev.GetProperties(), (result, e) => { if (e != null) { var httpError = Misc.Flatten(e).FirstOrDefault(ex => ex is HttpResponseException) as HttpResponseException; if (httpError != null) { LastError = Misc.CreateExceptionAndLog(Log.To.Sync, StatusCode.Forbidden, TAG, $"{rev.DocID} was rejected by the endpoint"); } else { LastError = e; RevisionFailed(); } } else { Log.To.Sync.V(TAG, "{0} sent {1} (JSON), response={2}", this, rev, new LogJsonString(result)); SafeIncrementCompletedChangesCount(); RemovePending(rev); } }); }