httpwebresponse

How to unit test a method with HttpWebRequest/Response dependencies

£可爱£侵袭症+ 提交于 2019-12-25 07:05:44
问题 Been trying to unit test this method but can't figure out how to do it. public bool ValidateCaptcha(string captchaResponse, string captchaChallenge, string hostip) { var strPrivateKey = _secConfiguration.CaptchaPrivateKey; var strParameters = "verify?privatekey=" + strPrivateKey + "&remoteip=" + hostip + "&challenge=" + captchaChallenge+ "&response=" + captchaResponse; var url = CaptchaUrl + strParameters; var request = CreateHttpWebRequest(url); request.Proxy.Credentials = CredentialCache

HttpWebResonse hangs on multiple request

牧云@^-^@ 提交于 2019-12-25 04:54:33
问题 I've an application that create many web request to donwload the news pages of a web site (i've tested for many web sites) after a while I find out that the application slows down in fetching the html source then I found out that HttpWebResonse fails getting the response. I post only the function that do this job. public PageFetchResult Fetch() { PageFetchResult fetchResult = new PageFetchResult(); try { HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(URLAddress); HttpWebResponse

httpRequest, httpResponse, send GET through Stream and Receive the Result in C#

拈花ヽ惹草 提交于 2019-12-25 04:19:16
问题 This is what i'm trying to do: Connect to a http service From here, i need to get a STREAM for comunicate with that. Now, i send GET request, and the service answer me. Then, after the first GET request and the answer, i need to intercept everytime the service send me something. How can i do? I'm trying from yesterday with httRequest, httResponse, GetResponseStream and so on, but not working :( How can i have the stream to "talk" with the service sending the GET request? all this for NETCF 3

Download Files From Web Server

China☆狼群 提交于 2019-12-25 04:13:45
问题 I have the following response from a URL. How do I code to download the two files to my hard drive with the name = id. HTTP/1.1 200 OK Content-Type: application/json { "files": [ { "format": "fillz-order-tab", "checksum": "6b86b273ff34fce19d6b804eff5a3f5747ada4eaa22f1d49c01e52ddb7875b4b", "acknowledged": false, "uri": "https://file-api.fillz.com/v1/orders/created/20140611T003336Z-8b975127", "date_created": "20140611T003336Z", "id": "20140611T003336Z-8b975127" }, { "format": "fillz-order-tab",

Get content of response with StatusCode 401

十年热恋 提交于 2019-12-25 00:36:45
问题 I'm trying to establish a connection to a server that sends 401 Authentication Error for all my requests along with the normal html response. e.g. However, I also want to read the HTML response that is sent alongwith so that I can parse that. An example header exchange captured using LiveHTTPHeaders: Clearly, content-length is non-zero. Firefox shows it to be javascript. https://172.31.1.251:1003/fgtauth?73e285357b2dc5cc Request: GET /fgtauth?73e285357b2dc5cc HTTP/1.1 Host: 172.31.1.251:1003

Download file from URL with parameters and authentication required

主宰稳场 提交于 2019-12-24 22:43:02
问题 Sorry for disturbing you, but I tried during more than a week and did no find a simple and efficient way to reach this goal, so I'm here to ask your help. I have a recurrent task in my job that follow this steps: Access my company website; Sign-in; Make a search; Download a KMZ file from the search result page. I do it every week and need to download more then 100 files per time, do you know? I have a list with all result I need, so I created an application in c# to automate this process, but

Getting error in AJAX response on Safari browser only

点点圈 提交于 2019-12-24 13:56:00
问题 I'm facing very strange issue. I'm using below code to get value from an API: var getId = function () { var url: "Proxy:url=https_URL" var result; $.ajax({ type: 'GET', url: url, dataType: 'json', contentType: "application/json", success: function (res) { objLen = res.length; var arrElems = []; for (i = 0; i < objLen; i++) { arrElems[i] = res[i].ids; } result = arrElems; }, error: function (e) { result = e; } }) return result; } Its responsing as success but when I run this code on Safari its

Application hangs on GetRequestStream() after first request

烈酒焚心 提交于 2019-12-24 13:25:52
问题 I've googled and searched here. Some suggest that streams were not being close, others suggested that it's a connection limit with ServicePointManager.DefaultConnectionLimit being set to 1. However, none of these seem to work. My problem is, when i use this for the first time, it works: using (var stream = request.GetRequestStream()) { var data = Encoding.UTF8.GetBytes(post.ToString()); stream.Write(data, 0, data.Length); } When I use it a second time, it freezes. Yes, I'm disposing my stream

crawledPage.HttpWebResponse is null in Abot

人盡茶涼 提交于 2019-12-24 12:34:48
问题 I'm trying to make a C# web crawler using Abot I followed the QuickStart Tutorial but I cannot seem to make it work. It has an unhandled exception in the method crawler_ProcessPageCrawlCompleted , in exactly this line : if (crawledPage.WebException != null || crawledPage.HttpWebResponse.StatusCode != HttpStatusCode.OK) { Console.WriteLine("Crawl of page failed {0}", crawledPage.Uri.AbsoluteUri); } Because crawledPage.HttpWebResponse is null. I'm probably missing something but what ? Notes and

sending httpresponses in library file c#

孤者浪人 提交于 2019-12-24 07:25:20
问题 i used the following code to download the file folder in asp.net website are string path = @"E:\sample.zip"; FileInfo file = new FileInfo(path); int len = (int)file.Length, bytes; Response.ContentType = "text/html"; // Response.AddHeader "Content-Disposition", "attachment;filename=" + filename; Response.AppendHeader("content-length", len.ToString()); byte[] buffer = new byte[1024]; using(Stream stream = File.OpenRead(path)) { while (len > 0 && (bytes = stream.Read(buffer, 0, buffer.Length)) >