title: EventSourceHttpClient never exits
body: <p>I'm trying to create some stuff on my Philips-Hue installation, using Symfony.
  I'm able to control my lights, get motion sensor,... But all is working with GET requests. This is a very bad idea ;)</p>
  <p>API provided by Philips comes with Events endpoint, as described here : <a href="https://developers.meethue.com/develop/hue-api-v2/core-concepts/#events" rel="nofollow noreferrer">Core-concepts of meethue</a></p>
  <p>So, I tried to use the &quot;<a href="https://symfony.com/doc/current/http_client.html#consuming-server-sent-events" rel="nofollow noreferrer">Consuming Server Events</a>&quot; capability of Symfony in my application.</p>
  <p>I do not understand how to use it? I tried to find more information, but this is always regarding sending information. I want to consume informations.
  I tried to create some route, but the connect function does not end (I assume this is the normal way). So how to use the &quot;$source&quot; created by the call?</p>
  <p>During my searches, I noticed that, if I enter one bad key, I get an error (Full HTML response), but this does not throw any Exception on the connect function. For me, as written line 112 of <a href="https://github.com/symfony/symfony/blob/6.1/src/Symfony/Component/HttpClient/EventSourceHttpClient.php" rel="nofollow noreferrer">source code</a>, it should be.</p>
  <p>For example, when using curl call:</p>
  <pre><code>curl --insecure -N -H 'hue-application-key: ThisIsAVeryBadKey' -H 'Accept: text/event-stream' https://ip-bridge/eventstream/clip/v2
  </code></pre>
  <p>I get:</p>
  <pre><code>&lt;!DOCTYPE HTML PUBLIC &quot;-//W3C//DTD HTML 4.0 Transitional//EN&quot;&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;hue personal wireless lighting&lt;/title&gt;
      &lt;link rel=&quot;stylesheet&quot; type=&quot;text/css&quot; href=&quot;/index.css&quot;&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;div class=&quot;philips-header&quot;&gt;
        &lt;img src=&quot;/philips-blue.png&quot; class=&quot;philips-logo&quot; alt=&quot;Philips&quot; /&gt;
      &lt;/div&gt;
      &lt;div class=&quot;header&quot;&gt;
        &lt;img class=&quot;header-logo&quot; src=&quot;/hue-logo.png&quot; alt=&quot;hue personal wireless lighting&quot; /&gt;
  
        &lt;img src=&quot;/hue-color-line.png&quot; class=&quot;colorline&quot; /&gt;
  
      &lt;/div&gt;
      &lt;div class=&quot;error&quot;&gt;Oops, there appears to be no lighting here&lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>If I use a good key, I have the following:</p>
  <pre><code>:hi
  
  id: 1639957108:0
  data: [{&quot;creationtime&quot;:&quot;2021-12-19T23:38:28Z&quot;,&quot;data&quot;:[{&quot;id&quot;:&quot;YYYY&quot;,&quot;id_v1&quot;:&quot;/sensors/30&quot;,&quot;owner&quot;:{&quot;rid&quot;:&quot;XXXXX&quot;,&quot;rtype&quot;:&quot;device&quot;},&quot;temperature&quot;:{&quot;temperature&quot;:19.059999465942383,&quot;temperature_valid&quot;:true},&quot;type&quot;:&quot;temperature&quot;}],&quot;id&quot;:&quot;ZZZZZ&quot;,&quot;type&quot;:&quot;update&quot;}]
  </code></pre>
  <p>Regards,</p>