Skip to content
This repository was archived by the owner on Apr 22, 2023. It is now read-only.
This repository was archived by the owner on Apr 22, 2023. It is now read-only.

HTTP POST / PUT race condition when using it with Expect: 100-continue #2636

Closed
@SaltwaterC

Description

@SaltwaterC

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:

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
var_dump($_REQUEST);

Here's what's logged into the shell:

$ node php.js 

http.js:1147
      var ret = parser.execute(d, start, end - start);
                       ^
TypeError: Cannot call method 'execute' of null
    at Socket.ondata (http.js:1147:24)
    at TCP.onread (net.js:354:27)
$ node php.js 

http.js:1147
      var ret = parser.execute(d, start, end - start);
                       ^
TypeError: Cannot call method 'execute' of null
    at Socket.ondata (http.js:1147:24)
    at TCP.onread (net.js:354:27)
$ node php.js 
array(1) {
  ["foo"]=>
  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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions