Skip to content
This repository was archived by the owner on Mar 18, 2019. It is now read-only.
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
2 changes: 1 addition & 1 deletion coreapi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from coreapi.document import Array, Document, Link, Object, Error, Field


__version__ = '2.0.1'
__version__ = '2.0.2'
__all__ = [
'Array', 'Document', 'Link', 'Object', 'Error', 'Field',
'Client',
Expand Down
7 changes: 5 additions & 2 deletions coreapi/codecs/download.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,13 @@ def decode(self, bytestring, **options):

# Determine the full output path.
output_path = os.path.join(output_dir, output_filename)
output_path = _unique_output_path(output_path)

# Move the temporary download file to the final location.
os.rename(temp_path, output_path)
if output_path != temp_path:
output_path = _unique_output_path(output_path)
os.rename(temp_path, output_path)

# Open the file and return the file object.
output_file = open(output_path, 'rb')
downloaded = DownloadedFile(output_file, output_path, delete=self._delete_on_close)
downloaded.basename = output_filename
Expand Down
6 changes: 4 additions & 2 deletions coreapi/transports/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,10 +111,12 @@ def _get_headers(url, decoders, credentials=None):
"""
Return a dictionary of HTTP headers to use in the outgoing request.
"""
accept = '%s, */*' % ', '.join(decoders[0].get_media_types())
accept_media_types = decoders[0].get_media_types()
if '*/*' not in accept_media_types:
accept_media_types.append('*/*')

headers = {
'accept': accept,
'accept': ', '.join(accept_media_types),
'user-agent': 'coreapi'
}

Expand Down