Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Context.req.body has the wrong body type with content-type="multipart/form-data" #22

Open
dbukhmastov opened this issue Jul 26, 2017 · 0 comments

Comments

@dbukhmastov
Copy link
Contributor

dbukhmastov commented Jul 26, 2017

Scenario:

local contentType = "multipart/form-data; boundary=--ff4ed67396bc8e1d6dbf19d65b6c6348";
local body = "--ff4ed67396bc8e1d6dbf19d65b6c6348\r\nContent-Disposition: form-data; name=\"contentType\"\r\n\r\nbody\r\n--ff4ed67396bc8e1d6dbf19d65b6c6348\r\nContent-Disposition: form-data; name=\"tmp\"\r\n\r\nContent file\r\n--ff4ed67396bc8e1d6dbf19d65b6c6348";
local headers = {
    "content-type": contentType,
    "content-length": body.len()
};
local app = Rocky();
app.on("GET", "/test", function(context) {
    if ("table" != type(context.req.body)) {
        server.log("Wrong type of context.req.body: " + type(context.req.body) + ", should be table");
    }
    context.send(200, {"message": "OK"});
}.bindenv(this));
imp.wakeup(0, function() {
    local req = http.request("GET", http.agenturl() + "/test", headers, body);
    req.sendasync(function(res){});
}.bindenv(this));

Log:

[Agent] Wrong type of context.req.body: array, should be table

Tests:

This issue affects class: tests/CoreRockyMethod.nut method: testContentTypeMultipart()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant