[drakma-devel] A simple Cookie and viewing the actual Post
Ryan Davis
ryan at acceleration.net
Mon Feb 13 15:51:14 UTC 2012
It looks like you are wanting a session cookie
(http://en.wikipedia.org/wiki/HTTP_cookie#Session_cookie). These are a
bit of a special case usage of cookies; your server issues each HTTP
client (usually a web browser) a unique ID that is used to track some
state on the server. This is generally impossible to know in advance.
If you trace the HTTP traffic in a browser, I bet you make two requests;
one where the server issues the session cookie (frequently a login
page), and then another that POSTs to node/create.
In drakma you can do the same thing, make two requests, and use the same
'drakma:cookie-jar in both requests. Some psuedo-code:
(let ((cookie-jar (make-instance 'drakma:cookie-jar)))
(drakma:http-request
"http://path/to/create/session"
:method :post
:cookie-jar cookie-jar)
(drakma:http-request
"http://path/to/create/node"
:method :post
:cookie-jar cookie-jar)
)
The drakma:cookie-jar will accept the session cookie from the server in
the first http-request, and then pass it back to the server in the
second http-request. Of course, you'll need to fill out the http-request
parameters to match what your server is asking for.
HTH,
Ryan Davis
Acceleration.net
Director of Programming Services
2831 NW 41st street, suite B
Gainesville, FL 32606
Office: 352-335-6500 x 124
Fax: 352-335-6506
On 2/9/2012 4:32 PM, Michael Minerva wrote:
> I'm sorry if my question is unclear but I just started using Drakma today and I am not very experienced with http-requests in general.
>
> I am trying to create an http-request that looks something like this:
>
> POST /?q=node/create HTTP/1.1
> Host: localhost:8888
> Cookie: SESSdc0685ed01f285dab628a3700259e6bc=rCfmWLUeugRQNAQTs14yox_DWqZyGE2fYUS8W24j4co
> Content-Length: 0
> Content-Type: application/x-www-form-urlencoded
>
> I tried doing this with a cookie-jar and a cookie but the make-instance of cookie required parameters such as name which I do not have (and did not need when I made the http-request by other means). I wanted to see the actual http-post that was being created so I could compare it to other successful http-posts and try and find my problem (is this what header-stream might help with)?
>
> --Mike
> On Feb 9, 2012, at 2:09 PM, Edi Weitz wrote:
>
>> You know about this, don't you?
>>
>> http://weitz.de/drakma/#*header-stream*
>>
>> Otherwise, I don't really understand your question. Perhaps you could
>> tell us what exactly you tried, what happened, and what you expected
>> to happen.
>>
>> Cheers,
>> Edi.
>>
>>
>> On Thu, Feb 9, 2012 at 9:41 PM, Michael Minerva <minerva at agentsheets.com> wrote:
>>> I just started using drakma today and so far it seems really great but I had a couple quesitons.
>>>
>>> First, is it possible to send a simpler for example i want my http-post to have something like this:
>>>
>>> Cookie: SESSdc0685ed01f285dab628a3700259e6bc=rCfmWLUeugRQNAQTs14yox_DWqZyGE2fYUS8W24j4co
>>>
>>> I tried making a drakma cookie and adding it to a cookie-jar but none of that seemed to work.
>>>
>>> Also, is there a way to print the actual post I am sending so I can see what might be wrong with it?
>>>
>>> Thanks a lot,
>>>
>>> --Mike
>>>
>>>
>>> _______________________________________________
>>> drakma-devel mailing list
>>> drakma-devel at common-lisp.net
>>> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel
>> _______________________________________________
>> drakma-devel mailing list
>> drakma-devel at common-lisp.net
>> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel
>>
>
> _______________________________________________
> drakma-devel mailing list
> drakma-devel at common-lisp.net
> http://lists.common-lisp.net/cgi-bin/mailman/listinfo/drakma-devel
More information about the Drakma-devel
mailing list