summaryrefslogtreecommitdiffstats
path: root/src/rest.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/rest.c')
-rw-r--r--src/rest.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/rest.c b/src/rest.c
index 1f35174..ff51332 100644
--- a/src/rest.c
+++ b/src/rest.c
@@ -296,6 +296,7 @@ int og_send_request(enum og_rest_method method, enum og_cmd_type type,
const char *uri;
unsigned int i;
int client_sd;
+ bool has_seq;
if (method == OG_METHOD_GET)
snprintf(method_str, 5, "GET");
@@ -312,9 +313,17 @@ int og_send_request(enum og_rest_method method, enum og_cmd_type type,
JSON_COMPACT);
uri = og_cmd_to_uri[type];
- snprintf(buf, OG_MSG_REQUEST_MAXLEN,
- "%s /%s HTTP/1.1\r\nContent-Length: %d\r\n%s\r\n\r\n%s",
- method_str, uri, content_length, content_type, content);
+
+ switch (type) {
+ case OG_CMD_POWEROFF:
+ case OG_CMD_REBOOT:
+ case OG_CMD_STOP:
+ has_seq = false;
+ break;
+ default:
+ has_seq = true;
+ break;
+ }
for (i = 0; i < params->ips_array_len; i++) {
cli = og_client_find(params->ips_array[i]);
@@ -331,6 +340,13 @@ int og_send_request(enum og_rest_method method, enum og_cmd_type type,
continue;
}
+ if (++cli->seq == 0)
+ cli->seq++;
+
+ snprintf(buf, OG_MSG_REQUEST_MAXLEN,
+ "%s /%s HTTP/1.1\r\nContent-Length: %d\r\nX-Sequence: %u\r\n%s\r\n\r\n%s",
+ method_str, uri, content_length, has_seq ? cli->seq : 0, content_type, content);
+
if (send(client_sd, buf, strlen(buf), 0) < 0)
continue;