Skip to content

Instantly share code, notes, and snippets.

@mtomwing
Created April 7, 2014 05:02
Show Gist options
  • Save mtomwing/10015066 to your computer and use it in GitHub Desktop.
Save mtomwing/10015066 to your computer and use it in GitHub Desktop.
import requests
print 'Reading 0 bytes from a file'
fd = open(__file__)
print 'Closed:', fd.closed
print 'Read(0):', repr(fd.read(0))
print 'Closed:', fd.closed
print
print 'Reading 0 bytes from a socket'
url = 'https://files.mtomwing.com/foobar.gif'
res = requests.get(url, stream=True)
print 'Closed:', res.raw.closed
print 'Read(0):', repr(res.raw.read(0))
print 'Closed:', res.raw.closed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment