webrequest

Silverlight ClientHttp WebRequest timeout

跟風遠走 提交于 2019-12-05 08:58:54
I have a silverlight 4 application using the ClientHttp stack to make a WebRequest which serves a binary stream. I then read from this stream and do stuff. However, I have the following problem: the server buffers the data that it sends down, so that the send process is like send-pause-send-pause-send... Sometimes the server takes a little longer pause (around 20 seconds), at which point the connection seems to somehow break. I don't get any exception in Silverlight, actually to the code it looks like the read from the web response stream finished ok (i.e. no more data). However, the server

WebException.Response.GetResponseStream() limited to 65536 characters

半世苍凉 提交于 2019-12-05 06:35:40
I am trying to retrieve HTML code from a webpage using HttpWebRequest and HttpWebResponse. response = (HttpWebResponse)request.GetResponse(); ... Stream stream = response.GetResponseStream(); The response object has a ContentLength value of 106142. When I look at the stream object, it has a length of 65536. When reading the stream with a StreamReader using ReadToEnd(), only the first 65536 characters are returned. How can I get the whole code? Edit: Using the following code segment: catch (WebException ex) { errorMessage = errorMessage + ex.Message; if (ex.Response != null) { if (ex.Response

WebRequest BeginGetResponse/EndGetResponse throws exception when using Task.FromAsync

独自空忆成欢 提交于 2019-12-05 05:08:50
问题 I try to asyncify the POST operation to a REST web service using the WebRequest. So from what I know already, I need to use the Task.Factory.FromAsync<T>(BeginXyz, EndXyz, null) , seems like its working for the GetRequestStream pair methods, since I get no exception and the byte[] is filled with values. Stream requestStream = await Task.Factory.FromAsync<Stream>( request.BeginGetRequestStream, request.EndGetRequestStream, null); byte[] postBytes = Encoding.UTF8.GetBytes(requestData); await

Copying Http Request InputStream

不问归期 提交于 2019-12-04 22:14:23
问题 I'm implementing a proxy action method that forwards the incoming web request and forwards it to another web page, adding a few headers. The action method works file for GET requests, but I'm still struggling with forwarding the incoming POST request. The problem is that I don't know how to properly write the request body to the outgoing HTTP request stream. Here's a shortened version of what I've got so far: //the incoming request stream var requestStream=HttpContext.Current.Request

WebRequest to connect to the Wikipedia API

廉价感情. 提交于 2019-12-04 19:31:41
问题 This may be a pathetically simple problem, but I cannot seem to format the post webrequest/response to get data from the Wikipedia API. I have posted my code below if anyone can help me see my problem. string pgTitle = txtPageTitle.Text; Uri address = new Uri("http://en.wikipedia.org/w/api.php"); HttpWebRequest request = WebRequest.Create(address) as HttpWebRequest; request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; string action = "query"; string query =

Android webrequest simple solution

对着背影说爱祢 提交于 2019-12-04 08:24:16
I want to connect to a web-server (a page) via a simple URL which already contains any parameters I want to sent, like : www.web-site.com/action.php/userid/42/secondpara/23/ and then get the page content which is generated by the site (won't be morde than a simple OK/NOK). How can I manage to do this? I failed to find any example-code or documentation which seems to fit my problem. Thx for helping. try this: public static void connect(String url) { HttpClient httpclient = new DefaultHttpClient(); // Prepare a request object HttpGet httpget = new HttpGet(url); // Execute the request

Using a timeout callback in async requests

和自甴很熟 提交于 2019-12-04 06:37:23
问题 I asked this question before but I'm going to complete the question with a solution proposed and make another question. I'm using this class to make an async WebRequest: class HttpSocket { public static void MakeRequest(Uri uri, Action<RequestCallbackState> responseCallback) { WebRequest request = WebRequest.Create(uri); request.Proxy = null; Task<WebResponse> asyncTask = Task.Factory.FromAsync<WebResponse>(request.BeginGetResponse, request.EndGetResponse, null); ThreadPool

HttpWebRequest.GetRequestStream() breaks by timeout on SSL connection under Windows 7/Vista

送分小仙女□ 提交于 2019-12-04 01:39:31
I have an C# windows application (.Net 3.0 Framework) that makes a call to PHP web service using HttpWebRequest . In Win 7 & Vista , if the call is made via non-SSL (i.e. http:// ), the code works fine. When the call is changed to call the SSL(https:) version of the link, it times out at the HttpWebRequest.GetRequestStream() . This happens every time. When this same application is run on a Windows XP machine it works fine with either the HTTP or the HTTPS url being used. The code does have the accept all server certificates code in it. Also, I have added System.Net logging . It writes out the

Sending Basic authentication over http

試著忘記壹切 提交于 2019-12-04 01:28:49
问题 I am trying to read the source from a page that requires basic authentication. However, using a Header and even Credentials in my HttpWebRequest, I still get a Unauthorized Exception [401] returned. string urlAddress = URL; string UserName = "MyUser"; string Password = "MyPassword"; HttpWebRequest request = (HttpWebRequest)WebRequest.Create(urlAddress); if (UserName != string.Empty) { string encoded = System.Convert.ToBase64String(System.Text.Encoding.GetEncoding("ISO-8859-1").GetBytes

chrome.webRequest.onAuthRequired Listener

坚强是说给别人听的谎言 提交于 2019-12-04 00:51:46
问题 i'm trying to intercept the proxy authorization inside a chrome extension. Following the answer to here: Domain Authorization in Chrome Extension and reading the docs here my code looks like this: chrome.webRequest.onAuthRequired.addListener( function(details, callbackFn) { console.log("onAuthRequired!", details, callbackFn); //callback({ // authCredentials: {username: "1", password: "__TestUse"} //}); }, {urls: ["<all_urls>"]} ); The problem is that callbackFn is undefined but should be a