             when 'https:' then _require('https').request
 
     if not request
-        cb new Error "Protocol #{opts.protocol} is not supported."
+        err = new TypeError "Protocol #{opts.protocol} is not supported."
+        err.code = 'UNVALID PROTOCOL'
+        cb err
 
     req = request opts, (res) ->
         statusCode = res.statusCode


    if urlStr
        if urlStr.indexOf('.') < 0
            return cb new Error "Unvalid url string #{opts}."
        if urlStr.indexOf('http') < 0
            urlStr = 'http://' + urlStr


                decode null, buf
        .on 'error', cb

    req.setTimeout timeout, ->
        err = new Error "Request #{url.format opts} timeout."
        err.code = "TIMEOUT"
        req.emit 'error', err

    req.end()
    req

