本文整理汇总了C#中WebRequest.getUrl方法的典型用法代码示例。如果您正苦于以下问题:C# WebRequest.getUrl方法的具体用法?C# WebRequest.getUrl怎么用?C# WebRequest.getUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WebRequest
的用法示例。
在下文中一共展示了WebRequest.getUrl方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: getResponse
/// <summary>
/// Gets the response and modify the headers.
/// </summary>
/// <returns>The response.</returns>
/// <param name="request">Request.</param>
public override WebResponse getResponse(WebRequest request)
{
WebResponse response = base.getResponse(request);
//
// Only if Url matches
//
if (request.getUrl().toExternalForm().Contains("mb.aspx")) {
string content = response.getContentAsString("UTF-8");
java.util.ArrayList newheaders = new java.util.ArrayList();
java.util.List headers = response.getResponseHeaders();
java.util.Iterator it = headers.iterator();
//
// Remove the 'Access-Control-Allow-Origin' header
//
while (it.hasNext()) {
com.gargoylesoftware.htmlunit.util.NameValuePair o = (com.gargoylesoftware.htmlunit.util.NameValuePair)it.next();
if (o.getName().Equals("Access-Control-Allow-Origin")) {
string value = response.getResponseHeaderValue("Access-Control-Allow-Origin");
Console.WriteLine("Found header 'Access-Control-Allow-Origin' = \"{0}\" and stripping it from new headers for response", value);
continue; //headers.remove(o);
}
newheaders.add(o);
}
byte[] utf = System.Text.Encoding.UTF8.GetBytes(content);
WebResponseData data = new WebResponseData(utf,
response.getStatusCode(), response.getStatusMessage(), newheaders);
response = new WebResponse(data, request, response.getLoadTime());
return response;
}
return response;
}