title: Streaming mp4 from grails controller not working on iPhone
body: <p>I'm trying to stream a mp4 file to iOS devices (iPhone and iPad) from a Grails controller:</p>
  
  <pre><code>def streamContent() {
      def contentPath = "/path/to/file"
      File f = new File(contentPath)
      if(f.exists()) {
          response.setContentType("video/mp4")
          response.outputStream &lt;&lt; f.newInputStream()
          response.outputStream.flush()
          response.outputStream.close()
      } else {
          render status: 404
      }
  }
  </code></pre>
  
  <p>this code works well on desktop browsers like safari (I see the video), but when I access to the same page with an iPhone or an iPad the video won't play. Note that if I put the same video on Apache httpd and I request it from iOS devices, there is no problem. So it must be a streaming problem.</p>
  
  <p>On the html page the video is embedded using HTML5 video tag:</p>
  
  <pre><code>&lt;video width="360" height="200" controls&gt;
      &lt;source src="http://localhost:8080/myapp/controller/streamContent" type='video/mp4'&gt;
  &lt;/video&gt;
  </code></pre>