Created
March 3, 2009 04:21
-
-
Save pope/73172 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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