﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
21274	django-admin's --template option fails to download from https via proxy	Daniel Hahler	nobody	"Using Squid as $https_proxy, the following will fail:

    django-admin.py startproject -v3 --template=https://github.com/twoscoops/django-twoscoops-project/archive/develop.zip --extension=py,rst,html project


{{{
Rendering project template files with extensions: .html, .rst, .py
Rendering project template files with filenames: 
Downloading https://github.com/twoscoops/django-twoscoops-project/archive/develop.zip
Extracting /tmp/django_project_template_IKLof6_download/develop.zip
Traceback (most recent call last):
  File ""/home/daniel/.virtualenvs/TMM/bin/django-admin.py"", line 8, in <module>
    execfile(__file__)
  File ""/home/daniel/projects/TMM/src/django/django/bin/django-admin.py"", line 5, in <module>
    management.execute_from_command_line()
  File ""/home/daniel/projects/TMM/src/django/django/core/management/__init__.py"", line 397, in execute_from_command_line
    utility.execute()
  File ""/home/daniel/projects/TMM/src/django/django/core/management/__init__.py"", line 390, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File ""/home/daniel/projects/TMM/src/django/django/core/management/base.py"", line 244, in run_from_argv
    self.execute(*args, **options.__dict__)
  File ""/home/daniel/projects/TMM/src/django/django/core/management/base.py"", line 291, in execute
    output = self.handle(*args, **options)
  File ""/home/daniel/projects/TMM/src/django/django/core/management/commands/startproject.py"", line 31, in handle
    super(Command, self).handle('project', project_name, target, **options)
  File ""/home/daniel/projects/TMM/src/django/django/core/management/templates.py"", line 122, in handle
    base_subdir)
  File ""/home/daniel/projects/TMM/src/django/django/core/management/templates.py"", line 205, in handle_template
    return self.extract(absolute_path)
  File ""/home/daniel/projects/TMM/src/django/django/core/management/templates.py"", line 299, in extract
    archive.extract(filename, tempdir)
  File ""/home/daniel/projects/TMM/src/django/django/utils/archive.py"", line 49, in extract
    with Archive(path) as archive:
  File ""/home/daniel/projects/TMM/src/django/django/utils/archive.py"", line 58, in __init__
    self._archive = self._archive_cls(file)(file)
  File ""/home/daniel/projects/TMM/src/django/django/utils/archive.py"", line 181, in __init__
    self._archive = zipfile.ZipFile(file)
  File ""/usr/lib/python2.7/zipfile.py"", line 766, in __init__
    self._RealGetContents()
  File ""/usr/lib/python2.7/zipfile.py"", line 807, in _RealGetContents
    raise BadZipfile, ""File is not a zip file""
zipfile.BadZipfile: File is not a zip file
}}}

Looking at the tempfile, it contains HTML from a Squid3 error page.

From looking at Squid3's logfile, `urlretrieve` appears to do a GET request to the https URL, while wget will use CONNECT.

I am using Django's current master and Python 2.7.5+ (Ubuntu 13.10, in a virtualenv).

As a workaround I can unset $https_proxy."	Bug	closed	HTTP handling	dev	Normal	needsinfo			Unreviewed	0	0	0	0	0	0
