CMIS-903: read POST responses to avoid blocking
git-svn-id: https://svn.apache.org/repos/asf/chemistry/dotcmis/trunk@1670123 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/DotCMIS/binding/atompub/atompub.cs b/DotCMIS/binding/atompub/atompub.cs
index 96acdf1..3f10ee3 100644
--- a/DotCMIS/binding/atompub/atompub.cs
+++ b/DotCMIS/binding/atompub/atompub.cs
@@ -451,6 +451,33 @@
return resp;
}
+ protected void PostAndConsume(UrlBuilder url, string contentType, HttpUtils.Output writer)
+ {
+ HttpUtils.Response resp = HttpUtils.InvokePOST(url, contentType, writer, Session);
+
+ if (resp.StatusCode != HttpStatusCode.Created)
+ {
+ throw ConvertStatusCode(resp.StatusCode, resp.Message, resp.ErrorContent, null);
+ }
+
+ if (resp.Stream != null)
+ {
+ Stream stream = resp.Stream;
+ try
+ {
+ byte[] buffer = new byte[8 * 1024];
+ while (stream.Read(buffer, 0, buffer.Length) > 0)
+ {
+ }
+ }
+ finally
+ {
+ try { stream.Close(); }
+ catch (Exception) { }
+ }
+ }
+ }
+
protected HttpUtils.Response Put(UrlBuilder url, string contentType, HttpUtils.Output writer)
{
HttpUtils.Response resp = HttpUtils.InvokePUT(url, contentType, null, writer, Session);
@@ -2738,7 +2765,7 @@
AtomEntryWriter entryWriter = new AtomEntryWriter(CreateIdObject(objectId));
// post addObjectToFolder request
- Post(url, AtomPubConstants.MediatypeEntry, new HttpUtils.Output(entryWriter.Write));
+ PostAndConsume(url, AtomPubConstants.MediatypeEntry, new HttpUtils.Output(entryWriter.Write));
}
public void RemoveObjectFromFolder(string repositoryId, string objectId, string folderId, IExtensionsData extension)
@@ -2763,7 +2790,7 @@
AtomEntryWriter entryWriter = new AtomEntryWriter(CreateIdObject(objectId));
// post removeObjectFromFolder request
- Post(url, AtomPubConstants.MediatypeEntry, new HttpUtils.Output(entryWriter.Write));
+ PostAndConsume(url, AtomPubConstants.MediatypeEntry, new HttpUtils.Output(entryWriter.Write));
}
}
@@ -2827,7 +2854,7 @@
AtomEntryWriter entryWriter = new AtomEntryWriter(CreateIdObject(objectId));
// post applyPolicy request
- Post(url, AtomPubConstants.MediatypeEntry, new HttpUtils.Output(entryWriter.Write));
+ PostAndConsume(url, AtomPubConstants.MediatypeEntry, new HttpUtils.Output(entryWriter.Write));
}
public void RemovePolicy(string repositoryId, string policyId, string objectId, IExtensionsData extension)