Skip to content

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
Contributor

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