Skip to content

Instantly share code, notes, and snippets.

@pope
Created March 3, 2009 04:21
Show Gist options
  • Save pope/73172 to your computer and use it in GitHub Desktop.
Save pope/73172 to your computer and use it in GitHub Desktop.
from httplib.HTTPConnection
from urlparse import urlparse
def get_size_of_page(url):
o = urlparse(url)
conn = HTTPConnection(o.netloc)
conn.request("HEAD", o.path)
resp = conn.getresponse()
if resp.status == 200:
return long(resp.getheader("Content-Lenght"))
else:
return None
import size
def test_should_get_size_of_page():
# How would I mock HTTPConnection
pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment