本文整理汇总了C#中System.Net.HttpWebRequest.GetSyncResponse方法的典型用法代码示例。如果您正苦于以下问题:C# HttpWebRequest.GetSyncResponse方法的具体用法?C# HttpWebRequest.GetSyncResponse怎么用?C# HttpWebRequest.GetSyncResponse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Net.HttpWebRequest
的用法示例。
在下文中一共展示了HttpWebRequest.GetSyncResponse方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetLegendInfo
public ArcGISLegendResponse GetLegendInfo(string serviceUrl, ICredentials credentials = null)
{
_webRequest = CreateRequest(serviceUrl, credentials);
var response = _webRequest.GetSyncResponse(_timeOut);
_legendResponse = GetLegendResponseFromWebresponse(response);
return _legendResponse;
}
示例2: FetchImage
public static byte[] FetchImage(HttpWebRequest webRequest)
{
WebResponse webResponse = webRequest.GetSyncResponse(Timeout);
if (webResponse == null) throw (new WebException("An error occurred while fetching tile", null));
if (webResponse.ContentType.StartsWith("image", StringComparison.OrdinalIgnoreCase))
{
using (Stream responseStream = webResponse.GetResponseStream())
{
return Utilities.ReadFully(responseStream);
}
}
string message = ComposeErrorMessage(webResponse, webRequest.RequestUri.AbsoluteUri);
throw (new WebResponseFormatException(message, null));
}
示例3: FetchImage
public static byte[] FetchImage(HttpWebRequest webRequest)
{
using (var webResponse = webRequest.GetSyncResponse(Timeout))
{
if (webResponse == null)
{
throw (new WebException("An error occurred while fetching tile", null));
}
using (Stream responseStream = webResponse.GetResponseStream())
{
return Utilities.ReadFully(responseStream);
}
}
}