← Back to team overview

launchpad-reviewers team mailing list archive

Re: [Merge] lp:~cjwatson/launchpad/librarian-check-content-length into lp:launchpad

 


Diff comments:

> 
> === modified file 'lib/lp/services/librarian/client.py'
> --- lib/lp/services/librarian/client.py	2015-12-10 00:37:05 +0000
> +++ lib/lp/services/librarian/client.py	2016-05-31 17:06:57 +0000
> @@ -285,6 +286,18 @@
>      def __init__(self, file, url):
>          self.file = file
>          self.url = url
> +        headers = file.info()
> +        chunked = (headers.get("Transfer-Encoding") == "chunked")
> +        if not chunked and "Content-Length" in headers:

Fortunately not.  headers is an instance of rfc822.Message, which handles the case-insensitivity: https://docs.python.org/2/library/rfc822.html#rfc822.Message

> +            try:
> +                self.length = int(headers["Content-Length"])
> +            except ValueError:
> +                self.length = None
> +            else:
> +                if self.length < 0:
> +                    self.length = None
> +        else:
> +            self.length = None
>  
>      def read(self, chunksize=None):
>          request = get_current_browser_request()


-- 
https://code.launchpad.net/~cjwatson/launchpad/librarian-check-content-length/+merge/296120
Your team Launchpad code reviewers is subscribed to branch lp:launchpad.


References