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

Response payload option for "undefined" content #87

Open
JohnnyPicnic opened this issue May 25, 2023 · 3 comments
Open

Response payload option for "undefined" content #87

JohnnyPicnic opened this issue May 25, 2023 · 3 comments

Comments

@JohnnyPicnic
Copy link
Contributor

Is it possible to add an option for undefined content in the response?
For my specific use I needed to send an unencoded payload back but the Coap Response node doesn't allow for that.

       if (_checkContentFormat(contentFormat, "text/plain")) {
            return msg.payload.toString();
        } else if (_checkContentFormat(contentFormat, "json")) {
            return JSON.stringify(msg.payload);
        } else if (_checkContentFormat(contentFormat, "cbor")) {
            return cbor.encode(msg.payload);
        } else {
            return msg.payload.toString();

To get my flow working I changed "text/plain" toreturn.msg.payload; but a better solution would be to have one more option for contentFormat, "undefined" with a return of msg.payload;

@JKRhb
Copy link
Owner

JKRhb commented May 29, 2023

Thank you for reporting this issue! Having another look into the underlying node-coap, it seems to me as if the .toString() call in the "else" case might be a bit redundant/unnecessary anyway. Maybe that could already be the fix here?

@JohnnyPicnic
Copy link
Contributor Author

Is the return msg.payload tied to the type of content you select in the coap-response node?
For the device I'm working with the payload must not be formatted so I'm not sure if "text/plain" should be just msg.payload or if there should be another option for "raw-buffer"?

@JohnnyPicnic
Copy link
Contributor Author

Is the returned payload type determined by the list in the drop down Content-Format menu?
image

I may try editing the code to add this option...

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

No branches or pull requests

2 participants