From 7ba8132c878d6d7ee019cd755ed62480eaf422c5 Mon Sep 17 00:00:00 2001
From: michielpost <michiel@q42.nl>
Date: Mon, 9 Nov 2020 13:06:25 +0100
Subject: [PATCH] Changed GET requests into POST, API does not support GET
 anymore

---
 src/CoreApi/FileSystemApi.cs |  6 +++---
 src/CoreApi/ObjectApi.cs     |  2 +-
 src/IpfsClient.cs            | 33 ---------------------------------
 3 files changed, 4 insertions(+), 37 deletions(-)

diff --git a/src/CoreApi/FileSystemApi.cs b/src/CoreApi/FileSystemApi.cs
index 65e4ce9..230d0af 100644
--- a/src/CoreApi/FileSystemApi.cs
+++ b/src/CoreApi/FileSystemApi.cs
@@ -196,7 +196,7 @@ internal FileSystemApi(IpfsClient ipfs)
         /// </returns>
         public Task<Stream> ReadFileAsync(string path, CancellationToken cancel = default(CancellationToken))
         {
-            return ipfs.DownloadAsync("cat", cancel, path);
+            return ipfs.PostDownloadAsync("cat", cancel, path);
         }
 
         public Task<Stream> ReadFileAsync(string path, long offset, long length = 0, CancellationToken cancel = default(CancellationToken))
@@ -209,7 +209,7 @@ internal FileSystemApi(IpfsClient ipfs)
 
             if (length == 0)
                 length = int.MaxValue; // go-ipfs only accepts int lengths
-            return ipfs.DownloadAsync("cat", cancel, path, 
+            return ipfs.PostDownloadAsync("cat", cancel, path, 
                 $"offset={offset}",
                 $"length={length}");
         }
@@ -257,7 +257,7 @@ internal FileSystemApi(IpfsClient ipfs)
 
         public Task<Stream> GetAsync(string path, bool compress = false, CancellationToken cancel = default(CancellationToken))
         {
-            return ipfs.DownloadAsync("get", cancel, path, $"compress={compress}");
+            return ipfs.PostDownloadAsync("get", cancel, path, $"compress={compress}");
         }
     }
 }
diff --git a/src/CoreApi/ObjectApi.cs b/src/CoreApi/ObjectApi.cs
index a05cb43..42fb945 100644
--- a/src/CoreApi/ObjectApi.cs
+++ b/src/CoreApi/ObjectApi.cs
@@ -55,7 +55,7 @@ internal ObjectApi(IpfsClient ipfs)
 
         public Task<Stream> DataAsync(Cid id, CancellationToken cancel = default(CancellationToken))
         {
-            return ipfs.DownloadAsync("object/data", cancel, id);
+            return ipfs.PostDownloadAsync("object/data", cancel, id);
         }
 
         public async Task<IEnumerable<IMerkleLink>> LinksAsync(Cid id, CancellationToken cancel = default(CancellationToken))
diff --git a/src/IpfsClient.cs b/src/IpfsClient.cs
index 0b8ce55..7eff437 100644
--- a/src/IpfsClient.cs
+++ b/src/IpfsClient.cs
@@ -361,39 +361,6 @@ public async Task<Stream> PostDownloadAsync(string command, CancellationToken ca
             return await response.Content.ReadAsStreamAsync();
         }
 
-        /// <summary>
-        ///  Perform an <see href="https://ipfs.io/docs/api/">IPFS API command</see> returning a
-        ///  <see cref="Stream"/>.
-        /// </summary>
-        /// <param name="command">
-        ///   The <see href="https://ipfs.io/docs/api/">IPFS API command</see>, such as
-        ///   <see href="https://ipfs.io/docs/api/#apiv0filels">"file/ls"</see>.
-        /// </param>
-        /// <param name="cancel">
-        ///   Is used to stop the task.  When cancelled, the <see cref="TaskCanceledException"/> is raised.
-        /// </param>
-        /// <param name="arg">
-        ///   The optional argument to the command.
-        /// </param>
-        /// <param name="options">
-        ///   The optional flags to the command.
-        /// </param>
-        /// <returns>
-        ///   A <see cref="Stream"/> containing the command's result.
-        /// </returns>
-        /// <exception cref="HttpRequestException">
-        ///   When the IPFS server indicates an error.
-        /// </exception>
-        public async Task<Stream> DownloadAsync(string command, CancellationToken cancel, string arg = null, params string[] options)
-        {
-            var url = BuildCommand(command, arg, options);
-            if (log.IsDebugEnabled)
-                log.Debug("GET " + url.ToString());
-            var response = await Api().GetAsync(url, HttpCompletionOption.ResponseHeadersRead, cancel);
-            await ThrowOnErrorAsync(response);
-            return await response.Content.ReadAsStreamAsync();
-        }
-
         /// <summary>
         ///  Perform an <see href="https://ipfs.io/docs/api/">IPFS API command</see> returning a
         ///  a byte array.