 MIME  = require('mime')
 URL   = require('url')
 
-# TODO: scan @import rules for CSS and fetch subresources.
 class ResourceProxy
     constructor : (baseURL) ->
         @urlsByIndex = []

            if /^text/.test(type)
                stream.setEncoding('utf8')
            res.writeHead(200, {'Content-Type' : type})
            stream.on 'data', (data) ->
                res.write(data)
            stream.on 'end', () ->
                res.end()
        req.on 'error', (e) ->
            throw e
        console.log("Fetching resource: #{id} [type=#{type}]")
            

module.exports = ResourceProxy

    # id - the resource ID to fetch
    # res - the response object to write to.
    fetch : (id, res) ->
        self = this
        url = @urlsByIndex[id]
        if !url?
            url = URL.parse(URL.resolve(@baseURL, id))
