Author: fmui
Date: Mon Mar 30 15:18:29 2015
New Revision: 1670123
URL: http://svn.apache.org/r1670123
Log:
CMIS-903: read POST responses to avoid blocking
Modified:
chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs
Modified: chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs
URL:
http://svn.apache.org/viewvc/chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs?rev=1670123&r1=1670122&r2=1670123&view=diff
==============================================================================
--- chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs (original)
+++ chemistry/dotcmis/trunk/DotCMIS/binding/atompub/atompub.cs Mon Mar 30
15:18:29 2015
@@ -451,6 +451,33 @@ namespace DotCMIS.Binding.AtomPub
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 @@ namespace DotCMIS.Binding.AtomPub
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 @@ namespace DotCMIS.Binding.AtomPub
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 @@ namespace DotCMIS.Binding.AtomPub
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)