Skip to content

Commit

Permalink
Set HTTP 200 with no content as the default config response from the …
Browse files Browse the repository at this point in the history
…agent
  • Loading branch information
cbeauchesne authored and bwoebi committed Oct 1, 2024
1 parent 9ea2886 commit d34f403
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions utils/proxy/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,19 +255,22 @@ def _modify_response(self, flow):
self._add_rc_capabilities_in_info_request(flow)

if flow.request.path == "/v0.7/config":

# mimic the default response from the agent
flow.response.status_code = 200
flow.response.content = b""

if self.rc_api_command is not None:
request_content = json.loads(flow.request.content)
runtime_id = request_content["client"]["client_tracer"]["runtime_id"]

payload = self.rc_api_command
if runtime_id in self.rc_api_runtime_ids_applied:
# this runtime id has already been applied
payload = "{}"
return

logger.info(f" => modifying rc response for runtime ID {runtime_id}")

flow.response.status_code = 200
flow.response.content = payload
flow.response.content = self.rc_api_command

self.rc_api_runtime_ids_applied.add(runtime_id)
elif self.rc_api_sequential_commands is not None:
Expand All @@ -285,7 +288,6 @@ def _modify_response(self, flow):
self.rc_api_runtime_ids_request_count[runtime_id]
]

flow.response.status_code = 200
flow.response.content = json.dumps(response).encode()

self.rc_api_runtime_ids_request_count[runtime_id] += 1
Expand Down

0 comments on commit d34f403

Please sign in to comment.