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

Passing a cookie back to the server

 [1/12] from: rsaathoff:datajunction at: 8-Jun-2001 11:34


Hi all, I was wondering it it was possible to pass a cookie back to the server using REBOL, and if so how to go about doing it. Thanks! Ryan

 [2/12] from: gjones05:mail:orion at: 8-Jun-2001 14:51


From: "Ryan"
> Hi all, > I was wondering it it was possible to pass a cookie back > to the server using REBOL, and if so how to go about > doing it. Thanks!
Hi, Ryan, Give my new patch a whirl, if you wish. http://www.escribe.com/internet/rebol/m10303.html First, to collect the cookie: fp: open http://my.cookie-site.com my-cookie: copy fp/locals/headers/set-cookie data: copy fp ;to get page information close fp then, use the cookie like so... page: read http://my.cookie-site.com reduce ['cookie mold my-cookie] Let me know how it works. Meanwhile, the way that many have used for several years can be found at: http://www.reboltech.com/library/scripts/cookies-client.r or http://www.reboltech.com/library/html/cookies-client.html --Scott Jones

 [3/12] from: gchiu:compkarori at: 9-Jun-2001 8:55


On Fri, 8 Jun 2001 14:51:56 -0500 "GS Jones" <[gjones05--mail--orion--org]> wrote:
> then, use the cookie like so... > > page: read http://my.cookie-site.com reduce ['cookie mold > my-cookie]
Hi Scott, What's the syntax for read/custom ie. posting data as well as sending a cookie? -- Graham Chiu

 [4/12] from: petr:krenzelok:trz:cz at: 8-Jun-2001 23:24


----- Original Message ----- From: "Graham Chiu" <[gchiu--compkarori--co--nz]> To: <[rebol-list--rebol--com]> Sent: Friday, June 08, 2001 10:55 PM Subject: [REBOL] Re: Passing a cookie back to the server
> On Fri, 8 Jun 2001 14:51:56 -0500 > "GS Jones" <[gjones05--mail--orion--org]> wrote:
<<quoted lines omitted: 6>>
> What's the syntax for read/custom ie. posting data as well > as sending a cookie?
page: read/custom http://my.post-site.com reduce ['post post-string] however, if for e.g. the request serves for download of big file, it will eat your memory. Even using 'open will not help here. There seem to be no simple way of partial readout from the port, simply to construct something like while [data: copy/part my-opened-port buffer-size][insert local-opened-file data] Or am I wrong? :-) -pekr-

 [5/12] from: gjones05:mail:orion at: 8-Jun-2001 17:44


From: "Graham Chiu"
> "GS Jones" <[gjones05--mail--orion--org]> wrote: > >
<<quoted lines omitted: 5>>
> What's the syntax for read/custom ie. posting data as well > as sending a cookie?
Hi, Graham, Your question has spurred two issues. First, as you may have already noticed, I *forgot* to put the custom refinement in the above instruction ("If I only had a brain," Scarecrow - Wizard of Oz). Second, as I mentioned, the cookie has not tried with a post, and with your question, I suddenly realized that there may be a bug (there is an error in logic, but it may still work despite this oversite). I haven't had (taken) the time to find a site to try this out on yet. :-( The syntax is **supposed** to be like this: page: read/custom http://my.cookie-site.com reduce [ 'cookie mold my-cookie 'post "data: 10" ] or this if no reduction/molding is needed (yuck, mold on the cookies;-): page: read/custom http://my.cookie-site.com [ cookie my-cookie post "data: 10" ] Again, please don't spend a lot of time on it if it doesn't work easily. I should be able to get a much closer look at it this weekend and test it like it should have been before posting it to the list!! Do feel free to give me feedback, though. :-) And Petr Krenzelok wrote separartely:
> page: read/custom http://my.post-site.com reduce ['post post-string]
yes, thanks for catching my oversite!!
> however, if for e.g. the request serves for download of big file, it will > eat your memory. Even using 'open will not help here. There seem to be no > simple way of partial readout from the port, simply to construct something > like while [data: copy/part my-opened-port buffer-size][insert > local-opened-file data] > > Or am I wrong? :-)
I was thinking early that maybe there is a way to include the following three things: 1) cookie management (getting/sending and otherwise) 2) port control for managing longer downloads 3) basic authorization The /custom refinement leaves some room for managing the transaction in a ... well ... custom way (hey, maybe they should call it /custom refinement ... oh, they did;-). I'm getting more comfortable poking around in the schemes, so maybe this weekend I can get some of this ironed out, and firm up the ideal syntax. (But I still need to finish my Command and Control Script written in the Prez dialect for replacing the space shuttle's Ada programs!!!! That is OK, right, Jeff K.? ;-) Sorry about the syntax oversite. --Scott Jones

 [6/12] from: gjones05:mail:orion at: 9-Jun-2001 9:05


From: "GS Jones"
> I should be able to get a much closer look at > it this weekend and test it like it > should have been before posting it to the list!! > > Do feel free to give me feedback, though. :-)
Hi, Graham, et al, The following types of syntax work. a: read/custom http://127.0.0.1/archive/cookie-get-post.php [ cookie "TestCookie=Test+Value" post "field=MyField"] c: "TestCookie=Test+Value" b: "field=MyField" a: read/custom http://127.0.0.1/archive/cookie-get-post.php reduce [ 'cookie c 'post b] a: read/custom http://127.0.0.1/archive/cookie-get-post.php reduce [ 'cookie "TestCookie=Test+Value" 'post b] a: read/custom http://127.0.0.1/archive/cookie-get-post.php reduce [ 'cookie c 'post "field=MyField"] Reversing the order of 'cookie and 'post doesn't matter. All in all it works better than I figured for a first shot. I will warn though that in the wild (the "real" Internet), I've had less success finding a site that takes cookies and has a simple enough form to check. As examples, eBay combinations of cookies and forms appear to work with limited testing, but Yahoo sign-in is a mess because of all the cross checks they do (it would take longer to set up the test than it took to hack the http scheme!). I really am interested in gettin feedback. Meahwhile, I will do more thinking and checking on the other things that would be nice to have that I mentioned before. Cheer-ios, --Scott Jones

 [7/12] from: gchiu:compkarori at: 10-Jun-2001 12:14


> I really am interested in gettin feedback. Meahwhile, I > will do more thinking > and checking on the other things that would be nice to > have that I mentioned > before.
Hi Scott, As you say, in the wild Internet, things get a little more complicated. For instance, when you reach my site, I initially send a session cookie to the browser. A session cookie is only supposed to last the life of the browser session. When the client browser logs in, eg: a: read/custom http://mysite.co.nz reduce [ 'cookie mycookie 'post {userid=scott&password=etc} ] I then send another persistent cookie to the browser, and my site now checks for 2 cookies. So, read/custom has to also catch all the new cookies coming down the line. This is what I do in the htpp-tools.r So, maybe the syntax should be open/custom http://userid:[password--www--nabisco--com] reduce [ 'cookie mycookie 'post data ] ? -- Graham Chiu

 [8/12] from: gjones05:mail:orion at: 9-Jun-2001 20:32


> From "Scott Jones" > > I really am interested in gettin feedback. > > Meahwhile, I will do more thinking and > > checking on the other things that would > > be nice tohave that I mentioned before.
From: "Graham Chiu"
> As you say, in the wild Internet, things get a little more > complicated.
<<quoted lines omitted: 4>>
> a: read/custom http://mysite.co.nz reduce [ 'cookie mycookie > 'post {userid=scott&password=etc} ]
Hey! How did you know my password! ;-)
> I then send another persistent cookie to the browser, and my > site now checks for 2 cookies. > > So, read/custom has to also catch all the new cookies coming > down the line. This is what I do in the htpp-tools.r
Wow, so it sounds like I have been reinventing the wheel. (Now, let's see, 2 x PI x R seems like a good guess, let me try that...). Several months ago I thought I had looked at all the most recent additions to the http arena. I guess your update came soon thereafter. Shame on me for not re-looking and asking! Well, that is only partially true. As I have mentioned elsewhere, I look for little projects that help me to improve my skills, and schemes are one of the areas in which I am trying to gain proficiency. After working on the ftp scheme and then the http scheme, I started thinking that a more generic solution was needed. It looks as though you (and the others) were way ahead of me in that arena. The main (and only) advantage I can think of with hacking the http scheme itself is that ssl, tls, tunneling, and encryption, etc, will be transparently supported. Do you think that this would be beneficial?
> So, maybe the syntax should be > > open/custom http://userid:[password--www--nabisco--com] reduce [ > 'cookie mycookie 'post data ]
It looks like it won't be too difficult to snag the return cookies even with a read (it sounds odd, but RT's schemes are really, really clever). I was looking at this section of the protocol for the specific purpose of allowing custom direct reads of large files (I was working on this with Petr K). The same section could snag the incoming cookie, ready for passing on the next read. Believe me, I am not trying to take away from your work (by the way, your code is always incredibly easy to read, which is a Good Thing, which is a compliment in case it was not obvious). As odd as it sounds, I am not a cookie kind of person, but I, too, need them for certain sites, and it would be nice if REBOL handled them more transparently. I mainly am doing this as a way to improve my skills. I am very glad to know of your improvements to our cookie mainstay by Andrew Grossman, and the addition of Martin Johannesson's POST script. It will be nice to recommend a more tried and true script. It will leave me to do my Frankenstein hacks in total safety!!! Now, back to what I was doing. let's see, the area of one surface of a cookie is PI x R x R, and if the chocolate chips are even distributed ..... Thanks for the info and enjoy what's left of your Sunday! --Scott Jones

 [9/12] from: gchiu:compkarori at: 10-Jun-2001 15:44


> thought I had looked at all the most recent additions to > the http arena. I > guess your update came soon thereafter. Shame on me for
Actually Dec 2000. After a hiatus of a year, I went back then to trying to figure out why the mods I made to cookies-client.r weren't working with one particular site.
> arena. The main (and only) advantage I can think of with > hacking the http > scheme itself is that ssl, tls, tunneling, and > encryption, etc, will be > transparently supported. Do you think that this would be > beneficial?
Absolutely. Interestingly my recollection is that when Rebol was first released, 'read did include all the headers, but then it was improved and hidden from us.
> (by the way, your code > is always incredibly easy to read, which is a Good Thing,
Thanks <blush>. I guess it's a reflection of my exposure to forth <grin>.
> person, but I, too, need them for certain sites, and it > would be nice if REBOL > handled them more transparently. I mainly am doing this
I agree, and I don't understand why RT haven't implemented transparent cookie handling into core yet, unless they don't consider it a priority. -- Graham Chiu

 [10/12] from: gjones05:mail:orion at: 10-Jun-2001 5:35


From "Scott Jones"
> > thought I had looked at all the most > > recent additions to the http arena. I > > guess your update came soon thereafter. > > Shame on me for
From: "Graham Chiu"
> Actually Dec 2000.
Oh. =0 OK, so I guess it is more like what a "kind" medical school prof once told me. He said that I had three neurons in my brain, and that one was syphilitic, the second was neuritic, and the third that connected the other two was suffering from Alzheimer's. Gee, that was so much fun, may I go back??
> > arena. The main (and only) advantage > > I can think of with hacking the http
<<quoted lines omitted: 6>>
> did include all the headers, but then it was > improved and hidden from us.
I guess that progress sometimes comes at a cost. It was like I "AR" and I were talking about last week, sometimes a simple recursive directory listing in FTP would be nice. The advanced functionality offered by the current FTP scheme means that one has to write a routine to get a simple listing. I am not gripping; all in all I get more work done in REBOL than any other language.
> > person, but I, too, need them for certain sites, > > and it would be nice if REBOL handled them > > more transparently. I mainly am doing this > > I agree, and I don't understand why RT haven't > implemented transparent cookie handling into > core yet, unless they don't consider it a priority.
Yes, when resources are limited, one must keep the eyes on the prize. The one recurring thought that I keep having reflects on the early days of the Microsoft and IBM alliance on creating a next generation OS. If memory serves (and this *is* a big if), IBM wanted to totally break with the past tradition of MS-DOS, and Microsoft wanted to create a more gentle transition so that legacy apps could be run until they were recoded. Ultimately, they split the partnership with IBM going to OS2 and Microsoft going to NT and gentle updating of MS-DOS/Windows. I think we know who won that war. Clean breaks with the past can allow one to indulge in a totally new vision of how the world should work. The new vision presented by REBOL makes cookies seem rather anachronistic. A REBOL reb, by design, can allow for intelligent statefulness, as opposed to the stateless HTTP request with the "after-thought hack" called cookies (no insult intended; the transparency of the model of non-linear http links makes gopher look postively brain dead, but surely Tim Berners-Lee must recognize cookies as being a bit of a tacked on hack). Here is where studying history sometimes pays off. It gives one insight into the human pysche and motivations. We are reluctant to make breaks with the past if for no other reason than loss of investment. A major infrastructure has been built upon http's stateless model and the tacked-on cookies and sessions. A smooth, transparent management of this historical legacy goes along way towards acceptance, which then sets the stage for the next leap. From role-playing a bit as Dr. Frankenstein, non-ace hacker, it seems as though cookies could be readily integrated into the existing framework. Did I get off topic? Not really. Nabisco has a very large interest in cookie distribution, and your update goes a long way towards consuming those cookies (and toasted posts). (By the way, I assumed that they were "digestive biscuits" in NZ?? Here is where the first-class semantic mapping puts REBOL ahead of the curve: digestive-biscuits: :cookies ;-). --Scott Jones

 [11/12] from: gchiu:compkarori at: 10-Jun-2001 23:34


On Sun, 10 Jun 2001 05:35:04 -0500 "GS Jones" <[gjones05--mail--orion--org]> wrote:
> OK, so I guess it is more like what a "kind" medical > school prof once told me. > He said that I had three neurons in my brain, and that > one was syphilitic, the
That's a coincidence. I had the same education. Though I doubt any of my lecturers would have been so "kind" to our faces :-). Ours was an experimental syllabus, and in our first year, we were taught Fortran for a semester. I guess they wanted some of us to become medical computer scientists!
> I guess that progress sometimes comes at a cost. It was > like I "AR" and I were
<<quoted lines omitted: 6>>
> gripping; all in all I get more work done in REBOL than > any other language.
I'm not so sure about this cost and wonder if better factoring would eliminate these problems.
> apps could be run until they were recoded. Ultimately, > they split the > partnership with IBM going to OS2 and Microsoft going to > NT and gentle updating > of MS-DOS/Windows. I think we know who won that war.
I recall this differently. I read that Microsoft learnt a lot about writing an operating system from IBM during this period, and at the same time screwed IBM so that OS/2 was stuck into a 286 archictecture.
> Clean breaks with the past can allow one to indulge in a > totally new vision of
<<quoted lines omitted: 3>>
> for intelligent > statefulness, as opposed to the stateless HTTP request
Except of course that the WWReb comes a couple of years after Rebol, and we are still stateless unless running Rebol/Express.
> bit as Dr. Frankenstein, non-ace hacker, it seems as > though cookies could be > readily integrated into the existing framework.
I think it just requires the nod from the architect :-)
> (By the way, I assumed that they were "digestive > biscuits" in NZ?? Here is where > the first-class semantic mapping puts REBOL ahead of the > curve: > digestive-biscuits: :cookies ;-).
Just plain "biscuits". -- Graham Chiu

 [12/12] from: gjones05:mail:orion at: 10-Jun-2001 7:13


From: "Graham Chiu" ...
> Ours was an experimental syllabus, and in our > first year, we were taught Fortran for a semester. I guess > they wanted some of us to become medical computer > scientists!
The dawn of medical informatics, no doubt, and what finer language to use than Fortran! Oh, sarcasm, how it doth suit me!
> > Ultimately, they split the partnership with IBM going to > > OS2 and Microsoft going to NT and gentle updating > > of MS-DOS/Windows. I think we know who won that > > war. > > I recall this differently. ...
Now you know why the middle neuron was considered to be suffering from Alzheimer's!!! I really must institute some form of statefulness for my brain! ;-) --Scott Jones

Notes
  • Quoted lines have been omitted from some messages.
    View the message alone to see the lines that have been omitted