I need to serve a file on localhost to a certain application which only accepts http URI-s. However, the files are generated on the fly and I would like to avoid writing to disk, so I decided to write a simple HTTP server using QTcpServer. Luckily, I even found a nice tutorial explaining just that. However, I'm not familiar with HTTP responses. How do I serve a flash file? Is there a particular MIME type for that? And after putting the header together, do I just dump the stream to the socket and that's all?
+1
A:
This doesn't answer your complete question but you can look for MIME type here:
http://www.w3schools.com/media/media_mimeref.asp
SWF is application/x-shockwave-flash
dierre
2010-08-07 16:19:50
+2
A:
The mime type you are looking for is: application/x-shockwave-flash
What you need to set is
- Set the content type to
application/x-shockwave-flash
- Set the content length to the total size of the swf to serve
- Set the header with content disposition like:
Content-Disposition=attachment;filename=SWFToServe.swf
- Start writing out all the bytes of the swf file.
- Flush the response
And that's all, the client should start downloading it...
Garis Suero
2010-08-07 16:20:12