Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

[REBOL] Re: http scheme to support cookies

From: gabriele::colellachiara::com at: 16-Apr-2005 16:39

Hi Thomas, On Saturday, April 16, 2005, 2:17:14 PM, you wrote: TC> the scripts in question basically hacked functionnality on top of TC> rebol instead of doing it within rebol. they use weird global TC> variables called "cookie-data" and "cookie-data2" instead of the TC> common datastructure for ports and protocols, they use weird function TC> interfaces such as "tmp: HTTP-TOOLS http://www.rebol.com []" (to fetch TC> a page which sends you a cookie) instead of the familiar read... I agree, however I'm not sure about making REBOL deal with cookies automatically . Anyway, the functionality is almost already there.
>> p: open http://www.qtask.com/
connecting to: www.qtask.com
>> probe p/locals
make object! [ list: [] headers: make object! [ Date: "Sat, 16 Apr 2005 14:28:09 GMT" Server: "Apache/2.0.52 (Fedora)" Last-Modified: none Accept-Ranges: none Content-Encoding: none Content-Type: "text/html; charset=iso-8859-1" Content-Length: none Location: none Expires: "Sat, 16 Apr 2005 14:28:09 GMT" Referer: none Connection: "close" Authorization: none Set-Cookie: "previousurl=http%3A%2F%2Fwww.qtask.com%2Findex.cgi" Vary: "Accept-Encoding" Cache-Control: "max-age=0, must-revalidate" ] ] You can get the cookie from p/locals/headers/Set-Cookie, except that PARSE-HEADER has problems with repeated headers and you only get to see the last one in the object. A quick hack migth be to read directly header-rules/head-list which has all of them. You can send cookies back using the /CUSTOM refinement. Here the problem of using repeated headers is harder to workaround, and you probably need to poke into the handler code to make it work; anyway, it's something like: read/custom http://somesite/ [ header [Cookie: "my-cookie=something"] ] I think that some of these problems have been fixed during the View 1.3 project. Regards, Gabriele. -- Gabriele Santilli <[g--santilli--tiscalinet--it]> -- REBOL Programmer Amiga Group Italia sez. L'Aquila --- SOON: http://www.rebol.it/