So I've released my helpers code via github. Scaladoc is available here, although I warn you that my patience with hacking the stylesheet only goes so far and I don't yet know how to make scaladoc that is not foul to look at. To build it, and run the tests, do...
...after unpacking the tarball somewhere
The motivation behind this package is that I wanted to do some http stuff and wanted to make my client code be as simple as possible while still being polite to servers. So that meant supporting conditional get using Etags, Last-Modified and also supporting gzip encoding. I do all this by using the apache commons httpclient-4.x and httpcore-4.x libraries and wrapping them all up in a class that's convenient and simple to use. Here's a taster:
import com.uncarved.helpers.http._ val helper = new BasicClient() //Get a webpage as a string (if you look at the apache http log4j messages you can see it //does conditional get and has transparent gzip support) val str = helper.get("http://www.theflautadors.org/") //Get some XML (with request parameters supplied) val params = List(("tag"->""), ("limit"->"5")) val xml = helper.getXML(Request(RequestType.GET, "http://www.uncarved.com/index.py/rss1.1.xml", params)) val items = xml \\ "item"
Unless otherwise specified the contents of this page are copyright © 2011 Sean Hunter and are released under a creative commons attribution 2.5 license.
Machine-readable metadata for this article can be found here.
Last modified: Wed Jun 1 10:46:47 2011.