mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-06-28 19:47:08 -04:00
Port rest/ to Python 3 (#3823)
This commit is contained in:
parent
8fd93b5eea
commit
02aa41809b
18 changed files with 113 additions and 100 deletions
|
@ -261,7 +261,7 @@ class PreviewUrlResource(Resource):
|
|||
|
||||
logger.debug("Calculated OG for %s as %s" % (url, og))
|
||||
|
||||
jsonog = json.dumps(og)
|
||||
jsonog = json.dumps(og).encode('utf8')
|
||||
|
||||
# store OG in history-aware DB cache
|
||||
yield self.store.store_url_cache(
|
||||
|
@ -301,20 +301,20 @@ class PreviewUrlResource(Resource):
|
|||
logger.warn("Error downloading %s: %r", url, e)
|
||||
raise SynapseError(
|
||||
500, "Failed to download content: %s" % (
|
||||
traceback.format_exception_only(sys.exc_type, e),
|
||||
traceback.format_exception_only(sys.exc_info()[0], e),
|
||||
),
|
||||
Codes.UNKNOWN,
|
||||
)
|
||||
yield finish()
|
||||
|
||||
try:
|
||||
if "Content-Type" in headers:
|
||||
media_type = headers["Content-Type"][0]
|
||||
if b"Content-Type" in headers:
|
||||
media_type = headers[b"Content-Type"][0].decode('ascii')
|
||||
else:
|
||||
media_type = "application/octet-stream"
|
||||
time_now_ms = self.clock.time_msec()
|
||||
|
||||
content_disposition = headers.get("Content-Disposition", None)
|
||||
content_disposition = headers.get(b"Content-Disposition", None)
|
||||
if content_disposition:
|
||||
_, params = cgi.parse_header(content_disposition[0],)
|
||||
download_name = None
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue