Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed GET requests into POST, API does not support GET anymore #64

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/CoreApi/FileSystemApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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}");
}
Expand Down Expand Up @@ -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}");
}
}
}
2 changes: 1 addition & 1 deletion src/CoreApi/ObjectApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
33 changes: 0 additions & 33 deletions src/IpfsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down