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

fix check endpoint expression for http commands #854

Merged
merged 4 commits into from
Jan 20, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGES_NEXT_RELEASE
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
- Fix: check endpoint expression when execute http command
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issue associated to this PR? (just to check...)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issue was created

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NTC

- Add: X-Processing-Time response header with processing time (in milliseconds) expended by current HTTP measure (iotagent-node-lib#1650)
7 changes: 3 additions & 4 deletions lib/bindings/HTTPBinding.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ function executeCommand(apiKey, group, device, cmdName, serializedPayload, conte
'content-type': contentType
}
};
if (options.endpoint) {
if (options.url) {
// endpoint could be an expression
const parser = iotAgentLib.dataPlugins.expressionTransformation;
let attrList = iotAgentLib.dataPlugins.utils.getIdTypeServSubServiceFromDevice(device);
Expand All @@ -224,11 +224,11 @@ function executeCommand(apiKey, group, device, cmdName, serializedPayload, conte
// expression result will be the full command payload
let endpointRes = null;
try {
endpointRes = parser.applyExpression(options.endpoint, ctxt, device);
endpointRes = parser.applyExpression(options.url, ctxt, device);
} catch (e) {
// no error should be reported
}
options.url = endpointRes ? endpointRes : options.endpoint;
options.url = endpointRes ? endpointRes : options.url;
}
if (config.getConfig().http.timeout) {
options.timeout = config.getConfig().http.timeout;
Expand Down Expand Up @@ -516,7 +516,6 @@ function setPollingAndDefaultTransport(device, group, callback) {
device.polling = !(group && group.endpoint);
}
}

callback(null, device);
}

Expand Down
2 changes: 1 addition & 1 deletion test/unit/ngsiv2/HTTP_commands_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ const groupCreation = {
resource: '/iot/json',
apikey: 'KL223HHV8732SFL1',
entity_type: 'TheLightType',
endpoint: 'http://localhost:9876/command',
endpoint: '"http://localhost:9876/" + "command"',
transport: 'HTTP',
commands: [
{
Expand Down
Loading