Added SendRequestMultiPart method instead of using SendRequest for it

This commit is contained in:
Jaex 2016-12-26 19:30:17 +03:00
parent bf36dec3b3
commit d3a075ffec
33 changed files with 122 additions and 132 deletions

View file

@ -121,27 +121,18 @@ public virtual void StopUpload()
protected string SendRequest(HttpMethod method, string url, Dictionary<string, string> args = null, NameValueCollection headers = null,
CookieCollection cookies = null, ResponseType responseType = ResponseType.Text)
{
HttpWebResponse response = null;
try
using (HttpWebResponse response = GetResponse(method, url, null, null, args, headers, cookies))
{
if (method == HttpMethod.POST)
{
response = SendRequestMultiPart(url, args, headers, cookies);
}
else
{
response = GetResponse(method, url, null, null, args, headers, cookies);
}
return ResponseToString(response, responseType);
}
finally
}
protected string SendRequest(HttpMethod method, string url, Stream data, string contentType = null, Dictionary<string, string> args = null, NameValueCollection headers = null,
CookieCollection cookies = null, ResponseType responseType = ResponseType.Text)
{
using (HttpWebResponse response = GetResponse(method, url, data, contentType, args, headers, cookies))
{
if (response != null)
{
response.Close();
}
return ResponseToString(response, responseType);
}
}
@ -158,15 +149,6 @@ public virtual void StopUpload()
}
}
protected string SendRequest(HttpMethod method, string url, Stream data, string contentType = null, Dictionary<string, string> args = null, NameValueCollection headers = null,
CookieCollection cookies = null, ResponseType responseType = ResponseType.Text)
{
using (HttpWebResponse response = GetResponse(method, url, data, contentType, args, headers, cookies))
{
return ResponseToString(response, responseType);
}
}
protected string SendRequestURLEncoded(HttpMethod method, string url, Dictionary<string, string> args, NameValueCollection headers = null, CookieCollection cookies = null,
ResponseType responseType = ResponseType.Text)
{
@ -204,7 +186,8 @@ public virtual void StopUpload()
return false;
}
private HttpWebResponse SendRequestMultiPart(string url, Dictionary<string, string> args, NameValueCollection headers = null, CookieCollection cookies = null)
protected string SendRequestMultiPart(string url, Dictionary<string, string> args, NameValueCollection headers = null, CookieCollection cookies = null,
ResponseType responseType = ResponseType.Text)
{
string boundary = CreateBoundary();
string contentType = ContentTypeMultipartFormData + "; boundary=" + boundary;
@ -214,61 +197,11 @@ private HttpWebResponse SendRequestMultiPart(string url, Dictionary<string, stri
{
stream.Write(data, 0, data.Length);
return GetResponse(HttpMethod.POST, url, stream, contentType, null, headers, cookies);
}
}
private HttpWebResponse GetResponse(HttpMethod method, string url, Stream data = null, string contentType = null, Dictionary<string, string> args = null,
NameValueCollection headers = null, CookieCollection cookies = null)
{
IsUploading = true;
StopUploadRequested = false;
try
{
url = CreateQuery(url, args);
long length = 0;
if (data != null)
using (HttpWebResponse response = GetResponse(HttpMethod.POST, url, stream, contentType, null, headers, cookies))
{
length = data.Length;
}
HttpWebRequest request = PrepareWebRequest(method, url, headers, cookies, contentType, length);
if (length > 0)
{
using (Stream requestStream = request.GetRequestStream())
{
if (!TransferData(data, requestStream))
{
return null;
}
}
}
return (HttpWebResponse)request.GetResponse();
}
catch (Exception e)
{
if (!StopUploadRequested)
{
if (WebExceptionThrow && e is WebException)
{
throw;
}
AddWebError(e);
return ResponseToString(response, responseType);
}
}
finally
{
currentRequest = null;
IsUploading = false;
}
return null;
}
protected UploadResult UploadData(string url, Stream data, string fileName, string fileFormName = "file", Dictionary<string, string> args = null,
@ -342,6 +275,59 @@ private HttpWebResponse SendRequestMultiPart(string url, Dictionary<string, stri
return result;
}
private HttpWebResponse GetResponse(HttpMethod method, string url, Stream data = null, string contentType = null, Dictionary<string, string> args = null,
NameValueCollection headers = null, CookieCollection cookies = null)
{
IsUploading = true;
StopUploadRequested = false;
try
{
url = CreateQuery(url, args);
long length = 0;
if (data != null)
{
length = data.Length;
}
HttpWebRequest request = PrepareWebRequest(method, url, headers, cookies, contentType, length);
if (length > 0)
{
using (Stream requestStream = request.GetRequestStream())
{
if (!TransferData(data, requestStream))
{
return null;
}
}
}
return (HttpWebResponse)request.GetResponse();
}
catch (Exception e)
{
if (!StopUploadRequested)
{
if (WebExceptionThrow && e is WebException)
{
throw;
}
AddWebError(e);
}
}
finally
{
currentRequest = null;
IsUploading = false;
}
return null;
}
#region Helper methods
private HttpWebRequest PrepareWebRequest(HttpMethod method, string url, NameValueCollection headers = null, CookieCollection cookies = null, string contentType = null, long contentLength = 0)

View file

@ -93,7 +93,7 @@ public bool GetAccessToken(string pin)
args.Add("client_id", AuthInfo.Client_ID);
args.Add("client_secret", AuthInfo.Client_Secret);
string response = SendRequest(HttpMethod.POST, "https://www.box.com/api/oauth2/token", args);
string response = SendRequestMultiPart("https://www.box.com/api/oauth2/token", args);
if (!string.IsNullOrEmpty(response))
{
@ -120,7 +120,7 @@ public bool RefreshAccessToken()
args.Add("client_id", AuthInfo.Client_ID);
args.Add("client_secret", AuthInfo.Client_Secret);
string response = SendRequest(HttpMethod.POST, "https://www.box.com/api/oauth2/token", args);
string response = SendRequestMultiPart("https://www.box.com/api/oauth2/token", args);
if (!string.IsNullOrEmpty(response))
{

View file

@ -113,7 +113,7 @@ private Drop CreateDrop(string name, string description, bool guests_can_comment
// determines whether guests can delete assets
args.Add("guests_can_delete", guests_can_delete.ToString());
string response = SendRequest(HttpMethod.POST, "http://api.drop.io/drops", args);
string response = SendRequestMultiPart("http://api.drop.io/drops", args);
XDocument doc = XDocument.Parse(response);
XElement root = doc.Element("drop");

View file

@ -136,7 +136,7 @@ public bool GetAccessToken(string code)
args.Add("grant_type", "authorization_code");
args.Add("code", code);
string response = SendRequest(HttpMethod.POST, URLOAuth2Token, args);
string response = SendRequestMultiPart(URLOAuth2Token, args);
if (!string.IsNullOrEmpty(response))
{
@ -363,7 +363,7 @@ public string CreateShareableLinkAPIv1(string path, DropboxURLType urlType)
Dictionary<string, string> args = new Dictionary<string, string>();
args.Add("short_url", urlType == DropboxURLType.Shortened ? "true" : "false");
string response = SendRequest(HttpMethod.POST, url, args, GetAuthHeaders());
string response = SendRequestMultiPart(url, args, GetAuthHeaders());
if (!string.IsNullOrEmpty(response))
{

View file

@ -101,7 +101,7 @@ public bool GetAccessToken(string code)
args.Add("redirect_uri", "urn:ietf:wg:oauth:2.0:oob");
args.Add("grant_type", "authorization_code");
string response = SendRequest(HttpMethod.POST, "https://accounts.google.com/o/oauth2/token", args);
string response = SendRequestMultiPart("https://accounts.google.com/o/oauth2/token", args);
if (!string.IsNullOrEmpty(response))
{
@ -128,7 +128,7 @@ public bool RefreshAccessToken()
args.Add("client_secret", AuthInfo.Client_Secret);
args.Add("grant_type", "refresh_token");
string response = SendRequest(HttpMethod.POST, "https://accounts.google.com/o/oauth2/token", args);
string response = SendRequestMultiPart("https://accounts.google.com/o/oauth2/token", args);
if (!string.IsNullOrEmpty(response))
{

View file

@ -103,7 +103,7 @@ private void GetSessionToken()
args.Add("token_version", "2");
args.Add("response_format", "json");
args.Add("signature", GetInitSignature());
string respStr = SendRequest(HttpMethod.POST, _apiUrl + "user/get_session_token.php", args);
string respStr = SendRequestMultiPart(_apiUrl + "user/get_session_token.php", args);
GetSessionTokenResponse resp = DeserializeResponse<GetSessionTokenResponse>(respStr);
EnsureSuccess(resp);
if (resp.session_token == null || resp.time == null || resp.secret_key == null)
@ -137,7 +137,7 @@ private string PollUpload(string uploadKey, string fileName)
args.Add("filename", fileName);
args.Add("response_format", "json");
args.Add("signature", GetSignature("upload/poll_upload.php", args));
string respStr = SendRequest(HttpMethod.POST, _apiUrl + "upload/poll_upload.php", args);
string respStr = SendRequestMultiPart(_apiUrl + "upload/poll_upload.php", args);
PollUploadResponse resp = DeserializeResponse<PollUploadResponse>(respStr);
EnsureSuccess(resp);
if (resp.doupload.result == null || resp.doupload.status == null) throw new IOException("Invalid response");

View file

@ -78,7 +78,7 @@ public bool GetAccessToken()
args.Add("username", Config.Username);
args.Add("password", Config.Password);
string response = SendRequest(HttpMethod.POST, URL_OAUTH_TOKEN, args);
string response = SendRequestMultiPart(URL_OAUTH_TOKEN, args);
if (!string.IsNullOrEmpty(response))
{
@ -106,7 +106,7 @@ public bool RefreshAccessToken()
args.Add("scope", AuthInfo.Token.scope);
args.Add("refresh_token", AuthInfo.Token.refresh_token);
string response = SendRequest(HttpMethod.POST, URL_OAUTH_TOKEN, args);
string response = SendRequestMultiPart(URL_OAUTH_TOKEN, args);
if (!string.IsNullOrEmpty(response))
{
@ -196,7 +196,7 @@ public MinusFolder CreateFolder(string name, bool is_public)
MinusFolder dir;
string response = SendRequest(HttpMethod.POST, GetActiveUserFolderURL(), args);
string response = SendRequestMultiPart(GetActiveUserFolderURL(), args);
if (!string.IsNullOrEmpty(response))
{
dir = JsonConvert.DeserializeObject<MinusFolder>(response);

View file

@ -140,7 +140,7 @@ public string ShareFile(string path)
string url = URLHelpers.CombineURL(Host, "ocs/v1.php/apps/files_sharing/api/v1/shares?format=json");
url = URLHelpers.FixPrefix(url);
NameValueCollection headers = CreateAuthenticationHeader(Username, Password);
string response = SendRequest(HttpMethod.POST, url, args, headers);
string response = SendRequestMultiPart(url, args, headers);
if (!string.IsNullOrEmpty(response))
{

View file

@ -82,7 +82,7 @@ public UploadResult PushFile(Stream stream, string fileName)
upArgs.Add("file_name", fileName);
string uploadRequest = SendRequest(HttpMethod.POST, apiRequestFileUploadURL, upArgs, headers);
string uploadRequest = SendRequestMultiPart(apiRequestFileUploadURL, upArgs, headers);
if (uploadRequest == null) return null;
@ -110,7 +110,7 @@ public UploadResult PushFile(Stream stream, string fileName)
pushArgs.Add("file_url", fileInfo.file_url);
pushArgs.Add("body", "Sent via ShareX");
string pushResult = SendRequest(HttpMethod.POST, apiSendPushURL, pushArgs, headers);
string pushResult = SendRequestMultiPart(apiSendPushURL, pushArgs, headers);
if (pushResult == null) return null;
@ -140,7 +140,7 @@ private string Push(string pushType, string valueType, string value, string titl
args.Add("body", "Sent via ShareX");
}
string response = SendRequest(HttpMethod.POST, apiSendPushURL, args, headers);
string response = SendRequestMultiPart(apiSendPushURL, args, headers);
if (response == null) return null;

View file

@ -78,7 +78,7 @@ public string Login(string email, string password)
arguments.Add("p", password);
arguments.Add("z", "ShareX");
string response = SendRequest(HttpMethod.POST, PuushAPILoginURL, arguments);
string response = SendRequestMultiPart(PuushAPILoginURL, arguments);
if (!string.IsNullOrEmpty(response))
{

View file

@ -98,7 +98,7 @@ public string GetAuthToken(string username, string password)
{ "password", password }
};
string response = SendRequest(HttpMethod.POST, url, args);
string response = SendRequestMultiPart(url, args);
if (!string.IsNullOrEmpty(response))
{
@ -365,7 +365,7 @@ public bool DecryptLibrary(string libraryPassword)
sslBypassHelper = new SSLBypassHelper();
}
string response = SendRequest(HttpMethod.POST, url, args, headers);
string response = SendRequestMultiPart(url, args, headers);
if (!string.IsNullOrEmpty(response))
{

View file

@ -272,7 +272,7 @@ public bool AuthRegister(string username, string fullname, string email, string
args.Add("email", email);
args.Add("password", password);
string response = SendRequest(HttpMethod.POST, APIURL, args);
string response = SendRequestMultiPart(APIURL, args);
if (!string.IsNullOrEmpty(response))
{
@ -296,7 +296,7 @@ public string AuthCreateToken()
args.Add("app_version", AppVersion); // Application specific, formatting / style is up to you
args.Add("response_format", "xml"); // Value must be: XML
string response = SendRequest(HttpMethod.POST, APIURL, args);
string response = SendRequestMultiPart(APIURL, args);
if (!string.IsNullOrEmpty(response))
{
@ -329,7 +329,7 @@ public LoginInfo AuthLogin(string token, string username, string password)
string passwordHash = TranslatorHelper.TextToHash(password, HashType.MD5);
args.Add("tokened_password", TranslatorHelper.TextToHash(token + passwordHash, HashType.MD5));
string response = SendRequest(HttpMethod.POST, APIURL, args);
string response = SendRequestMultiPart(APIURL, args);
if (!string.IsNullOrEmpty(response))
{
@ -357,7 +357,7 @@ public bool AuthCheckSession(string sessionKey)
args.Add("method", "auth.checkSession");
args.Add("session_key", sessionKey);
string response = SendRequest(HttpMethod.POST, APIURL, args);
string response = SendRequestMultiPart(APIURL, args);
if (!string.IsNullOrEmpty(response))
{
@ -389,7 +389,7 @@ public bool AuthLogout(string sessionKey)
args.Add("method", "auth.logout");
args.Add("session_key", sessionKey);
string response = SendRequest(HttpMethod.POST, APIURL, args);
string response = SendRequestMultiPart(APIURL, args);
if (!string.IsNullOrEmpty(response))
{
@ -555,7 +555,10 @@ private void bw_DoWork(object sender, DoWorkEventArgs e)
time = DateTime.Now;
try
{
progressInfo.ParseResponse(sendSpace.SendRequest(HttpMethod.POST, url));
string response = sendSpace.SendRequest(HttpMethod.POST, url);
progressInfo.ParseResponse(response);
if (progressInfo.Status != "fail" && !string.IsNullOrEmpty(progressInfo.Meter))
{
if (int.TryParse(progressInfo.Meter, out progress))

View file

@ -76,7 +76,8 @@ public UpleaGetUserInformationResponse GetUserInformation(string apiKey)
private UpleaNode GetBestNode()
{
UpleaGetBestNodeResponse getBestNodeResponse = JsonConvert.DeserializeObject<UpleaGetBestNodeResponse>(SendRequest(HttpMethod.POST, upleaBaseUrl + "get-best-node"));
string response = SendRequest(HttpMethod.POST, upleaBaseUrl + "get-best-node");
UpleaGetBestNodeResponse getBestNodeResponse = JsonConvert.DeserializeObject<UpleaGetBestNodeResponse>(response);
return new UpleaNode(getBestNodeResponse.Result.Name, getBestNodeResponse.Result.Token);
}

View file

@ -92,7 +92,7 @@ public FlickrAuthInfo CheckToken(string token)
args.Add("auth_token", token);
args.Add("api_sig", GetAPISig(args));
string response = SendRequest(HttpMethod.POST, API_URL, args);
string response = SendRequestMultiPart(API_URL, args);
Auth = new FlickrAuthInfo(ParseResponse(response, "auth"));
@ -110,7 +110,7 @@ public string GetFrob()
args.Add("api_key", API_Key);
args.Add("api_sig", GetAPISig(args));
string response = SendRequest(HttpMethod.POST, API_URL, args);
string response = SendRequestMultiPart(API_URL, args);
XElement eFrob = ParseResponse(response, "frob");
@ -142,7 +142,7 @@ public FlickrAuthInfo GetFullToken(string frob)
args.Add("mini_token", frob);
args.Add("api_sig", GetAPISig(args));
string response = SendRequest(HttpMethod.POST, API_URL, args);
string response = SendRequestMultiPart(API_URL, args);
Auth = new FlickrAuthInfo(ParseResponse(response, "auth"));
@ -162,7 +162,7 @@ public FlickrAuthInfo GetToken(string frob)
args.Add("frob", frob);
args.Add("api_sig", GetAPISig(args));
string response = SendRequest(HttpMethod.POST, API_URL, args);
string response = SendRequestMultiPart(API_URL, args);
Auth = new FlickrAuthInfo(ParseResponse(response, "auth"));

View file

@ -76,7 +76,7 @@ public bool GetAccessToken()
args.Add("user", Config.Username);
args.Add("password", Config.Password);
string response = SendRequest(HttpMethod.POST, URLAccessToken, args);
string response = SendRequestMultiPart(URLAccessToken, args);
if (!string.IsNullOrEmpty(response))
{

View file

@ -124,7 +124,7 @@ public bool GetAccessToken(string pin)
args.Add("grant_type", "pin");
args.Add("pin", pin);
string response = SendRequest(HttpMethod.POST, "https://api.imgur.com/oauth2/token", args);
string response = SendRequestMultiPart("https://api.imgur.com/oauth2/token", args);
if (!string.IsNullOrEmpty(response))
{
@ -151,7 +151,7 @@ public bool RefreshAccessToken()
args.Add("client_secret", AuthInfo.Client_Secret);
args.Add("grant_type", "refresh_token");
string response = SendRequest(HttpMethod.POST, "https://api.imgur.com/oauth2/token", args);
string response = SendRequestMultiPart("https://api.imgur.com/oauth2/token", args);
if (!string.IsNullOrEmpty(response))
{

View file

@ -151,7 +151,7 @@ public bool CreateAlbum(string albumID, string albumName)
string query = OAuthManager.GenerateQuery(url, args, HttpMethod.POST, AuthInfo);
query = FixURL(query);
string response = SendRequest(HttpMethod.POST, query, args);
string response = SendRequestMultiPart(query, args);
if (!string.IsNullOrEmpty(response))
{

View file

@ -86,7 +86,7 @@ public bool GetAccessToken(string code)
args.Add("redirect_uri", "urn:ietf:wg:oauth:2.0:oob");
args.Add("grant_type", "authorization_code");
string response = SendRequest(HttpMethod.POST, "https://accounts.google.com/o/oauth2/token", args);
string response = SendRequestMultiPart("https://accounts.google.com/o/oauth2/token", args);
if (!string.IsNullOrEmpty(response))
{
@ -113,7 +113,7 @@ public bool RefreshAccessToken()
args.Add("client_secret", AuthInfo.Client_Secret);
args.Add("grant_type", "refresh_token");
string response = SendRequest(HttpMethod.POST, "https://accounts.google.com/o/oauth2/token", args);
string response = SendRequestMultiPart("https://accounts.google.com/o/oauth2/token", args);
if (!string.IsNullOrEmpty(response))
{

View file

@ -124,7 +124,7 @@ public string UserAuth(string email, string password)
{ "pass", password }
};
string response = SendRequest(HttpMethod.POST, URLAPI, args);
string response = SendRequestMultiPart(URLAPI, args);
if (!string.IsNullOrEmpty(response))
{

View file

@ -123,7 +123,7 @@ public TwitterStatusResponse TweetMessage(string message)
Dictionary<string, string> args = new Dictionary<string, string>();
args.Add("status", message);
string response = SendRequest(HttpMethod.POST, query, args);
string response = SendRequestMultiPart(query, args);
if (!string.IsNullOrEmpty(response))
{

View file

@ -94,7 +94,7 @@ public override UploadResult UploadText(string text, string fileName)
{
if (string.IsNullOrEmpty(customUploader.FileFormName))
{
result.Response = SendRequest(HttpMethod.POST, requestURL, args, customUploader.GetHeaders(), responseType: customUploader.ResponseType);
result.Response = SendRequestMultiPart(requestURL, args, customUploader.GetHeaders(), responseType: customUploader.ResponseType);
}
else
{

View file

@ -101,7 +101,7 @@ public bool GetAccessToken(string code)
WebHeaderCollection headers = new WebHeaderCollection();
headers.Add("Accept", ContentTypeJSON);
string response = SendRequest(HttpMethod.POST, "https://github.com/login/oauth/access_token", args, headers);
string response = SendRequestMultiPart("https://github.com/login/oauth/access_token", args, headers);
if (!string.IsNullOrEmpty(response))
{

View file

@ -78,7 +78,7 @@ public override UploadResult UploadText(string text, string fileName)
headers = CreateAuthenticationHeader(API_USERNAME, API_KEY);
}
result.Response = SendRequest(HttpMethod.POST, API_ENDPOINT, args, headers);
result.Response = SendRequestMultiPart(API_ENDPOINT, args, headers);
if (!string.IsNullOrEmpty(result.Response))
{

View file

@ -72,7 +72,7 @@ public override UploadResult UploadText(string text, string fileName)
arguments.Add("lang", settings.TextFormat);
arguments.Add("parent", "0");
ur.URL = SendRequest(HttpMethod.POST, APIURL, arguments, responseType: ResponseType.RedirectionURL);
ur.URL = SendRequestMultiPart(APIURL, arguments, responseType: ResponseType.RedirectionURL);
}
return ur;

View file

@ -78,7 +78,7 @@ public override UploadResult UploadText(string text, string fileName)
arguments.Add("format", "simple");
arguments.Add("return", "link");
ur.Response = SendRequest(HttpMethod.POST, "http://paste.ee/api", arguments);
ur.Response = SendRequestMultiPart("http://paste.ee/api", arguments);
if (!string.IsNullOrEmpty(ur.Response) && ur.Response.StartsWith("error"))
{

View file

@ -84,7 +84,7 @@ public bool Login()
loginArgs.Add("api_user_name", Settings.Username);
loginArgs.Add("api_user_password", Settings.Password);
string loginResponse = SendRequest(HttpMethod.POST, "http://pastebin.com/api/api_login.php", loginArgs);
string loginResponse = SendRequestMultiPart("http://pastebin.com/api/api_login.php", loginArgs);
if (!string.IsNullOrEmpty(loginResponse) && !loginResponse.StartsWith("Bad API request"))
{
@ -121,7 +121,7 @@ public override UploadResult UploadText(string text, string fileName)
args.Add("api_user_key", Settings.UserKey); // this paramater is part of the login system
}
ur.Response = SendRequest(HttpMethod.POST, "http://pastebin.com/api/api_post.php", args);
ur.Response = SendRequestMultiPart("http://pastebin.com/api/api_post.php", args);
if (!string.IsNullOrEmpty(ur.Response) && !ur.Response.StartsWith("Bad API request") && ur.Response.IsValidUrl())
{

View file

@ -71,7 +71,7 @@ public override UploadResult UploadText(string text, string fileName)
arguments.Add("tags", settings.Tags);
arguments.Add("type", settings.TextFormat);
ur.Response = SendRequest(HttpMethod.POST, APIURL, arguments);
ur.Response = SendRequestMultiPart(APIURL, arguments);
if (!string.IsNullOrEmpty(ur.Response))
{

View file

@ -71,7 +71,7 @@ public override UploadResult UploadText(string text, string fileName)
arguments.Add("key", Key);
}
ur.URL = SendRequest(HttpMethod.POST, "https://pastee.org/submit", arguments, responseType: ResponseType.RedirectionURL);
ur.URL = SendRequestMultiPart("https://pastee.org/submit", arguments, responseType: ResponseType.RedirectionURL);
}
return ur;

View file

@ -80,7 +80,7 @@ public override UploadResult UploadText(string text, string fileName)
arguments.Add("tabbing", "true");
arguments.Add("tabtype", "real");
ur.URL = SendRequest(HttpMethod.POST, APIURL, arguments, responseType: ResponseType.RedirectionURL);
ur.URL = SendRequestMultiPart(APIURL, arguments, responseType: ResponseType.RedirectionURL);
}
return ur;

View file

@ -81,7 +81,7 @@ public override UploadResult UploadText(string text, string fileName)
arguments.Add("expire", "0");
arguments.Add("json", "true");
ur.Response = SendRequest(HttpMethod.POST, APIURL, arguments);
ur.Response = SendRequestMultiPart(APIURL, arguments);
if (!string.IsNullOrEmpty(ur.Response))
{

View file

@ -91,7 +91,7 @@ public bool GetAccessToken(string code)
args.Add("code", code);
args.Add("redirect_uri", Links.URL_CALLBACK);
string response = SendRequest(HttpMethod.POST, URLAccessToken, args);
string response = SendRequestMultiPart(URLAccessToken, args);
if (!string.IsNullOrEmpty(response))
{

View file

@ -91,7 +91,7 @@ public bool GetAccessToken(string code)
args.Add("redirect_uri", "urn:ietf:wg:oauth:2.0:oob");
args.Add("grant_type", "authorization_code");
string response = SendRequest(HttpMethod.POST, "https://accounts.google.com/o/oauth2/token", args);
string response = SendRequestMultiPart("https://accounts.google.com/o/oauth2/token", args);
if (!string.IsNullOrEmpty(response))
{
@ -118,7 +118,7 @@ public bool RefreshAccessToken()
args.Add("client_secret", AuthInfo.Client_Secret);
args.Add("grant_type", "refresh_token");
string response = SendRequest(HttpMethod.POST, "https://accounts.google.com/o/oauth2/token", args);
string response = SendRequestMultiPart("https://accounts.google.com/o/oauth2/token", args);
if (!string.IsNullOrEmpty(response))
{

View file

@ -92,7 +92,7 @@ public override UploadResult ShortenURL(string url)
//arguments.Add("title", "");
arguments.Add("format", "simple");
result.Response = SendRequest(HttpMethod.POST, APIURL, arguments);
result.Response = SendRequestMultiPart(APIURL, arguments);
result.ShortenedURL = result.Response;
}