Bugs item #1424148, was opened at 2006-02-04 17:35 Message generated for change (Comment added) made by jjlee You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1424148&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Python Library Group: Python 2.4 Status: Open Resolution: None Priority: 6 Submitted By: Robert Kiendl (kxroberto) Assigned to: Nobody/Anonymous (nobody) Summary: urllib.FancyURLopener.redirect_internal looses data on POST! Initial Comment: def redirect_internal(self, url, fp, errcode, errmsg, headers, data): if 'location' in headers: newurl = headers['location'] elif 'uri' in headers: newurl = headers['uri'] else: return void = fp.read() fp.close() # In case the server sent a relative URL, join with original: newurl = basejoin(self.type + ":" + url, newurl) return self.open(newurl) ... has to become ... def redirect_internal(self, url, fp, errcode, errmsg, headers, data): if 'location' in headers: newurl = headers['location'] elif 'uri' in headers: newurl = headers['uri'] else: return void = fp.read() fp.close() # In case the server sent a relative URL, join with original: newurl = basejoin(self.type + ":" + url, newurl) return self.open(newurl,data) ... i guess? ( ",data" added ) Robert ---------------------------------------------------------------------- Comment By: John J Lee (jjlee) Date: 2006-02-06 00:54 Message: Logged In: YES user_id=261020 This is not a bug. See the long discussion here: http://python.org/sf/549151 ---------------------------------------------------------------------- Comment By: Robert Kiendl (kxroberto) Date: 2006-02-04 20:10 Message: Logged In: YES user_id=972995 Found http://www.faqs.org/rfcs/rfc2616.html (below). But the behaviour is still strange, and the bug even more serious: a silent redirection of a POST as GET without data is obscure for a Python language. Leads to unpredictable results. The cut half execution is not stopable and all is left to a good reaction of the server, and complex reinterpreation of the client. Python urllibX should by default yield the 30X code for a POST redirection and provide the first HTML: usually a redirection HTML stub with < a href=... That would be consistent with the RFC: the User (=Application! not Python!) can redirect under full control without generating a wrong call! In my application, a bug was long unseen because of this wrong behaviour. with 30X-stub it would have been easy to discover and understand ... urllib2 has the same bug with POST redirection. ======= 10.3.2 301 Moved Permanently The requested resource has been assigned a new permanent URI and any future references to this resource SHOULD use one of the returned URIs. Clients with link editing capabilities ought to automatically re-link references to the Request-URI to one or more of the new references returned by the server, where possible. This response is cacheable unless indicated otherwise. The new permanent URI SHOULD be given by the Location field in the response. Unless the request method was HEAD, the entity of the response SHOULD contain a short hypertext note with a hyperlink to the new URI(s). If the 301 status code is received in response to a request other than GET or HEAD, the user agent MUST NOT automatically redirect the request unless it can be confirmed by the user, since this might change the conditions under which the request was issued. Note: When automatically redirecting a POST request after receiving a 301 status code, some existing HTTP/1.0 user agents will erroneously change it into a GET request. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1424148&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com