webrequest

non blocking webrequests vb.net

六月ゝ 毕业季﹏ 提交于 2019-12-11 01:50:05
问题 I am making a program that must process about 5000 strings as quickly as possible. about 2000 of these strings must be translated via a webrequest to mymemory.translated.net. (see code below, JSON part removed since not needed here) Try url = "http://api.mymemory.translated.net/get?q=" & Firstpart & "!&langpair=de|it&de=somemail@christmas.com" request = DirectCast(WebRequest.Create(url), HttpWebRequest) response = DirectCast(request.GetResponse(), HttpWebResponse) myreader = New StreamReader

How to get RequestCachePolicy to respect max-age

十年热恋 提交于 2019-12-10 18:20:55
问题 I am confused about how time-based cache policies work when using HttpWebRequest . I am calling a GET method of a WebAPI that returns JSON content together with a Cache-Control header similar to: Cache-Control: public, max-age=60 The intention is that the content should be considered to be stale after max-age seconds. I am calling this API using HttpWebRequest , and want subsequent requests to be served from the local cache for max-age seconds, then to be retrieved from the server when the

Encoding differences between using WebClient and WebRequest?

情到浓时终转凉″ 提交于 2019-12-10 16:50:00
问题 In getting some random spanish newspaper's index I don't get the diacriticals properly using WebRequest, they yield this weird character: � , while downloading the response from the same uri using a WebClient I get the appropriate response. Why is this differentiation? var client = new WebClient(); string html = client.DownloadString(endpoint); vs WebRequest request = WebRequest.Create(endpoint); using (WebResponse response = request.GetResponse()) { Stream stream = response.GetResponseStream

How to Avoid Server Error 414 for Very Long QueryString Values

↘锁芯ラ 提交于 2019-12-09 23:25:58
问题 I had a project that required posting a 2.5 million character QueryString to a web page. The server itself only parsed URI's that were 5,400 characters or less. After trying several different sets of code for WebRequest/WebResponse, WebClient, and Sockets, I finally found the following code that solved my problem: HttpWebRequest webReq; HttpWebResponse webResp = null; string Response = ""; Stream reqStream = null; webReq = (HttpWebRequest)WebRequest.Create(strURL); Byte[] bytes = Encoding

HttpWebRequest Unable to download data from nasdaq.com but able from browsers

最后都变了- 提交于 2019-12-08 14:44:49
I am trying to download this website csv file, the file small only take like 2 seconds to download with any browsers. http://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=AMEX&render=download using HttpWebRequest and also WebClient but looks like nasdaq.com is not letting the data to flow through with these two methods, I also tried with Fiddler and nothing coming back. I only can download this data using any browsers. I tried to change the header, the agent, security protocol, redirect, a little on cookie and many settings but I'm still stuck with this problem. If anyone

HttpWebRequest BeginGetResponse callback not firing on WP8 (working on WP7)

删除回忆录丶 提交于 2019-12-08 12:33:20
问题 I'm having a problem with a previous app not working on WP8, which works perfectly on WP7. This is the code I'm using for the http request: public void SendMessage() { request = WebRequest.Create(uri) as HttpWebRequest; request.Method = "POST"; request.AllowReadStreamBuffering = true; request.ContentType = "application/octet-stream"; try { // get device info String deviceInfo = String.Format("platform,{0};os,{1};width,{2};height,{3};dpi,{4};", Config.PLATFORM_NAME, Environment.OSVersion

Invoke-WebRequest Proxy Bypass

好久不见. 提交于 2019-12-08 06:19:29
问题 How to bypass the default proxy in Windows while accessing a locally accessible URL? By default the Invoke-WebRequest powershell cmdlet is using the default proxy server. In my setup the proxy allows only certain URLs and the locally accessible URL is not in that list. Is there a way to bypass the proxy? I can add the URL to the proxy allowed list but I don't want to do that. Thanks for the attention. 回答1: You can programmatically bypass proxy for local addresses and even return the old

How to post XML document to HTTP with VB.Net

徘徊边缘 提交于 2019-12-08 06:03:52
问题 I'm looking for help with posting my XML document to a url in VB.NET. Here's what I have so far ... Public Shared xml As New System.Xml.XmlDocument() Public Shared Sub Main() Dim root As XmlElement root = xml.CreateElement("root") xml.AppendChild(root) Dim username As XmlElement username = xml.CreateElement("username") username.InnerText = _username root.AppendChild(username) xml.Save(Console.Out) Dim url = "https://mydomain.com" Dim req As WebRequest = WebRequest.Create(url) req.Method =

GUI not responding while fetching data

女生的网名这么多〃 提交于 2019-12-08 04:12:56
问题 My application often fetch data from a webpage using WebRequest, but it isn't possible to click buttons etc while it's fetching. I've understood that I have to use threads/a backgroundworker, but I can't get it to work properly; it doesn't make the GUI more respondable. The code I want to apply some kind of threading on, so that it stops making my application unresponding: public string SQLGet(string query) { string post = "q=" + query; WebRequest request = WebRequest.Create("http://test.com"

Google API Key hits max request limit despite billing enabled

你。 提交于 2019-12-08 02:56:14
问题 I believe I have done everything to properly setup access to the Distance Matrix API. First, I created a project and a billing account. That billing account is enabled on this project. Next, I enabled the Distance Matrix API and created an unrestricted (for now) API key. This is how I am making calls to the Google Distance Matrix API: var requestUri = string.Format("https://maps.googleapis.com/maps/api/distancematrix/xml?units=imperial&mode=driving&origins={0}&destinations={1}&KEY={2}",