mjijackson/stratajs.org — Issue #1: mocking raw body submits
Author: bingomanatee
Created: 2011-12-02 17:25:59+00:00
State: open

I am trying to mock a REST style POST

new_item = {id:1, name:'dava'};

var content = JSON.stringify(new_item);
var contentLength = Buffer.byteLength(content).toString(10);
var serverName = "example.org";
var env_data = {protocol:"http:",
protocolVersion:"1.1",
requestMethod:"POST",
requestTime:new Date,
remoteAddr:"127.0.0.1",
serverName:serverName,
serverPort:"443",
pathInfo:"/rest_path/1",
userAgent:"test suite",
headers:{
"Host":serverName,
"User-Agent":this.userAgent,
"Content-Length":this.contentLength
},
input:new BufferedStream(content)
};

the result is that the entire expression gets set as a POST parameter:

when echoing env, I get:
{ ...
strataBody: { '{"id":1,"name":"dava"}': '' },
}

How can you create/mock raw body POSTs in strata?

Dave