httpwebrequest

HttpWebRequest.AllowAutoRedirect=false can cause timeout?

十年热恋 提交于 2019-12-23 21:21:03
问题 I need to test around 300 URLs to verify if they lead to actual pages or redirect to some other page. I wrote a simple application in .NET 2.0 to check it, using HttpWebRequest. Here's the code snippet: System.Net.HttpWebRequest wr = (System.Net.HttpWebRequest)System.Net.HttpWebRequest.Create( url ); System.Net.HttpWebResponse resp = (System.Net.HttpWebResponse)wr.GetResponse(); code = resp.StatusDescription; Code ran fast and wrote to file that all my urls return status 200 OK. Then I

Reading request parameters in Google App Engine with Java [duplicate]

℡╲_俬逩灬. 提交于 2019-12-23 19:53:36
问题 This question already has answers here : GWT: Capturing URL parameters in GET request (4 answers) Closed 6 years ago . I'm modifying the default project that Eclipse creates when you create a new project with Google Web Toolkit and Google App Engine. It is the GreetingService sample project. How can I read a request parameter in the client's .java file? For example, the current URL is http://127.0.0.1:8887/MyProj.html?gwt.codesvr=127.0.0.1&foo=bar and I want to use something like request

Can't send Content-Type header with c# HttpClient

橙三吉。 提交于 2019-12-23 19:11:52
问题 I'm trying to set a Content-Type header in a c# HttpClient request of "multipart/form-data; boundary=----WebKitFormBoundaryaYcxA3wAp5XMUV2w" . So far I've tried using TryAddWithoutValidation which does not throw any exception/error but when I watch the request in fiddler its just not added? See code below. client.DefaultRequestHeaders.TryAddWithoutValidation("Content-Type", "multipart/form-data; boundary=----WebKitFormBoundaryaYcxA3wAp5XMUV2w"); response = client.PostAsync("https://example

How to make HttpWebRequest async

风格不统一 提交于 2019-12-23 19:00:07
问题 I have such code: private async Task<string> Request(url) { Task<string> task = null; try { task = MakeAsyncRequest(url, "text/html"); return await task; } catch { return null; } } private async Task<string> MakeAsyncRequest(string url, string contentType) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url); request.ContentType = contentType; request.Method = WebRequestMethods.Http.Get; request.Timeout = 20000; request.Proxy = null; Task<WebResponse> task = Task.Factory

WebDAV get free space info

落花浮王杯 提交于 2019-12-23 16:27:59
问题 I'm working with Yandex Disk API (http://api.yandex.com/disk/doc/dg/reference/propfind_space-request.xml). Having trouble with adding property in the request body ( quota-available-bytes and quota-used-bytes ) public static string SpaceInfo(string path) { // Authorization. HttpWebRequest webReq = (HttpWebRequest)WebRequest.Create("https://webdav.yandex.ru/"); webReq.Accept = "*/*"; webReq.Headers.Add("Depth: 0"); webReq.Headers.Add("Authorization: OAuth " + token); webReq.Method = "PROPFIND";

HttpWebRequest virtual button click

喜夏-厌秋 提交于 2019-12-23 15:22:42
问题 I have my html-php web page with form, inputs and sumbit button. With html request I\m trying to fill some fields and press a button, but I can't. Here is C# code: public static string PostData(string data) { HttpWebRequest request = (HttpWebRequest)WebRequest.Create("http://localhost/request.php"); //http://businesslist.com/search/clients/?m=userspace&d=addclassified request.Method = "POST"; request.AllowAutoRedirect = true; request.ContentType = "application/x-www-form-urlencoded"; byte[]

Detecting which version of IE is installed on your OS in C#?

若如初见. 提交于 2019-12-23 12:38:33
问题 I am currenting manintaining a windows service that programmatcially generates a HttpWebRequest and HttpWebResponse objects for retrieving the response message of the request. The UserAgent property of the HttpWebRequest was hard coded to use IE 6 as the browser agent. Is the a way to programmatcially detect which version of IE is installed on the server hosting the service? It is currently hosted on a Windows Server 2003 machine and might be installed on a Windows Server 2008 machine. 回答1:

PayPal API, HttpWebRequest throws SSL WebException

时光怂恿深爱的人放手 提交于 2019-12-23 12:32:56
问题 I'm trying to get an PayPal access token as shown here: https://developer.paypal.com/docs/integration/direct/make-your-first-call/#get-an-access-token My C# Code looks like this: HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://api.sandbox.paypal.com/v1/oauth2/token"); request.Headers["Authorization"] = "Basic " + Convert.ToBase64String(Encoding.Default.GetBytes(clientId + ":" + clientSecret)); request.Accept = "application/json"; request.Headers.Add("Accept-Language", "en

Best approach to Timeout using HttpWebRequest.BeginGetResponse

瘦欲@ 提交于 2019-12-23 12:06:42
问题 HttpWebRequest.BeginGetResponse doesn´t respect any Timeout properties from HttpWebRequest(Timeout or ReadWriteTimeout). I read some approaches to get the same results, but I don't know if it's the best way to do it and if I should use for few calls or I can scale it inside loops(I am doing a webcrawler). The important thing is, initially my code isn´t async, I just need async because my method should accept a CancellationToken. My concern is about WaitHandles and ThreadPool

File is downloading through visual studio but not through .exe

爷,独闯天下 提交于 2019-12-23 11:53:16
问题 Am getting the below error when I try to download the a .pdf file from a url through my .exe file. The server committed a protocol violation. Section=ResponseHeader Detail=CR must be followed by LF but the same is getting downloaded when I try to debug the code from visual studio. I am totally lost, no clue of whats going on. Can somebody tell me what could be the problem My App.config file <?xml version="1.0"?> <configuration> <system.net> <settings> <httpWebRequest useUnsafeHeaderParsing=