matjaz/node-http.min

Consider ability to set a timeout

hunterloftis opened this issue · 2 comments

Lovely little library! It would be fantastic to be able to set a timeout for requests, which currently is impossible (no way to call request.setTimeout since the request instance is not returned to the user).

options.timeout: ms would be obvious, but what about other ClientRequest methods?
Maybe something like

http.get({
    ...
    request: (request) {
        request.setTimeout...
    }
})

With this, user can also hook into events.

Thanks!

A hook that passes the request instance sounds like a great solution to me.