Changeset View
Changeset View
Standalone View
Standalone View
swh/web/save_origin_webhooks/generic_receiver.py
Show First 20 Lines • Show All 82 Lines • ▼ Show 20 Lines | ) -> Dict[str, Any]: | ||||
if not self.is_push_event(request): | if not self.is_push_event(request): | ||||
raise BadInputExc( | raise BadInputExc( | ||||
f"Event sent by {self.FORGE_TYPE} webhook is not a push one, request " | f"Event sent by {self.FORGE_TYPE} webhook is not a push one, request " | ||||
"has not been processed." | "has not been processed." | ||||
) | ) | ||||
content_type = request.headers.get("Content-Type") | content_type = request.headers.get("Content-Type") | ||||
if content_type != "application/json": | if content_type and not content_type.startswith("application/json"): | ||||
raise BadInputExc( | raise BadInputExc( | ||||
f"Invalid content type '{content_type}' for the POST request sent by " | f"Invalid content type '{content_type}' for the POST request sent by " | ||||
f"{self.FORGE_TYPE} webhook, it should be 'application/json'." | f"{self.FORGE_TYPE} webhook, it should be 'application/json'." | ||||
) | ) | ||||
repo_url, visit_type = self.extract_repo_url_and_visit_type(request) | repo_url, visit_type = self.extract_repo_url_and_visit_type(request) | ||||
if not repo_url: | if not repo_url: | ||||
raise BadInputExc( | raise BadInputExc( | ||||
Show All 18 Lines |