Skip to content

Don't try to set Content-Type if no mimetype is available - #1069

Open
lalten wants to merge 1 commit into
google:masterfrom
lalten:dont-set-null-mimetype
Open

Don't try to set Content-Type if no mimetype is available#1069
lalten wants to merge 1 commit into
google:masterfrom
lalten:dont-set-null-mimetype

Conversation

@lalten

@laltenlalten commented Oct 25, 2022

Copy link
Copy Markdown
Contributor

This phase:

defattach(test_api: htf.TestApi) ->None:
test_api.attach("file.unknown", b"I'm data")

will work, but when you try to download an attachment that has an extension that

ifmimetypeisINFER_MIMETYPE:
mimetype=mimetypes.guess_type(name)[0]
does not recognize, the mimetype is set to None (null in json). This makes Tornado fail on attachment download when it sets the Content-Type of the response:

Traceback (mostrecentcalllast):
File"path/to/tornado/web.py", line1702, in_executeresult=method(*self.path_args, **self.path_kwargs)
File"path/to/openhtf/output/servers/station_server.py", line369, ingetself.set_header('Content-Type', attachment.mimetype)
File"path/to/tornado/web.py", line374, inset_headerself._headers[name] =self._convert_header_value(value)
File"path/to/tornado/web.py", line416, in_convert_header_valueraiseTypeError("Unsupported header value %r"%value)
TypeError: UnsupportedheadervalueNone

The simple fix is to only send the Content-Type header when we actually know it.


This change is Reviewable

@dbhatman

Copy link
Copy Markdown
Contributor

Closing and reopening to trigger some automation.

@dbhatmandbhatman reopened this Nov 28, 2022
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@lalten@dbhatman