code: protected Connection createHttpConnection(Dsn dsn) {
          URL sentryApiUrl = HttpConnection.getSentryApiUrl(dsn.getUri(), dsn.getProjectId());
  
          String proxyHost = getProxyHost(dsn);
          String proxyUser = getProxyUser(dsn);
          String proxyPass = getProxyPass(dsn);
          int proxyPort = getProxyPort(dsn);
  
          Proxy proxy = null;
          if (proxyHost != null) {
              InetSocketAddress proxyAddr = new InetSocketAddress(proxyHost, proxyPort);
              proxy = new Proxy(Proxy.Type.HTTP, proxyAddr);
              if (proxyUser != null && proxyPass != null) {
                  Authenticator.setDefault(new ProxyAuthenticator(proxyUser, proxyPass));
              }
          }
  
          Double sampleRate = getSampleRate(dsn);
          EventSampler eventSampler = null;
          if (sampleRate != null) {
              eventSampler = new RandomEventSampler(sampleRate);
          }
  
          HttpConnection httpConnection = new HttpConnection(sentryApiUrl, dsn.getPublicKey(),
              dsn.getSecretKey(), proxy, eventSampler);
  
          Marshaller marshaller = createMarshaller(dsn);
          httpConnection.setMarshaller(marshaller);
  
          int timeout = getTimeout(dsn);
          httpConnection.setConnectionTimeout(timeout);
  
          boolean bypassSecurityEnabled = getBypassSecurityEnabled(dsn);
          httpConnection.setBypassSecurity(bypassSecurityEnabled);
  
          return httpConnection;
      }
docs: Creates an HTTP connection to the Sentry server.
  
  @param dsn Data Source Name of the Sentry server.
  @return an {@link HttpConnection} to the server.