Hi.
I'm using the Cookie module (on the client side).
I have found a problem trying to parse the cookie:
"Set-Cookie: value=thevalue; path=/;
expires=Fri, 21-May-2004 10:40:51 GMT"
The date is not parsed correctly, only "Fri," is matched.
Thanks and regards Manlio Perillo 13 2121
Manlio Perillo <NO************ ******@libero.i t> pisze: I'm using the Cookie module (on the client side). I have found a problem trying to parse the cookie:
"Set-Cookie: value=thevalue; path=/; expires=Fri, 21-May-2004 10:40:51 GMT"
You must use date in UTC format.
--
Jarek Zgoda http://jpa.berlios.de/
On Sat, 22 May 2004 20:06:45 +0000 (UTC), Jarek Zgoda
<jz****@gazeta. usun.pl> wrote: Manlio Perillo <NO************ ******@libero.i t> pisze:
I'm using the Cookie module (on the client side).
^^^ I have found a problem trying to parse the cookie:
"Set-Cookie: value=thevalue; path=/; expires=Fri, 21-May-2004 10:40:51 GMT"
You must use date in UTC format.
This is the date format used by the server cookie!
Thanks and Regards Manlio Perillo
Manlio Perillo <NO************ ******@libero.i t> pisze: I'm using the Cookie module (on the client side). ^^^ I have found a problem trying to parse the cookie:
"Set-Cookie: value=thevalue; path=/; expires=Fri, 21-May-2004 10:40:51 GMT"
You must use date in UTC format.
This is the date format used by the server cookie!
See http://www.w3.org/TR/NOTE-datetime on how should date look in
cookies. If date is not in valid format, the module functions may have
trouble decoding it.
--
Jarek Zgoda http://jpa.berlios.de/
On Sun, 23 May 2004 18:36:52 GMT, JanC <us*********@ja nc.invalid>
wrote: Manlio Perillo <NO************ ******@libero.i t> schreef:
I'm using the Cookie module (on the client side).
Do you know the ClientCookie module? <http://wwwsearch.sourc eforge.net/ClientCookie/>
Yes, I know; but the standard Cookie module is sufficient.
Thanks and regards
On Sun, 23 May 2004 17:12:25 +0000 (UTC), Jarek Zgoda
<jz****@gazeta. usun.pl> wrote: Manlio Perillo <NO************ ******@libero.i t> pisze:
>You must use date in UTC format. This is the date format used by the server cookie! See http://www.w3.org/TR/NOTE-datetime on how should date look in cookies. If date is not in valid format, the module functions may have trouble decoding it. It is not a my problem!
As you see, it's your problem, since it's you who cann't decode this cookie. ;)
The problem is also of Cookie module. The web server follow the Netscape specification for Cookies and in this spec the date is in the format I have posted.
Netscape is not internet God, W3C is.
Unfortunately we don't live in a perfect world... ;)
I never tried to read cookies using Cookie module (I used Python only for writing), so I cann't help more here. Good luck.
Ok, thanks.
Regards Manlio Perillo
Manlio Perillo <NO************ ******@libero.i t> writes:
[...] I'm trying to fix the regular expression patternin Cookie.py but it does not work:
[...]
Yeah, IIRC there's some odd stuff in there, that doesn't even seem to
come from the standards, let alone reality ;-)
The Cookie module really doesn't know how to handle cookies on the
client side. Use this, which does: http://wwwsearch.sf.net/ClientCookie/
You can just say:
ClientCookie.ur lopen("http://www.example.com/")
and be done with it.
John
On 27 May 2004 22:52:10 +0100, jj*@pobox.com (John J. Lee) wrote: Manlio Perillo <NO************ ******@libero.i t> writes: [...] I'm trying to fix the regular expression patternin Cookie.py but it does not work:[...]
Yeah, IIRC there's some odd stuff in there, that doesn't even seem to come from the standards, let alone reality ;-)
I have fixed the pattern.
For matching spaces it is needed '\ ' and not ' '.
Here is the code.
Now the Cookie parse the Netscape format.
_LegalCharsPatt = r"[\w\d!#%&'~_`><@ ,:/\$\*\+\-\.\^\|\)\(\?\}\ {\=]"
_WeekPatt = r"(?:Mon|Tue|We d|Thu|Fri|Sat|S un)"
_MonthPatt = r"(?:Jan|Feb|Ma r|Apr|May|Jun|J ul|Aug|Sep|Oct| Nov|Dec)"
_DatePatt = r"(?:" + _WeekPatt + r",\ \d{2}-" + _MonthPatt +\
r"-\d{4}\ \d{2}:\d{2}:\d{ 2}\ GMT)"
_CookiePattern = re.compile(
r"(?x)" # This is a Verbose pattern
r"(?P<key>" # Start of group 'key'
""+ _LegalCharsPatt +"+?" # Any word of at least one letter,\
nongreedy
r")" # End of group 'key'
r"\s*=\s*" # Equal Sign
r"(?P<val>" # Start of group 'val'
r'"(?:[^\\"]|\\.)*"' # Any doublequoted string
r"|" # or
""+ _DatePatt + "" # A date as specified by Netscape\
spec
r"|" # or
""+ _LegalCharsPatt +"*" # Any word or empty string
r")" # End of group 'val'
r"\s*;?" # Probably ending in a semi-colon
)
I also have added a method to BaseCookie that behaves like
Morsel.OutputSt ring:
def OutputString(se lf, attrs=None, sep='\n'):
"""Return a string suitable for HTTP.
"""
result = []
items = self.items()
items.sort()
for K,V in items:
result.append( V.OutputString( attrs) )
return sep.join(result )
Now the Cookie is usable on the client side too.
The Cookie module really doesn't know how to handle cookies on the client side.
It does not matter, all the cookie logic for my program is very very
simple and standard Cookie is all I need.
Use this, which does:
http://wwwsearch.sf.net/ClientCookie/
You can just say:
ClientCookie.u rlopen("http://www.example.com/")
and be done with it.
I have seen the module, but it is too complicated.
Standard Cookie module (with my corrections) plus httplib module is
really all I need.
Thanks and regards Manlio Perillo
Manlio Perillo <NO************ ******@libero.i t> writes: On 27 May 2004 22:52:10 +0100, jj*@pobox.com (John J. Lee) wrote:
[...]You can just say:
ClientCookie.u rlopen("http://www.example.com/")
and be done with it.
I have seen the module, but it is too complicated.
Having written it, I agree, but I don't think it's my fault <wink>.
Standard Cookie module (with my corrections) plus httplib module is really all I need.
Cool.
John
On 29 May 2004 12:26:59 +0100, jj*@pobox.com (John J. Lee) wrote: Manlio Perillo <NO************ ******@libero.i t> writes:
On 27 May 2004 22:52:10 +0100, jj*@pobox.com (John J. Lee) wrote:[...] >You can just say: > >ClientCookie.u rlopen("http://www.example.com/") > >and be done with it. >
I have seen the module, but it is too complicated.
Having written it, I agree, but I don't think it's my fault <wink>.
Well, it is too complicated for me. Standard Cookie module (with my corrections) plus httplib module is really all I need.
Cool.
Yes, there exists programs that are simple (as there exist programming
languages that are simple)!
Actually what I do is to download several files from a server.
Some files/pages are generated by a script (so I have to post an
x-www-form-urlencoded string).
I don't want to use urllib2 because it (as I think) for every request
connects to the server, do the request and disconnect.
I need cookies because the server (as many other) authenticate user
with cookies.
So the simple algorithm is:
-connect to the server
-read a cookie from a file
-send the cookie to the server
-if the server send a cookie, the old one must be updated: with
standard Cookie this is simple: cookie.update(n ewcookie)
- ...
- save the cookie to a file
This is very simple to do with httplib and Cookie modules, so why to
use more involved modules?
Regards Manlio Perillo This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: N.K |
last post by:
Hi ,
Python's existing cookie module doesnt supports new cookie headers
SetCookie2 ,
How to submit a patch for that ? I tried emailing person who owns that
module.But no response.
Thanks,
Nirmal
|
by: sh |
last post by:
Hi guys,
Well, I have a (maybe dumb) question.
I want to write my own little blog using Python (as a fairly small but doable
project for myself to learn more deaply Python in a web context).
I don't want so far to use a database as a backend, I'd prefer use XML which is
enough for a small amount of data the blog would have to deal with.
|
by: |
last post by:
I''m having a problem with cookies that is driving me insane :).
- If a user comes to http://domain.com and a cookie is set for them, then the user for whatever reason jumps to http://www.domain.com one of the 2 happens:
1) The cookie we set can not be read (expected), but then a new one can not be written ether (I looked at the server headers and although the cookie information is sent, IE ignores it).
2) The cookie from...
|
by: Mike |
last post by:
1. For some reason after the session has ended and the authentication cookie has expired I'm not being redirected to the login page. Insted I'm be assigned a new authentication cookie? Anyone have any ideas as to what may be causing this? (I'm using Microsoft's example
2. I'm also transferring a forms authentication cookie recieved from a web service (SQL Reporting Services) thru my app to the client. For some reason the expired cookie is...
|
by: thomson |
last post by:
Hi All,
i do hae a solution in which i do have mulitple projects
including Web Projects,, Depending on the functionality it gets
redirected to different web projects and it is working fine,
for eg: http:DomainName/MainProject/index.aspx, If i login, it gets
redirectes to a different Web Project inside the solution like
http://DomainName/MainProject/ChildProject/MyPage.aspx..
| |
by: Larry Rebich |
last post by:
How do I read and write a cookie in an ASP.Net module?
I can get this code to work in an aspx.vb class but not in a regular VB
module:
Response.Cookies.Add(c)
Response is not a recognized command in the module. I've tried importing
System.Web into the module but that is not allowed.
|
by: ccdetail |
last post by:
http://www.tiobe.com/index.htm?tiobe_index
Python is the 7th most commonly used language, up from 8th.
The only one gaining ground besides VB in the top 10.
We're glad, our app is written in python.
It's free at http://pnk.com and it is a web timesheet for project
accounting
|
by: Aek |
last post by:
We recently moved our large codebase over from VS7 to 8 and found that
we now get access violations in atexit calls at shutdown when
debugging the application in VS2005.
This occurs in static members / singletons (especially meyer type
singletons) which use locally declared static variables. These
variables are normally cleaned up automatically at shutdown of the
application by registering with the atexit. I break point the
destructor on...
|
by: rodmc |
last post by:
Hi, I am trying to set a cookie on a client computer using the Cookie
module however all I get is the text being printed in the browser
window. Can anyone point me in the right direction so that the cookie
data is set without it appearing in the browser? A shortened version
of the code is below, in the full version there is also userID check,
this seems to work ok. I have removed that portion for the time being
as its the writing part that...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |