 resourceRequest = require './resource-request.coffee'
 virtual = require './virtual-resource.coffee'
+crypto = require 'crypto'
 
 idResourceCache = {}
+pathResourceCache = {}
+
+checkComplete = (resource) ->
+  # Determine if there are any incomplete operations
+  for content in resource.content
+    if not content.complete
+      return false
+
+  resource.content = new Buffer (content.data for content in resource.content).join(''), 'utf8'
+
+  for deferred in resource.deferred
+    deferred resource.content
+
+  # Clear the deferred list so future requests will be handled directly
+  resource.deferred = undefined
 
 # TODO : Implement cache invalidation on a periodic basis here
 exports.combine = ({resources, req, separator, contentType, prefix}) ->

      deferred: []
    }

    checkComplete = ->
      # Determine if there are any incomplete operations
      for content in resource.content
        if not content.complete
          return false

      resource.content = (content.data for content in resource.content).join ''

      for deferred in resource.deferred
        deferred resource.content

      # Clear the deferred list so future requests will be handled directly
      resource.deferred = undefined

    for content in resource.content
      do (content) ->

              res.on 'end', ->
                content.data = chunks.join('') + (separator ? '')
                content.complete = true
                checkComplete resource
        )

    resource.href = virtual.create
