@kellerza - We just published a new version of Rocky (v1.2.2) that resolves this issue!
Take it for a spin and let me know if it’s behaving as expected
Here’s some test code to verify (works with Rocky.class.nut:1.2.2, but not with Rocky.class.nut:1.2.1)
`
// #require “Rocky.class.nut:1.2.1”
#require “Rocky.class.nut:1.2.2”
// Test Setup
app <- Rocky();
app.post("/", function (context) {
if (typeof context.req.body == “table” && “test” in context.req.body) {
context.send(200, “Test Passed”);
return;
}
context.send(400, "Test Failed")
});
// Test Methods
function a_request_with_basic_json_content_type() {
// Send a request to ourselves
local url = http.agenturl();
local headers = { “content-type”: “application/json” };
local body = http.jsonencode({ “test”: “foo” });
http.post(url, headers, body).sendasync(function(resp) {
server.log("A request with basic json content-type header:")
if (resp.statuscode == 400) {
server.log(" Test Failed.");
return;
}
if (resp.statuscode == 200) {
server.log(" Test Passed!");
return;
}
server.log(" Unknown status code (" + resp.statuscode + ").");
});
}
function a_request_with_extended_json_content_type() {
// Send a request to ourselves
local url = http.agenturl();
local headers = { “content-type”: “application/json; charset=UTF-8” };
local body = http.jsonencode({ “test”: “foo” });
http.post(url, headers, body).sendasync(function(resp) {
server.log("A request with extended json content-type header:")
if (resp.statuscode == 400) {
server.log(" Test Failed.");
return;
}
if (resp.statuscode == 200) {
server.log(" Test Passed!");
return;
}
server.log(" Unknown status code (" + resp.statuscode + ").");
});
}
function a_request_with_basic_url_content_type() {
// Send a request to ourselves
local url = http.agenturl();
local headers = { “content-type”: “application/x-www-form-urlencoded” };
local body = http.urlencode({ “test”: “foo” });
http.post(url, headers, body).sendasync(function(resp) {
server.log("A request with basic url-encoded content-type header:")
if (resp.statuscode == 400) {
server.log(" Test Failed.");
return;
}
if (resp.statuscode == 200) {
server.log(" Test Passed!");
return;
}
server.log(" Unknown status code (" + resp.statuscode + ").");
});
}
function a_request_with_extended_url_content_type() {
// Send a request to ourselves
local url = http.agenturl();
local headers = { “content-type”: “application/x-www-form-urlencoded; charset=UTF-8” };
local body = http.urlencode({ “test”: “foo” });
http.post(url, headers, body).sendasync(function(resp) {
server.log("A request with extended url-encoded content-type header:")
if (resp.statuscode == 400) {
server.log(" Test Failed.");
return;
}
if (resp.statuscode == 200) {
server.log(" Test Passed!");
return;
}
server.log(" Unknown status code (" + resp.statuscode + ").");
});
}
// Test Runner
function test() {
server.log("********** Starting Test **********")
a_request_with_basic_json_content_type();
a_request_with_extended_json_content_type();
a_request_with_basic_url_content_type();
a_request_with_extended_url_content_type();
}
test();
`