Skip to content

Instantly share code, notes, and snippets.

@wsdookadr
Forked from isaacs/http-client-timeout.js
Created November 25, 2010 18:56
Show Gist options
  • Select an option

  • Save wsdookadr/715787 to your computer and use it in GitHub Desktop.

Select an option

Save wsdookadr/715787 to your computer and use it in GitHub Desktop.

Revisions

  1. @isaacs isaacs created this gist Nov 25, 2010.
    16 changes: 16 additions & 0 deletions http-client-timeout.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,16 @@
    var http = require("http")

    http.createServer(function (req, res) {
    // let it time out
    // just hold the connection open forever
    }).listen(8080)

    var r = http.createClient(8080, "localhost").request("GET", "/", {})
    r.on("response", function (res) {
    console.log("got response")
    })
    r.connection.setTimeout(100)
    r.connection.on("timeout", function () {
    console.log("timeout!")
    })
    r.end()