Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changes/35.canada.changes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added the HTTP header `CKAN/<ckan-version>` to Python requests when downloading data from file sources.
5 changes: 4 additions & 1 deletion ckanext/xloader/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
# (canada fork only): ckan.plugins.toolkit
from ckan.plugins.toolkit import get_action, asbool, enqueue_job, ObjectNotFound, config, asbool
from ckan.lib.uploader import get_resource_uploader
# (canada fork only): add User-Agent header
from ckan.lib.helpers import ckan_version

from . import db, loader
from .job_exceptions import JobError, HTTPError, DataTooBigError, FileCouldNotBeLoadedError
Expand Down Expand Up @@ -379,7 +381,8 @@ def _download_resource_data(resource, data, logger):
m = hashlib.md5()
cl = None
try:
headers = {}
# (canada fork only): add User-Agent header
headers = {'User-Agent': 'CKAN/{}'.format(ckan_version())}
if resource.get('url_type') == 'upload':
# Add a constantly changing parameter to bypass URL caching.
# If we're running XLoader, then either the resource has
Expand Down
Loading