     timeout = options.timeout ? null
     responseBodyType = options.responseBodyType ? "text"
     new Promise((resolve, reject) ->
-        if mate.environmentType == "browser"
+        if mate.environmentType == "browser" then do ->
             xhr = new XMLHttpRequest()
             xhr.open(method, url)
             if headers?

            xhr.onload = ->
                response =
                    statusCode: xhr.status
                    statusText: xhr.statusText
                    headers:
                        xhr.getAllResponseHeaders()
                        .stripTrailingNewline()
                        .splitDeep("\r\n", ": ", 1)
                        .toObject()
                    body:
                        if responseBodyType == "binary"

            xhr.ontimeout = ->
                reject(new Error("timeout"))
            xhr.send(body)
        else do ->
            http = module.require("http")
            https = module.require("https")
            urlMod = module.require("url")
            parsedUrl = urlMod.parse(url)
            httpOrHttps = if parsedUrl.protocol == "https:" then https else http
            httpOrHttps.request(
                {
                    method: method
                    hostname: parsedUrl.hostname
                    port: parsedUrl.port
                    path: parsedUrl.path
                    headers: headers
                },
                (rawResponse) ->
                    data = new Buffer(0)
                    rawResponse.on("data", (chunk) ->
                        data = Buffer.concat([data, chunk])
                    )
                    rawResponse.on("end", ->
                        response =
                            statusCode: rawResponse.statusCode
                            statusReason: rawResponse.statusMessage
                            headers: rawResponse.headers
                            body:
                                if responseBodyType == "binary"
                                    new Uint8Array(data)
                                else if responseBodyType == "text"
                                    data.toString()
                                else if responseBodyType == "json"
                                    JSON.parse(data.toString())
                                else
                                    fail()
                        if (200 <= response.statusCode < 300)
                            resolve(response)
                        else
                            reject(response)
                    )
            ).on("error", (e) ->
                fail()
            ).end()
    )
web.get = (url, options) ->
    actualOptions =
