Skip to content

Commit 7f9c951

Browse files
committed
fix e2ee type conversion issue
1 parent 132c8d4 commit 7f9c951

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

opentok/opentok.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,24 +458,23 @@ def create_session(
458458
).format(location)
459459
)
460460
options[u("location")] = location
461-
options["e2ee"] = e2ee
461+
options["e2ee"] = str(e2ee).lower()
462462

463463
try:
464464
logger.debug(
465465
"POST to %r with params %r, headers %r, proxies %r",
466466
self.endpoints.session_url(),
467467
options,
468-
self.headers(),
468+
{**self.get_headers(), "Accept": "application/json"},
469469
self.proxies,
470470
)
471471
response = requests.post(
472472
self.endpoints.get_session_url(),
473473
data=options,
474-
headers=self.get_headers(),
474+
headers={**self.get_headers(), "Accept": "application/json"},
475475
proxies=self.proxies,
476476
timeout=self.timeout,
477477
)
478-
479478
response.encoding = "utf-8"
480479

481480
if response.status_code == 403:

tests/test_session_creation.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,12 @@ def test_create_default_session(self):
3939

4040
validate_jwt_header(self, httpretty.last_request().headers[u("x-opentok-auth")])
4141
expect(httpretty.last_request().headers[u("user-agent")]).to(
42-
equal(u("OpenTok-Python-SDK/") + __version__ + ' python/' + platform.python_version())
42+
equal(
43+
u("OpenTok-Python-SDK/")
44+
+ __version__
45+
+ " python/"
46+
+ platform.python_version()
47+
)
4348
)
4449
body = parse_qs(httpretty.last_request().body)
4550
expect(body).to(have_key(b("p2p.preference"), [b("enabled")]))
@@ -310,7 +315,7 @@ def test_create_session_with_e2ee(self):
310315
session = self.opentok.create_session(e2ee=True)
311316

312317
body = parse_qs(httpretty.last_request().body)
313-
expect(body).to(have_key(b("e2ee"), [b"True"]))
318+
expect(body).to(have_key(b("e2ee"), [b"true"]))
314319
expect(session).to(be_a(Session))
315320
expect(session).to(
316321
have_property(

0 commit comments

Comments
 (0)