Skip to content

Commit

Permalink
Properly remove accept headers from the provisioning API
Browse files Browse the repository at this point in the history
  • Loading branch information
bradtgmurray committed Feb 1, 2024
1 parent 266aa5e commit 8543920
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 8 additions & 3 deletions linkedin_matrix/web/provisioning_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,11 +107,16 @@ def parse_cookies(c):

if "all_headers" in req_data:
all_headers = req_data["all_headers"]
parse_cookies(all_headers.pop("Cookie", all_headers.pop("cookie", "")))

cookies = all_headers.pop("Cookie", all_headers.pop("cookie", None))
if not cookies:
return web.HTTPBadRequest(body='{"error": "Missing cookies"}', headers=self._headers)

parse_cookies(cookies)

# We never want the accept header, skip it
all_headers.pop("Accept")
all_headers.pop("accept")
all_headers.pop("Accept", None)
all_headers.pop("accept", None)

# Save the rest of the headers
headers = all_headers
Expand Down
6 changes: 3 additions & 3 deletions linkedin_messaging/linkedin.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,9 @@ def from_cookies_and_headers(cookies: dict[str, str],

# Skip these headers, including them will result in events being received in a newer
# format that we don't support
linkedin.headers.pop("x-li-query-map")
linkedin.headers.pop("x-li-query-accept")
linkedin.headers.pop("x-li-accept")
linkedin.headers.pop("x-li-query-map", None)
linkedin.headers.pop("x-li-query-accept", None)
linkedin.headers.pop("x-li-accept", None)

return linkedin

Expand Down

0 comments on commit 8543920

Please sign in to comment.