Skip to content

Commit

Permalink
[#989] Enable streaming in resource proxy
Browse files Browse the repository at this point in the history
  • Loading branch information
domoritz committed Jun 9, 2013
1 parent 85ad0c7 commit ab6694e
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions ckanext/resourceproxy/controller.py
Expand Up @@ -27,7 +27,7 @@ def proxy_resource(context, data_dict):
did_get = False
r = requests.head(url)
if r.status_code == 405:
r = requests.get(url)
r = requests.get(url, stream=True)
did_get = True
r.raise_for_status()

Expand All @@ -38,14 +38,13 @@ def proxy_resource(context, data_dict):
allowed=MAX_FILE_SIZE, actual=cl))

if not did_get:
r = requests.get(url)
r = requests.get(url, stream=True)

base.response.content_type = r.headers['content-type']
base.response.charset = r.encoding

length = 0
for chunk in r.iter_content(chunk_size=CHUNK_SIZE,
decode_unicode=False):
for chunk in r.iter_content(chunk_size=CHUNK_SIZE):
base.response.body_file.write(chunk)
length += len(chunk)

Expand Down

0 comments on commit ab6694e

Please sign in to comment.