Skip to main content
gamedev.net
🔒 Locked

HTTP request : login.

Started by FVIRTMAN Sep 10, 2007 at 7:02 AM 2 replies 1k views
Original Post
FVIRTMAN
FVIRTMAN
Hello, I'm currently writing a mini-browser (with C++) I've made sockets, connexion on an HTTP server, and I manage to get the pages with the "GET" method, get the header, and the datas. I manage to download any type of files (easy : just to copy data after header into a binary file, and I write a JPG, or a ZIP...) I have to interpret HTML code, but it is not a problem My problem is about cookies and logins : For exemple : if I want to check my mails, I "get" the login page : I detect the "
code, find variables to fill and send, but how do I send it ? with the "POST"'s HTTP functionnality ? I may receive a cookie, how do I get it ? Do I need to read it ? Or do I just post the login datas, and the server allows me to connect ? I tried to "GET" the link I have once logged, but it send me back a page with code "302 FOUND" (or 203), with the redirection of Login page : sure ! But if I post once the datas about login, will a request like GET on the previous link won't give me the "302 FOUND" anymore ? thx !
hplus0603
hplus0603
RFC 2616 describes the HTTP protocol, including cookies and submission methods.
enum Bool { True, False, FileNotFound };
TehDonutGuy
TehDonutGuy
To submit form data, set the Content-type header to application/x-www-form-urlencoded. The data you want to send should just be input1=value1&input2=value2.... in the data section. Also, don't forget to apply the right value to Content-length.

Cookies will be in the Set-cookie/Set-cookie2 headers in the http response. You send them later in Cookie/Cookie2 headers. Cookies can also be set locally, ie document.cookie = ... in js.

FVIRTMAN
FVIRTMAN
Thx a lot for your answers :)

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.