implicit.ly

Scala software, hot off the presses

Unfiltered 0.4.0

Header Extractor Refactor

This release includes a breaking change to the set of request-header extractors included with Unfiltered. Named header extractors are now abstractions of the particular header specifications, so that non-repeatable string headers extract to a String instead of a Seq[String], date headers extract to a Date object, etc.

Applications upgrading from Unfiltered 0.3.x will need to remove a few calls, for example to headOption, to compile against the new version.

Other Changes

  • Published for Scala 2.8.0 - 2.9.0-1. If you're building against Scala 2.7.7, stay on Unfiltered 0.3.x.
  • Built with sbt 0.10.1
  • Jetty and Netty servers now expose url's accessable through their RunnableServer#run method so you can do

    unfiltered.jetty.Http.anylocal.filter(plan).run({ svr => unfiltered.util.Browser.open(svr.url) })

  • Removed deprecated method requestURI and contextPath on HttpRequest, use url instead or the ServletFilter modules ContextPath extractor
  • Drop side effecting request reading extractors InStream, Read and Bytes. Prefer Body methods stream, reader, and bytes instead
  • Removed deprecated auxillary jetty.Http constructor
  • Enable @tailrec annotations
  • Fix compiler warnings

Unfiltered is a toolkit for servicing HTTP requests in Scala.

Unfiltered 0.3.4

  • chrislewis NotFoundHandler added as last in pipeline; plans push unhandled requests upstream. Channel handlers plans can now be chained like filter plans.
  • softprops Refactor of WebSockets interface, now enables the use of Unfiltered's request extractors prior to the WebSockets handshake. See the module's readme for details and examples.
  • Compiled, tested, and published for all release versions of Scala from 2.7.7 to 2.9.0-1.

Unfiltered is a toolkit for servicing HTTP requests in Scala.

Unfiltered 0.3.3

Documentation

Unfiltered documentation is now available.

library module

  • eed3si9n Accepts.Javascript now accepts text/javascript or application/javascript
  • eed3si9n Accepts.Jsonp now accepts application/json, text/javascript, or application/javascript
  • Deprecating HttpRequest.requestURI and HttpRequest.contextPath and replacing with HttpRequest.uri. HttpRequest.contextPath only existed to suit the HttpServletRequest spec and had no context in the Netty module and thus should not be in the base HttpRequest interface.
  • Added QueryString(qs) extractor for extracting the raw query string from a request
  • Added HostPort(hostname, port) extractor for extracting out a request's host and port
  • New unfiltered.request.Body object for working with request bodies explicitly, not as an extractor as these operations generally have side effects.

json-p

eed3si9n The Jsonp wrapper object now defines a respond method that returns a ChainResponse that handles a by-name parameter which produces a lift-json JValue.

case GET(UFPath("/jsonp/lift-json/optional") & Jsonp.Optional(callback)) => callback respond {
  import net.liftweb.json.JsonAST._
  import net.liftweb.json.JsonDSL._
  "answer" -> Seq(42)
}

filter module

  • Added ContextPath(ctx, path) extractor to suit filter plans mounted on a context path. Note, the Path extractor will contain the context path. To remove redundancy in filter plans, use ContextPath(ctx, path)

Prior to this release, you used matched filters on context paths with

jettySvr.context("/foo") { _.filter(Planify { case Path("/bar") => ... } }

To accomplish the same match in this release and beyond,

jettySvr.context("/foo") { _.filter(Planify { case ContextPath(_, "/bar") => ... } }

netty module

  • gh-15 Fixed issue with undecoded parameter keys

all intents

A function object Intent#apply to filter and other intent types, to explicitly construct an intent without the somewhat awkward type annotations.

val anIntent = unfiltered.filter.Intent {
  case GET(req) => ...
}

Unfiltered is a toolkit for servicing HTTP requests in Scala.

Unfiltered 0.3.2

WebSockets module

  • Refactor into a more Plan-friendly design

The HTTP side of websocket handlers now uses Netty HTTP RequestBindings

PartialFunction[netty.RequestBinding => PartialFunction[netty.websocket.SocketCallback => Unit]]

More information can be found in the module readme.

Binding modules

  • Netty dependency updated to 3.2.4
  • Jetty dependency updated to 7.2.2.v20101205

Unfiltered is a toolkit for servicing HTTP requests in Scala.

Filed under  //   Scala 2.7.7   Scala 2.8.0   Scala 2.8.1   Unfiltered Web Toolkit   net.databinder  

Unfiltered 0.3.1

netty-server module

  • Fixed issue with chaining multiple ChannelHandlers
  • Updated Netty dependency to 3.2.3

Unfiltered is a toolkit for servicing HTTP requests in Scala.

Filed under  //   Scala 2.7.7   Scala 2.8.0   Scala 2.8.1   Unfiltered Web Toolkit   net.databinder  

Unfiltered 0.3.0

Request Chaining Refactor

In prior versions of Unfiltered, extractors generally passed their source object into the extracted tuple, to support chaining by nesting extractors. This provided the needed flexibility, but it littered client code with _'s for unneeded request and map references. (Also, it's rather un-fun to maintain in every extractor in the library.)

It was pointed out to us that Scala's pattern matching can be extended to support this need with as a general operation.

object & { def unapply[A](a: A) = Some(a, a) }

With this in scope, we can do:

case GET(Path("/secret") & BasicAuth(name, pass)) =>

Because (if you're curious) that evaluates as:

case GET(&(Path("/secret"), BasicAuth(name, pass))) =>

Refactoring client code from 0.2.x extractors is a bit painful, but the improved readability should be worth it.

OAuth Module

Support for the official OAuth final 1.0 provider specification.

An example client and server have been provided as g8 templates. Otherwise please see the OAuth module's readme

Parameter validation

Values from outside the parameters map can easily participate in QParams validation using QParams.external as an alternative to QParams.lookup.

For example, to fail if a User-Agent header is not present:

agent <- external("UA", UserAgent(request).firstOption) is
  required("missing header")

This would generate a Fail named "UA" with the error message "missing header" when a request comes in without this header. The failure would be processed and reported along with other validation failures.

Breaking change: The method QParams.pred now takes its predicate function and error function in a single parameter list, to facilitate inference of its two type parameters.

Scalate Interface

Applications using the built-in Scalate responder can now override the creation of a DefaultRenderContext to use a servlet-specific rendering context, if required.

Unfiltered is a toolkit for servicing HTTP requests in Scala.

Filed under  //   Scala 2.7.7   Scala 2.8.0   Scala 2.8.1   Unfiltered Web Toolkit   net.databinder  

Unfiltered 0.2.3

Features

  • Support for HTTPS in Jetty and Netty server modules, testable through an HTTPS extractor. (softprops)
  • Extractor RemoteAddr for remote addresses whether direct or X-Forwarded-For. (softprops)
  • PdfContent header response function, and ContentType refactored to not assume character content, and CharContentType for encoded characters. (chrislewis)

Fixes

Unfiltered is a toolkit for responding to HTTP requests in Scala.

Filed under  //   Scala 2.7.7   Scala 2.8.0   Scala 2.8.1   Unfiltered Web Toolkit   net.databinder  

Unfiltered 0.2.2

Server Interfaces

  • The server field in prior versions of unfiltered.jetty.Server (the wrapper's reference to the Jetty server object) is now underlying.
  • The destroy method of the underlying Jetty server is now promoted to the wrapper interface, and it is called from the run method. Destroying completed server instances frees PermGen space for long-running JVM sessions, such as those provided by interactive build and test tools.
  • The run method is not guaranteed to return. If you have code to execute after the server is stopped, call run with beforeStart and afterStop functions.
  • Convenience methods on unfiltered.jetty.Http: local for a server bound to the loopback interface only, and anylocal for a server on loopback using any available port.

New Modules

  • unfiltered-websockets: Uses Netty. Details are available in the readme.
  • unfiltered-utils: basic functions used by other unfiltered modules.
  • unfiltered-netty-server: extracts servers from unfiltered-netty module, so that they may be used without depending on unfiltered-library.

Unfiltered Library

Support for Cookies.

ResponseFunction and Intent

ResponseFunction now takes a type parameter A to restrict the type of its underlying instance. The type A of all general ResponseFunctions in unfiltered library is Any, as they do not require any specific implementation.

The intent convention has evolved to encompass underlying response types, specifically the Cycle.Intent type takes two parameters, A for the underlying request and B for the response. This allows the use of narrowly typed ResponseFunctions to be checked when defining a particular intent.

Finally, the implementation of intent pattern matching has been improved. The method isDefinedAt is employed rather than optimistically attempting a match inside a try/catch block, all known side effects produced by request extractors have been eliminated. This required a slight change to the interface used to access multipart data in unfiltered-uploads.

Netty

The unfiltered-netty module now supplies two Plan constructs. unfiltered.netty.cycle.Plan is for defining a traditional request-response cycle, where a response object is synchronously produced for a request. unfiltered.netty.channel.Plan does not assume any response strategy; it simply matches the request and leaves it to the application to construct and write a response through Netty.

Unfiltered is a toolkit for responding to HTTP requests in Scala.

Unfiltered 0.2.1

Fixes issue 3, a bug in the embedded Jetty server wrapper that caused only the first filter defined in a context to be evaluated.

Unfiltered is a toolkit for responding to HTTP requests in Scala.

Unfiltered 0.2.0

Modules

The core Unfiltered library no longer depends on the Java Servlet API. Instead, it interacts with abstract request and response traits that require a binding implementation.

  • unfiltered Most applications will now depend on a particular binding library rather than this core library.
  • unfiltered-filter Binds the core library to servlet filters, version 2.3 of the Servlet API. Comparable to the core library in previous versions of Unfiltered.
  • unfiltered-jetty Offers convenience functions for defining an embedded Jetty server. Does not depend on unfiltered-filter, although it is generally expected to be used with it. This module was previously named unfiltered-server. Its server-building class is now unfiltered.jetty.Http.
  • unfiltered-jetty-ajp For defining an embedded Jetty server that supports the Apache JServ Protocol. Previously unfiltered-ajp-server.
  • unfiltered-netty Contributed by daggerrz, this module has "basic alpha Netty support", meaning, the tests pass. It was the motivation for abstracting the Servlet API from the core library and it supports the same kind of synchronous interaction as unfiltered-filter. (Future versions will support asynchronous messages.)
  • unfiltered-spec Now enables integration testing with both Netty and Jetty. This module is used by the core library to test itself against both server modules.

The unfiltered-scalate, unfiltered-uploads, and unfiltered-json modules are unchanged in this release.

Types

The Plan type has the same purpose as before, however it's now available in servlet-filter and Netty varieties. If your application references Plan or Planify, these can now be found in the unfiltered.filter package.

The partial function that defines a Plan is now called an Intent:

type Intent[T] = PartialFunction[HttpRequest[T], ResponseFunction]

The type parameter T allows Unfiltered modules (like uploads) and applications that need to use the actual request and response objects of their underlying implementation to do so type-safely through the underlying fields of HttpRequest and HttpResponse.

The method in a Plan type that defines the partial function is now called intent, by convention and specifically in the PassingIntent base that the filter Netty Plan traits extend. In the previous version's Plan trait it was named filter.

QParam

Requirement methods such as int, even that can be expected to fail on user input now take a function such as String => E or Int => E rather than a simple error object E. This allows the failing input to be easily cited in a constructed error message. The predicate builder function pred takes a function A => E for the same purpose. These uses are demonstrated in the softprops/unfiltered.g8 template project.

Demos

The demo projects have been removed from the project repository. Users are instead encouraged to try out released versions of Unfiltered using project templates such as softprops/unfiltered.g8.

Scala Support

In addition to Scala 2.7.7 and 2.8.0, this release of Unfiltered is compiled and published with Scala 2.8.1.RC1 for testing purposes.

Unfiltered is a toolkit for responding to HTTP requests in Scala.