Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(23)

Side by Side Diff: Lib/urllib/request.py

Issue 17485: Deleting Request data does not update Content-length header.
Patch Set: Created 6 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « Lib/test/test_urllib2.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 """An extensible library for opening URLs using a variety of protocols 1 """An extensible library for opening URLs using a variety of protocols
2 2
3 The simplest way to use this module is to call the urlopen function, 3 The simplest way to use this module is to call the urlopen function,
4 which accepts a string containing a URL or a Request object (described 4 which accepts a string containing a URL or a Request object (described
5 below). It opens the URL and returns the results as file-like 5 below). It opens the URL and returns the results as file-like
6 object; the returned object has some extra methods described below. 6 object; the returned object has some extra methods described below.
7 7
8 The OpenerDirector manages a collection of Handler objects that do 8 The OpenerDirector manages a collection of Handler objects that do
9 all the actual work. Each Handler implements a particular protocol or 9 all the actual work. Each Handler implements a particular protocol or
10 option. The OpenerDirector is a composite object that invokes the 10 option. The OpenerDirector is a composite object that invokes the
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
289 if data != self._data: 289 if data != self._data:
290 self._data = data 290 self._data = data
291 # issue 16464 291 # issue 16464
292 # if we change data we need to remove content-length header 292 # if we change data we need to remove content-length header
293 # (cause it's most probably calculated for previous value) 293 # (cause it's most probably calculated for previous value)
294 if self.has_header("Content-length"): 294 if self.has_header("Content-length"):
295 self.remove_header("Content-length") 295 self.remove_header("Content-length")
296 296
297 @data.deleter 297 @data.deleter
298 def data(self): 298 def data(self):
299 self._data = None 299 self.data = None
300 300
301 def _parse(self): 301 def _parse(self):
302 self.type, rest = splittype(self.full_url) 302 self.type, rest = splittype(self.full_url)
303 if self.type is None: 303 if self.type is None:
304 raise ValueError("unknown url type: %s" % self.full_url) 304 raise ValueError("unknown url type: %s" % self.full_url)
305 self.host, self.selector = splithost(rest) 305 self.host, self.selector = splithost(rest)
306 if self.host: 306 if self.host:
307 self.host = unquote(self.host) 307 self.host = unquote(self.host)
308 308
309 def get_method(self): 309 def get_method(self):
(...skipping 2294 matching lines...) Expand 10 before | Expand all | Expand 10 after
2604 """ 2604 """
2605 if getproxies_environment(): 2605 if getproxies_environment():
2606 return proxy_bypass_environment(host) 2606 return proxy_bypass_environment(host)
2607 else: 2607 else:
2608 return proxy_bypass_registry(host) 2608 return proxy_bypass_registry(host)
2609 2609
2610 else: 2610 else:
2611 # By default use environment variables 2611 # By default use environment variables
2612 getproxies = getproxies_environment 2612 getproxies = getproxies_environment
2613 proxy_bypass = proxy_bypass_environment 2613 proxy_bypass = proxy_bypass_environment
OLDNEW
« no previous file with comments | « Lib/test/test_urllib2.py ('k') | no next file » | no next file with comments »

RSS Feeds Recent Issues | This issue
This is Rietveld 894c83f36cb7+