Kind time of day!
I am writing an application which must:
1) send a POST request to a user specified address (for authorization), while retaining the request to a file.
2) obtain and maintain a file server response with the correct authorization.
3) does not send the correct POST and save to file an answer.
Questions:
1) Is there a common way of authentication on most websites? if possible example.
2) How to maintain the desired me information (cookies, POST, the server response)?
3) How do I upload the site without loss of credentials obtained during authentication?
4) What methods and functions better to use to accomplish this task?
Sorry for my English! :)
Previously very grateful.
Saving POST, GET, Cookies data
Started by LionMdS, Apr 12 2010 09:55 AM
2 replies to this topic
#1
Posted 12 April 2010 - 09:55 AM
|
|
|
#2
Posted 12 April 2010 - 01:46 PM
Assuming you're using C# (you didn't say explicitly) and sending over HTTP, you could use HttpWebRequest and do something like this:
Getting Cookie data is a little more complicated, although I'm a bit vague on whether you need some/all of this information and how you're storing it etc. Either way, I hope that helps a little. For FileServer stuff, check out FtpWebRequest as well.
HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://www.address.com/address.file");
req.Method = "POST";
req.Credentials = new NetworkCredential("username", "password");
byte[] buffer = Encoding.ASCII.GetBytes("var1=blah&var2=bleh");
req.ContentType = "application/x-www-form-urlencoded";
req.ContentLength = postdata.Length;
Stream responseStream = req.GetRequestStream();
responseStream.Write(buffer, 0, buffer.Length);
responseStream.Close();
HttpWebResponse res = req.GetResponse();
//...Whatever you want to do with the response data
Getting Cookie data is a little more complicated, although I'm a bit vague on whether you need some/all of this information and how you're storing it etc. Either way, I hope that helps a little. For FileServer stuff, check out FtpWebRequest as well.
#3
Posted 13 April 2010 - 09:54 AM
Yes i using C#. Sank you for a help! But its not all information what i need. Some body can give me more information? I need to save the POST data to a txt file, and else save the response of a server to another file.


Sign In
Create Account

Back to top









