Repository: getsentry/sentry-python

Issue:
KeyError 'https,http' in async handling 1.31.0
### How do you use Sentry?

Self-hosted/on-premise

### Version

1.31.0

### Steps to Reproduce

I'm running sentry and uvicorn. We also have django-channels. On upgrading to 1.31.0 I'm getting the following:

```
Traceback (most recent call last):
File "/home/vcap/deps/0/python/lib/python3.9/site-packages/uvicorn/protocols/http/httptools_impl.py", line 426, in run_asgi
result = await app( # type: ignore[func-returns-value]
File "/home/vcap/deps/0/python/lib/python3.9/site-packages/uvicorn/middleware/proxy_headers.py", line 84, in __call__
return await self.app(scope, receive, send)
File "/home/vcap/deps/0/python/lib/python3.9/site-packages/channels/routing.py", line 62, in __call__
return await application(scope, receive, send)
File "/home/vcap/deps/0/python/lib/python3.9/site-packages/sentry_sdk/integrations/django/asgi.py", line 40, in sentry_patched_asgi_handler
return await middleware(scope, receive, send)
File "/home/vcap/deps/0/python/lib/python3.9/site-packages/sentry_sdk/integrations/asgi.py", line 146, in _run_asgi3
return await self._run_app(scope, receive, send, asgi_version=3)
File "/home/vcap/deps/0/python/lib/python3.9/site-packages/sentry_sdk/integrations/asgi.py", line 178, in _run_app
) = self._get_transaction_name_and_source(
File "/home/vcap/deps/0/python/lib/python3.9/site-packages/sentry_sdk/integrations/asgi.py", line 293, in _get_transaction_name_and_source
name = _get_url(asgi_scope, "http" if ty == "http" else "ws", host=None)
File "/home/vcap/deps/0/python/lib/python3.9/site-packages/sentry_sdk/integrations/_asgi_common.py", line 46, in _get_url
default_port = {"http": 80, "https": 443, "ws": 80, "wss": 443}[scheme]
KeyError: 'https,http'
```

I did not research further but it seems to be caused by the recent overhaul of the code (#2335)

### Expected Result

No exception

### Actual Result

.


Discussion:
I'm behind a proxy, and ~~the proxy has `x-forwarded-proto: https`.~~ in instances of this error occurring the header `x-forwarded-proto: https,http` is sent.
In channels (4.0.0) in the following line `scheme` already has the value `https,http`:

`File "/home/vcap/deps/0/python/lib/python3.9/site-packages/channels/routing.py", line 62, in __call__`
The value of `x-forwarded-proto` comes from the Cloud Foundry gorouter:

https://docs.cloudfoundry.org/concepts/http-routing.html#X-Forwarded-Proto

I can't find an actual standard for this header, but I don't think it's unique and it would be good if sentry-sdk didn't introduce an error here.
Arguably, this is actually a problem in uvicorn; I've [started a discussion there](https://github.com/encode/uvicorn/discussions/2102)
Thinking this through a bit more, I'm becoming of the opinion that upstream problem or not, the sentry-sdk should simply be robust for this. My thinking is: it should never be so that the introduction of a framework to detect errors is in itself what causes failure. 

Resolving patch:
diff --git a/sentry_sdk/integrations/_asgi_common.py b/sentry_sdk/integrations/_asgi_common.py
--- a/sentry_sdk/integrations/_asgi_common.py
+++ b/sentry_sdk/integrations/_asgi_common.py
@@ -43,7 +43,7 @@ def _get_url(asgi_scope, default_scheme, host):
 
     if server is not None:
         host, port = server
-        default_port = {"http": 80, "https": 443, "ws": 80, "wss": 443}[scheme]
+        default_port = {"http": 80, "https": 443, "ws": 80, "wss": 443}.get(scheme)
         if port != default_port:
             return "%s://%s:%s%s" % (scheme, host, port, path)
         return "%s://%s%s" % (scheme, host, path)


Test patch: