httpwebrequest

HttpWebRequest losing cookies

I have a client application that is communicating with an ASP.NET web service using cookie-based authentication. (the clients call a login method which sets a persistent cookie that is then re-used across requests within the logon session). This has been working fine for some time, but I have started getting error reports from a few ma...

Receiving and handling a GET request in PHP

I'm trying to replace RSS polling with pubsubhubbub on my site. I'm able to use the subscriber library that google offers to send the subscription request. From the code it looks like it sends a post request via cURL with the RSS URL and a callback URL. So this is where I need some direction: In order to complete the subscription reque...

Error 502 (Bad Gateway) when sending a request with HttpWebRequest over SSL

I have the following snippet in classic ASP, to send a command and retrieve the response over SSL: Dim xmlHTTP Set xmlHTTP = Server.CreateObject("Msxml2.ServerXMLHTTP.3.0") xmlHTTP.open "POST", "https://www.example.com", False xmlHTTP.setRequestHeader "Content-Type","application/x-www-form-urlencoded" xmlHTTP.setRequestHeader "Content-L...

c# - is it ok to embed a "try/catch" within a "using" statement for a web request? Is my code correct?

Hi Is it ok to embed a "try/catch" within a "using" statement for a web request? Is my code correct? That is my requirements are: Want to use the "using" statement to make sure resources are released in any case for HttpWebResponse But still want to do some custom stuff if there is an exception re HttpWebResponse and "response = (...

Async HttpWebRequest with no wait from within a web application

In my web application (ASP.NET) I have a block of code that uses HttpWebRequest to make a call to a REST service and continue execution. Right now it's taking longer than I would like to complete the full web request. The thing is that what the REST service returns isn't useful. Ideally I would like to send an Async web request to the RE...

Reuse a HttpWebRequest?

Am i able to use a HttpWebRequest? It seems like the 3rd request to a site causes a operation timed out and it seems like each creates a new connection so i want to know if i can reuse a HttpWebRequest by changing the url and getting the request again. Code in question is below and this code is to check if a range of urls exist. st...

`post form` parameters difference between firefox and mechanize (ruby/mechanize)

I am trying to figure out if mechanize sends correct post query. I want to log in to a forum (please see html source, mechanize log in my other question) but I get only the login page again. When looking into it I can see that firefox sends out post with parameters like auth_username=myusername&auth_password=mypassword&auth_login=Log...

C# HttpWebRequest.GetResponse - how is StatusCode usage handled for a non-exception vs webexception response?

Hi, Can someone help clear up the usage of the "StatusCode" property in HttpWebResponse and WebException? For example it seems that if: a) there is no exception, then the HttpWebResponse will have a StatusCode that could have some values that indicate both: - success (e.g. OK, Accepted etc) - failure (e.g. UseProxy, RequestTimeout...

Long running HttpWebRequests

I have a ASP.NET web application running on an IIS6 server. The application is making potentially long running calls to a xml service on a remote machine. Some of the service calls on the remote machine are taking a long time to execute (sometimes up to 4 minutes). The long term solution would be to make the calls asyncronous, but as a s...

HttpRequest: pass through AuthLogin

I would need to make a simple program that logs with given credentials to certain website and then navigate to some element (link). It is even possible (I mean this Authlogin thing)? EDIT: SORRY - I am on my company machine and I cannot click on "Vote" or "Add comment" - the page says "Done, but with errors on page" (IE..). I do appreci...

How do I download a file in vb .net with a download timeout?

I want to download thousands of files from the web and save them locally. What is the most efficient way? It is important the failures timeout within 10 seconds. Is there a better way to stream one stream into another? Maybe a smaller buffer, like 1024 bytes at a time, is more efficient for large files? Dim w_req As System.Net.HttpW...

How do I programmatically login into a website that does not return an html response using c#? Tried using HttpWebRequest but it hangs when I call GetResponse()

Hi, I am trying to programmatically login into a website ("http://www.smscountry.com") using C#, but the program hangs at the second GetResponse() request, where I try to login by POST method and filling the form fields. public String GetWebContent(String username, String password) { //The URL of the Login Form ...

How to prevent packet fragmentation for a HttpWebRequest

I am having a problem using HttpWebRequest against a HTTP daemon on an embedded device. The problem appears to be that there is enough of a delay between the http headers being written to the socket stream, and the http payload (a POST), that the socket releases what's in the socket buffer to the server. This results in the HTTP request ...

C# HttpWebRequest Form Post with Progress Tracking (for uploading potentially large files)

I've got a winforms application I'm writing that posts files to a web application (not mine). I've got things working just fine as far as posting the files themselves go, my issue is that I'd like to provide some indication of how far along I am with the sending the request. The code below is my attempt to use BeginGetResponse to that ...

Is there a way to allow Google App Engine to send body or payload with a DELETE request?

I'm attempting to interface with an API that requires XML data to be contained in the body of an HTTP DELETE request. I'm using urlfetch in AppEngine and the payload is simply ignored for DELETE requests. After reading this article: http://stackoverflow.com/questions/299628/is-an-entity-body-allowed-for-an-http-delete-request, I realiz...

Get the KB or speed of a download in .NET

Right now i use either HttpWebRequest or WebClient to download files. I would like to see how many kbytes per second i am currently downloading at. How may i do this? ...

String encoding problem on PdoStatement->bindParam()?

Hi, I'm trying to perform a simple SELECT statement from a string taken from a $_REQUEST var but it seem my PDO statement doesn't like the string format, why? My $_REQUEST var contains a string like Hello+World, so I need to replace + with whitespaces to do my SELECT statement correctly. // the data returned is Hello+World $phrase = st...

C# HttpWebRequest - PreAuthenticate: Still returns 401 forbidden (HTTPS)

Hello, I would like to ask you for help with the following code I have quickly write, beucase I always get "403 FORBIDDEN". HttpWebRequest pozadavek = (HttpWebRequest)WebRequest.Create("LINK THAT ASKS FOR AUTHLOGIN"); //https System.IO.StreamReader stream = null; System.String result = null; public Form1() { Init...

ASP HttpWebRequest and Redirect

OK, I have a client doing a POST to a server with some data. The server receives the post, and answers with a redirect. The problem is that the client does not redirects. Also, I've tried to check the StatusCode of the response the client gets, and it is always the same "OK". Instead of the redirect code. What am I missing? In the clien...

Optimizing HttpWebResponse - GetResponse

I'm using the following lines of code to read the response of an asynchronous HttpWebRequest. This seems to be the largest amount of time spent in a particular operation. Is there anything I can optimize here? System.Net.HttpWebResponse oResp =(System.Net.HttpWebResponse)oReq.EndGetResponse(oResult); oResp = (HttpWebResponse)oReq.GetRes...