public static string Request(HttpMethod method, string url, string content, string contentPostingType = "application/x-www-form-urlencoded", string proxy = "", string Encoding = "UTF-8", ResponceType respType = 1, int Timeout = 0x7530, string Cookies = "", string UserAgent = "", bool UseRedirect = true, int MaxRedirectCount = 5, string[] AdditionalHeaders = null, string DownloadPath = null, bool UseOriginalUrl = false, bool throwExceptionOnError = true, ICookieContainer cookieContainer = null)
{
string str = string.Empty;
string error = string.Empty;
bool shouldClose = ZennoPoster.ConnectToInstanceManagerService(out WcfKeeper<IInstanceManagerService> keeper, false);
if (keeper != null)
{
switch (method)
{
case HttpMethod.GET:
str = keeper.Service.HttpGet(url, out error, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.POST:
str = keeper.Service.HttpPost(url, content, out error, contentPostingType, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.PUT:
str = keeper.Service.HttpPut(url, content, out error, contentPostingType, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.HEAD:
str = keeper.Service.HttpHead(url, out error, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.DELETE:
str = keeper.Service.HttpDelete(url, content, out error, contentPostingType, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.OPTIONS:
str = keeper.Service.HttpOptions(url, out error, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.TRACE:
str = keeper.Service.HttpTrace(url, out error, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.PATCH:
str = keeper.Service.HttpPatch(url, content, out error, contentPostingType, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
}
}
ZennoPoster.CloseConnectionWithInstanceManager(keeper, shouldClose);
if (!throwExceptionOnError || string.IsNullOrEmpty(error))
{
return str;
}
Dictionary<string, string> dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(error);
if (dictionary["ExceptionType"] == typeof(TimeoutException).Name)
{
RequestAbortedException exception1 = new RequestAbortedException {
_dataString = str
};
throw exception1;
}
throw new Exception(dictionary["ExceptionMessage"]);
}
public static string Request(HttpMethod method, string url, string content, string contentPostingType = "application/x-www-form-urlencoded", string proxy = "", string Encoding = "UTF-8", ResponceType respType = 1, int Timeout = 0x7530, string Cookies = "", string UserAgent = "", bool UseRedirect = true, int MaxRedirectCount = 5, string[] AdditionalHeaders = null, string DownloadPath = null, bool UseOriginalUrl = false, bool throwExceptionOnError = true, ICookieContainer cookieContainer = null)
{
string str = string.Empty;
string error = string.Empty;
bool shouldClose = ZennoPoster.ConnectToInstanceManagerService(out WcfKeeper<IInstanceManagerService> keeper, false);
if (keeper != null)
{
switch (method)
{
case HttpMethod.GET:
str = keeper.Service.HttpGet(url, out error, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.POST:
str = keeper.Service.HttpPost(url, content, out error, contentPostingType, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.PUT:
str = keeper.Service.HttpPut(url, content, out error, contentPostingType, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.HEAD:
str = keeper.Service.HttpHead(url, out error, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.DELETE:
str = keeper.Service.HttpDelete(url, content, out error, contentPostingType, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.OPTIONS:
str = keeper.Service.HttpOptions(url, out error, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.TRACE:
str = keeper.Service.HttpTrace(url, out error, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
case HttpMethod.PATCH:
str = keeper.Service.HttpPatch(url, content, out error, contentPostingType, proxy, Encoding, respType, Timeout, Cookies, UserAgent, UseRedirect, MaxRedirectCount, AdditionalHeaders, DownloadPath, UseOriginalUrl, false, cookieContainer);
break;
}
}
ZennoPoster.CloseConnectionWithInstanceManager(keeper, shouldClose);
if (!throwExceptionOnError || string.IsNullOrEmpty(error))
{
return str;
}
Dictionary<string, string> dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(error);
if (dictionary["ExceptionType"] == typeof(TimeoutException).Name)
{
RequestAbortedException exception1 = new RequestAbortedException {
_dataString = str
};
throw exception1;
}
throw new Exception(dictionary["ExceptionMessage"]);
}