The Snap team is proud to announce the release of Snap 0.4, containing a whole bunch of nifty new features. Here is what we’ve been up to:

Heist now uses the brand new xmlhtml HTML5 parser for parsing and rendering templates. This eliminates our dependency on XML and makes it possible to include inline javascript/css in templates. Check out Chris Smith’s blog post for more information about xmlhtml.

Along with the change to xmlhtml, we decided to convert Heist to use Text instead of ByteString. This is a backwards-incompatible change which breaks old code, but which we feel is the right thing to do.

Snap now has support for file uploads (!) and the multipart/form-data content type. Snap’s file upload support uses iteratees to stream uploaded data and comes with a convenience function to writeuploaded files to a temporary directory. We put significant effort into preventing denial of service attacks and providing policy controls for things like maximum allowable file size, upload timeouts, minimum upload speed, etc.

The web server now uses blaze-builder in the output response body Enumerator . Besides being significantly faster for most workloads than ByteString enumeration, this allowed us to save several copies within the server code, giving us a moderate performance improvement. However, this will break any existing code making direct use of the output enumerator rather than using convenience functions like writeBS . We encourage users who are building up large responses out of lots of little bytestring chunks to consider switching their code to using Builder and writeBuilder to get a speed boost.

The “development mode” of projects built using our snap project starter is now quite a bit smarter. The 0.3 version used hint to interpret web handlers on-the-fly, but it re-interpreted the code on each request, making keeping in-memory state between requests impossible. The development mode now only rebuilds the project when files actually change. State will now be preserved across requests as long as the project files are not changed on disk.

Our file serving code has been substantially improved/rewritten. The new code can automatically generate stylable/themable directory indexes, provides configurable lists of index files, and allows the user to plug in dynamic handlers. These handlers can be used to perform arbitrary transformations based on file type or file content on the fly. The new code also correctly handles trailing slashes for relative path resolution.