| 171 | } |
| 172 | |
| 173 | void HttpOptionsListener::value(String value) { |
| 174 | if (_depth == 1) { |
| 175 | // Top-level values |
| 176 | if (_currentKey == "method") { |
| 177 | _request.method = value.c_str(); |
| 178 | } else if (_currentKey == "timeout") { |
| 179 | int timeout = value.toInt(); |
| 180 | _request.timeout_ms = std::min(static_cast<uint32_t>(timeout), HttpCommand::MAX_TIMEOUT_MS); |
| 181 | } else if (_currentKey == "body") { |
| 182 | _request.body = value.c_str(); |
| 183 | // Default to POST if body is present and method not set |
| 184 | if (_request.method == "GET") { |
| 185 | _request.method = "POST"; |
| 186 | } |
| 187 | } else if (_currentKey == "halt_on_error") { |
| 188 | // "halt_on_error":true (default) = halt GCode on error, "halt_on_error":false = continue |
| 189 | _request.fail_on_error = (value == "true" || value == "1"); |
| 190 | } |
| 191 | } else if (_depth == 2) { |
| 192 | // Nested object values (headers or extract) |
| 193 | if (_inHeaders && !_nestedKey.isEmpty()) { |
| 194 | _request.headers[_nestedKey.c_str()] = value.c_str(); |
| 195 | } else if (_inExtract && !_nestedKey.isEmpty()) { |
| 196 | _request.extract[_nestedKey.c_str()] = value.c_str(); |
| 197 | } |
| 198 | } |
| 199 | } |
| 200 | |
| 201 | void HttpOptionsListener::startObject() { |
| 202 | _depth++; |