StubRequest(final HttpRequest request) {
        method = request.method;

        // Create a map of the request headers
        headers = new HashMap<String,String>();

        for(String headerName: request.getHeaderNames()) {
            headers.put(headerName, request.getHeader(headerName));
        }
        
        // Read in the message body
        try {
            byte[] data = request.body;
            String encoding = request.getHeader("Content-Encoding");
            if (ZLIBCodec.getID().equalsIgnoreCase(encoding)) {
                data = ZLIBCodec.decode(data);
            } else if (GZIPCodec.getID().equalsIgnoreCase(encoding)) {
                data = GZIPCodec.decode(data);
            }
            String bodyStr = new String(data);
            body = StaticBody.fromString(bodyStr);
        } catch (IOException iox) {
            throw(new IllegalStateException("Couldn't load request body", iox));
        } catch (BOSHException boshx) {
            throw(new IllegalStateException("Couldn't load request body", boshx));
        }
    }