(request_method: str, headers: dict, payload: str = "")
| 64 | |
| 65 | |
| 66 | def _get_headers(request_method: str, headers: dict, payload: str = "") -> dict: # type: ignore[type-arg] |
| 67 | headers = {k: v for k, v in headers.items()} |
| 68 | # Django by default sets the content-length to "", which in the case of get request(lack of content body) |
| 69 | # Remains an empty string - an invalid value(according to edge alb and HTTP spec). |
| 70 | # Hence, we need to remove this header to turn this into a valid request |
| 71 | # ref: https://groups.google.com/g/django-developers/c/xjYVJN-RguA/m/G9krDqawchQJ |
| 72 | if request_method == "GET": |
| 73 | headers.pop("Content-Length", None) |
| 74 | signature = sign_payload(payload, settings.EDGE_REQUEST_SIGNING_KEY) # type: ignore[arg-type] |
| 75 | headers[FLAGSMITH_SIGNATURE_HEADER] = signature |
| 76 | return headers |
no test coverage detected
searching dependent graphs…