joyent/node — Issue #2636: HTTP POST / PUT race condition when using with Expect: 100-continue
Author: SaltwaterC
Created: 2012-01-29 18:50:44+00:00
State: open

I managed to create a script that reproduces this. However, I didn't manage to create a self contained one (maybe due to laziness), but here it goes:

```javascript
var http = require('http')
var qs = require('querystring')
var reqBody = qs.stringify({foo: 'bar'})
var opt = {
method: 'POST',
host: '127.0.0.1',
path: '/index.php',
headers: {
expect: '100-continue',
'content-length': reqBody.length,
'content-type': 'application/x-www-form-urlencoded'
}
}
var req = http.request(opt, function (res) {
res.on('data', function (data) {
console.log(data.toString())
})
res.on('end', function () {
console.log('end')
})
})
req.on('error', function (err) {
console.error(err)
})
req.write(reqBody)
req.end()
```

The remote script is a simple:

```php

string(3) "bar"
}

end
$ node -v
v0.6.9
```

Couple of failures and a success. For the same script. For a larger HTTP client implementation, it fails all the time. Here's the Wireshark capture: https://gist.github.com/1700091

Without `Expect: 100-continue` everything is peachy.