httpwebrequest

This stream does not support seek operations. HttpWebResponse

限于喜欢 提交于 2020-01-02 03:54:07
问题 I'm making a program which downloads files over http. I've got it downloading, however I want to be able to pause the downloads, close the program and resume them again at a later date. I know the location i'm downloading them from supports this. I'm downloading the file through HttpWebResponse and reading the response into a Stream using GetResponseStream. When i close the app and restart it, I'm stuck as to how resume the download. I've tried doing a seek on the stream but it states its not

Content Length of HTTP Request > body size

孤街醉人 提交于 2020-01-02 03:37:07
问题 I'm managing a web site which is running fine for last couple of months over IIS 7.5 built with MVC 3.0 ASP.net. Every now and then we are facing a problem when our AJAX POST request (fired through jQuery) fails as the JSON being posted is getting truncated. What we've found so far is that for all such request, the "Content-Length" header of the request has more data than we are actually getting in the request. We've already set maxRequestLength to 51200 in our web.config and I believe the

HttpWebRequest gets slower when adding an Interval

旧街凉风 提交于 2020-01-01 19:17:50
问题 Testing different possibilities to download the source of a webpage I got the following results (Average time in ms to google.com, 9gag.com): Plain HttpWebRequest: 169, 360 Gzip HttpWebRequest: 143, 260 WebClient GetStream : 132 , 295 WebClient DownloadString: 143, 389 So for my 9gag client I decided to take the gzip HttpWebRequest. The problem is, after implementing in my actual program, the request takes more than twice the time. The Problem also occurs when just adding a Thread.Sleep

Diagnostic dump of HttpWebRequest object

陌路散爱 提交于 2020-01-01 15:37:13
问题 Is there any good way (other than tediously querying each property) to build a diagnostic dump string for an HttpWebRequest in C#? For simple objects one can get away with using new JObject(theObject) , but that doesn't work for HttpWebRequest (and toString is, of course, as useless on HttpWebRequest as it is on any C# object). Is there any general way to do this for any subset of C# objects (other than using new JObject as I already mentioned)? Update: I've found that using JsonConvert

Making a REST API request in PHP

放肆的年华 提交于 2020-01-01 15:05:25
问题 Apologies for newbishness of this question. I'm looking into integrating one website's API into my own website. Here's some quotes from their documentation: At the moment we only support XML, when calling our API the HTTP Accept header content type must be set to “application/xml”. The API uses the PUT request method. I have the XML I want to send, and I have the URL I want to send it to, but how do I go about constructing a suitable HTTP Request in PHP that will also grab the XML that's

HttpWebRequest for ShoutCast on Windows Phone7

谁说我不能喝 提交于 2020-01-01 14:36:15
问题 I tring to stream shoutcast stream in my window phone 7 app I start an async HttpWebRequest like this //Init Request HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create("http://ACommonoShoutCastUrl:8000"); myHttpWebRequest.Headers["Icy-MetaData"] = "1"; myHttpWebRequest.UserAgent = "WinampMPEG/5.09"; myHttpWebRequest.AllowReadStreamBuffering = true; //Call // Create an instance of the RequestState and assign the previous myHttpWebRequest object to its request field.

Check response time with HTTPWebRequest?

拜拜、爱过 提交于 2020-01-01 08:25:28
问题 I'm trying to find the performance of some of my proxies. I tried the Ping class in .net but it does not accept ports. Is there a way to check how long a response took with httpwebrequest ? 回答1: HttpWebRequest request = (HttpWebRequest)WebRequest.Create(myUri); System.Diagnostics.Stopwatch timer = new Stopwatch(); timer.Start(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); response.Close (); timer.Stop(); TimeSpan timeTaken = timer.Elapsed; 回答2: Why not just time it from

Proper way to handle the ampersand character in JSON string send to REST web service

二次信任 提交于 2020-01-01 06:31:26
问题 OK, I am using the System.Runtime.Serialization and the DataContractJsonSerialization . The problem is that in the request I send a value of a property with the & character. Say, AT&T , and I get a response with error: Invalid JSON Data . I thought that the escaping would be done inside the library but now I see that the serialization is left untouched the ampersand & character. Yes, for a JSON format this is valid. But it will be a problem to my POST request since I need to send this to a

how to send url parameter in POST request without form

若如初见. 提交于 2020-01-01 05:37:06
问题 I have to pass a parameter in url. I can't send it in as usual GET request the variable and value is shown in the address bar with the request. So, the end user can change the value for this variable value and send request which will be processed. href="url=/admin/usermanagement/?flag=2 I want to send this hiding flag=2 now this goes as a GET request and it is seen in the address bar. Please give your suggestion if you have any idea on changing this to POST to hide and send the value. 回答1:

Setting per request value for ServicePointManager.SecurityProtocol [duplicate]

可紊 提交于 2020-01-01 04:06:11
问题 This question already has answers here : Set the SecurityProtocol (Ssl3 or TLS) on the .net HttpWebRequest per request (9 answers) Closed 5 years ago . In c# I am able to set a static value for SSL3 or TLS, e.g. ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls; Or: ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3; But (I believe) this will affect all future HttpWebRequest objects in my application. Is there a way to set this for a given HttpWebRequest or at