classification
Title: urllib still doesn't support persistent connections
Type: behavior Stage: resolved
Components: Documentation, Library (Lib) Versions: Python 3.2, Python 3.3, Python 3.4, Python 2.7, Python 2.6
process
Status: closed Resolution: duplicate
Dependencies: Superseder: In http.cookiejar.FileCookieJar() the .load() and .revert() methods don't work
View: 16901
Assigned To: docs@python Nosy List: C19, demian.brecht, docs@python, orsenthil, r.david.murray, terry.reedy
Priority: normal Keywords: patch

Created on 2013-01-12 08:12 by C19, last changed 2013-04-20 17:48 by orsenthil. This issue is now closed.

Files
File name Uploaded Description Edit
cookiejar_16942.patch demian.brecht, 2013-02-24 01:18 review
Messages (9)
msg179777 - (view) Author: C19 (C19) Date: 2013-01-12 08:12
Is it means that we should use MozillaCookieJar LWPCookieJar or MSIECookieJar?

But the document says "perhaps save cookies to, a file on disk. "
http://docs.python.org/2/library/cookielib.html?highlight=filecookiejar#cookielib.FileCookieJar

it looks like FileCookieJar is just a base class.it shouldn't be used on normal purpose(like save your cookie).then the document should be modified.
but I think it's better to make the FileCookieJar works as expected.
msg179778 - (view) Author: C19 (C19) Date: 2013-01-12 08:22
# TODO(jhylton): Should this be redesigned to handle
        # persistent connections?

        # We want to make an HTTP/1.1 request, but the addinfourl
        # class isn't prepared to deal with a persistent connection.
        # It will try to read all remaining data from the socket,
        # which will block while the server waits for the next request.
        # So make sure the connection gets closed after the (only)
        # request.
        headers["Connection"] = "close"

http://bugs.python.org/issue9740
this has been a long time..how many is annoyed by this..Count me in..
persistent connections may not be easy on various OS and act the same.
I'm just satisfied if it works on linux.
msg179780 - (view) Author: C19 (C19) Date: 2013-01-12 08:36
https://github.com/shazow/urllib3
do we really have to use a 3rd party module for this ?..
msg179793 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2013-01-12 13:52
Please open a separate issue for your enhancement request in your second message (assuming there isn't already one open).  I'm not sure what your third message is about, but it also sounds off topic for your original bug report.

For the FileCookieJar issue, I agree that the documentation is unclear.  However, it is perfectly reasonable to have a documented base class that is an Abstract Base Class, and there is no reason for us to invent our own unique cookie file format just to make FileCookieJar work by itself.  ABCs didn't exist when FileCookieJar was implemented, so it should be turned in to one for 3.4 (it might break working code, so we shouldn't do that for bug fix releases).  That way you would get a useful error when you try to instantiate it, rather than when you try to use it.  And the docs should document it as being a base-class-only for all active releases.
msg182845 - (view) Author: Demian Brecht (demian.brecht) * (Python triager) Date: 2013-02-24 01:18
I've changed FileCookieJar to use the ABCMeta metaclass and updated the concrete implementations. If this patch looks sufficient, I'll make an update to the docs as well.
msg183020 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-02-26 05:53
+class FileCookieJar(CookieJar, metaclass=ABCMeta):
+    """Abstract Base Class for any file-based CookieJar."""

Is it just me or is it a bit strange to derive an abstract base class from a concrete class? Is CookieJar meant to be directly used?

+        with open(self.filename) as f:
+            magic = f.readline()
+            if not self.magic_re.search(magic):
+                f.close()
+                raise LoadError(
+                    "%r does not look like a Netscape format cookies 

f.close() seems not needed as doing that in __exit__ as a major point of with open... statements.
msg183103 - (view) Author: Demian Brecht (demian.brecht) * (Python triager) Date: 2013-02-27 00:45
http://bugs.python.org/issue1690 seems to be a duplicate of this one (at least the initial report). 16901 (imho) is documented more clearly than this one, so can this one be closed as duplicate?
msg186270 - (view) Author: Demian Brecht (demian.brecht) * (Python triager) Date: 2013-04-08 04:06
Just noticed there was a typo in the link in my previous post. It should be directing to issue# 16901.
msg187444 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-04-20 17:48
Agree with Demian Brecht. This issue is being closed in when two issues cover the requirements discussed here.

* issue# 16901 - For Enhancing FileCookieJar
* issue# 9740 - For supporting persistant HTTP 1.1 connections. 

(:-( on me)
History
Date User Action Args
2013-04-20 17:48:44orsenthilsetstatus: open -> closed

superseder: In http.cookiejar.FileCookieJar() the .load() and .revert() methods don't work

nosy: + orsenthil
messages: + msg187444
resolution: duplicate
stage: needs patch -> resolved
2013-04-08 04:06:52demian.brechtsetmessages: + msg186270
2013-02-27 00:45:02demian.brechtsetmessages: + msg183103
2013-02-26 05:53:13terry.reedysetnosy: + terry.reedy
messages: + msg183020
2013-02-24 01:18:50demian.brechtsetfiles: + cookiejar_16942.patch
keywords: + patch
messages: + msg182845
2013-02-24 00:45:51demian.brechtsetnosy: + demian.brecht
2013-01-12 13:52:23r.david.murraysetassignee: docs@python
type: enhancement -> behavior
components: + Documentation, Library (Lib)
versions: + Python 3.4, - Python 3.1
nosy: + docs@python, r.david.murray

messages: + msg179793
stage: needs patch
2013-01-12 09:46:22Ramchandra Aptesettitle: seriously? urllib still doesn't support persistent connections? -> urllib still doesn't support persistent connections
2013-01-12 08:58:22nadeem.vawdalinkissue16943 superseder
2013-01-12 08:36:32C19setmessages: + msg179780
2013-01-12 08:22:58C19setversions: + Python 2.6, Python 2.7
messages: + msg179778
title: seriously? http.cookiejar.FileCookieJar().save method NOTImplemented? -> seriously? urllib still doesn't support persistent connections?
2013-01-12 08:12:56C19create