fixed #2167: Use url arguments instead of header for json args

This commit is contained in:
Jaex 2016-12-23 10:56:37 +03:00
parent 10b57f05e3
commit 90dd7443f1

View file

@ -188,7 +188,7 @@ public DropboxAccount GetCurrentAccount()
if (OAuth2Info.CheckOAuth(AuthInfo)) if (OAuth2Info.CheckOAuth(AuthInfo))
{ {
string response = SendRequestJSON(URLGetCurrentAccount, "null", GetAuthHeaders()); string response = SendRequest(HttpMethod.POST, URLGetCurrentAccount, "null", ContentTypeJSON, null, GetAuthHeaders());
if (!string.IsNullOrEmpty(response)) if (!string.IsNullOrEmpty(response))
{ {
@ -230,16 +230,15 @@ public bool DownloadFile(string path, Stream downloadStream)
{ {
if (!string.IsNullOrEmpty(path) && OAuth2Info.CheckOAuth(AuthInfo)) if (!string.IsNullOrEmpty(path) && OAuth2Info.CheckOAuth(AuthInfo))
{ {
NameValueCollection headers = GetAuthHeaders();
string json = JsonConvert.SerializeObject(new string json = JsonConvert.SerializeObject(new
{ {
path = VerifyPath(path) path = VerifyPath(path)
}); });
headers.Add("Dropbox-API-Arg", json); Dictionary<string, string> args = new Dictionary<string, string>();
args.Add("arg", json);
return SendRequest(HttpMethod.POST, downloadStream, URLDownload, headers: headers, contentType: ContentTypeJSON); return SendRequestDownload(HttpMethod.POST, URLDownload, downloadStream, args, GetAuthHeaders(), null, ContentTypeJSON);
} }
return false; return false;
@ -253,8 +252,6 @@ public UploadResult UploadFile(Stream stream, string path, string filename, bool
return null; return null;
} }
NameValueCollection headers = GetAuthHeaders();
string json = JsonConvert.SerializeObject(new string json = JsonConvert.SerializeObject(new
{ {
path = VerifyPath(path, filename), path = VerifyPath(path, filename),
@ -263,9 +260,10 @@ public UploadResult UploadFile(Stream stream, string path, string filename, bool
mute = true mute = true
}); });
headers.Add("Dropbox-API-Arg", json); Dictionary<string, string> args = new Dictionary<string, string>();
args.Add("arg", json);
string response = SendRequestStream(URLUpload, stream, ContentTypeOctetStream, headers); string response = SendRequest(HttpMethod.POST, URLUpload, stream, ContentTypeOctetStream, args, GetAuthHeaders());
UploadResult ur = new UploadResult(response); UploadResult ur = new UploadResult(response);
@ -305,7 +303,7 @@ public DropboxMetadata GetMetadata(string path)
include_has_explicit_shared_members = false include_has_explicit_shared_members = false
}); });
string response = SendRequestJSON(URLGetMetadata, json, GetAuthHeaders()); string response = SendRequest(HttpMethod.POST, URLGetMetadata, json, ContentTypeJSON, null, GetAuthHeaders());
if (!string.IsNullOrEmpty(response)) if (!string.IsNullOrEmpty(response))
{ {
@ -336,7 +334,7 @@ public string CreateShareableLink(string path, DropboxURLType urlType)
} }
}); });
string response = SendRequestJSON(URLCreateSharedLink, json, GetAuthHeaders()); string response = SendRequest(HttpMethod.POST, URLCreateSharedLink, json, ContentTypeJSON, null, GetAuthHeaders());
if (!string.IsNullOrEmpty(response)) if (!string.IsNullOrEmpty(response))
{ {
@ -397,7 +395,7 @@ public DropboxMetadata Copy(string fromPath, string toPath)
to_path = VerifyPath(toPath) to_path = VerifyPath(toPath)
}); });
string response = SendRequestJSON(URLCopy, json, GetAuthHeaders()); string response = SendRequest(HttpMethod.POST, URLCopy, json, ContentTypeJSON, null, GetAuthHeaders());
if (!string.IsNullOrEmpty(response)) if (!string.IsNullOrEmpty(response))
{ {
@ -419,7 +417,7 @@ public DropboxMetadata CreateFolder(string path)
path = VerifyPath(path) path = VerifyPath(path)
}); });
string response = SendRequestJSON(URLCreateFolder, json, GetAuthHeaders()); string response = SendRequest(HttpMethod.POST, URLCreateFolder, json, ContentTypeJSON, null, GetAuthHeaders());
if (!string.IsNullOrEmpty(response)) if (!string.IsNullOrEmpty(response))
{ {
@ -441,7 +439,7 @@ public DropboxMetadata Delete(string path)
path = VerifyPath(path) path = VerifyPath(path)
}); });
string response = SendRequestJSON(URLDelete, json, GetAuthHeaders()); string response = SendRequest(HttpMethod.POST, URLDelete, json, ContentTypeJSON, null, GetAuthHeaders());
if (!string.IsNullOrEmpty(response)) if (!string.IsNullOrEmpty(response))
{ {
@ -464,7 +462,7 @@ public DropboxMetadata Move(string fromPath, string toPath)
to_path = VerifyPath(toPath) to_path = VerifyPath(toPath)
}); });
string response = SendRequestJSON(URLMove, json, GetAuthHeaders()); string response = SendRequest(HttpMethod.POST, URLMove, json, ContentTypeJSON, null, GetAuthHeaders());
if (!string.IsNullOrEmpty(response)) if (!string.IsNullOrEmpty(response))
{ {