Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

lalten
Copy link
Contributor

@lalten lalten commented Oct 25, 2022

This phase:

def attach(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

if mimetype is INFER_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 (most recent call last):
  File "path/to/tornado/web.py", line 1702, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "path/to/openhtf/output/servers/station_server.py", line 369, in get
    self.set_header('Content-Type', attachment.mimetype)
  File "path/to/tornado/web.py", line 374, in set_header
    self._headers[name] = self._convert_header_value(value)
  File "path/to/tornado/web.py", line 416, in _convert_header_value
    raise TypeError("Unsupported header value %r" % value)
TypeError: Unsupported header value None

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


This change is Reviewable

@dbhatman
Copy link
Collaborator

Closing and reopening to trigger some automation.

@dbhatman dbhatman closed this Nov 28, 2022
@dbhatman dbhatman reopened this Nov 28, 2022
Sign up for free to 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