apprtc icon indicating copy to clipboard operation
apprtc copied to clipboard

/join API endpoint returns incorrect Content-Type

Open jlaine opened this issue 7 years ago • 4 comments

Browsers and versions affected

All browsers.

Description

The POST to /join/ returns a JSON message, but the response headers indicate it is an HTML document.

Steps to reproduce

Open the browser's network inspector and join any room.

Expected results

The HTTP headers should contain:

Content-Type: application/json

Actual results

The HTTP headers contain:

Content-Type: text/html; charset=utf-8

jlaine avatar Jun 21 '18 21:06 jlaine

hi, same problem, have you solved it?

ArnaudFickinger avatar Jun 27 '18 21:06 ArnaudFickinger

For my usecase, I ended up having to "manually" decode the JSON payload, since the invalid Content-Type prevents me from using aiohttp's .json() method:

https://github.com/jlaine/aiortc/blob/a402b8c51de66a28d004e072e77308d543a29fcd/examples/apprtc/apprtc.py#L98

jlaine avatar Jun 27 '18 22:06 jlaine

@jlaine Possible workaround from https://stackoverflow.com/questions/48840378/python-attempt-to-decode-json-with-unexpected-mimetype:

Use response.json(content_type=None) to disable warning.

tobiasfriden avatar Nov 20 '18 12:11 tobiasfriden

@tobiasfriden Thanks for the pointer, but I'm not really looking for another workaround - my current one works. What I'd like is for the webservice to return the correct Content-Type so that no workaround is needed!

jlaine avatar Nov 21 '18 08:11 jlaine