Skip to content

[web]bugfix: clear request body when http method changes to GET#4163

Open
Wyh-max-star wants to merge 2 commits into
apache:masterfrom
Wyh-max-star:fix-2298-clear-request-body
Open

[web]bugfix: clear request body when http method changes to GET#4163
Wyh-max-star wants to merge 2 commits into
apache:masterfrom
Wyh-max-star:fix-2298-clear-request-body

Conversation

@Wyh-max-star

Copy link
Copy Markdown

What changed

Clear the request body when the HTTP method is changed from POST to GET in the HTTP/API monitor form.

Why

Fixes #2298.

Previously, when users changed the HTTP method from POST to GET, the previously entered request body could still remain in the form and be submitted with the GET configuration.

How tested

  • Added/updated the related monitor form unit test.
  • Manually verified that changing the HTTP method from POST to GET clears the request body.
  • Verified that switching back to POST still allows editing the request body.

@Wyh-max-star Wyh-max-star force-pushed the fix-2298-clear-request-body branch from 23fe7e6 to dcc6d54 Compare June 18, 2026 11:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Fixes the HTTP/API monitor form so that when the HTTP method is changed to a no-body method (e.g., GET), any previously-entered request payload is cleared to avoid submitting a hidden/stale body.

Changes:

  • Clear the payload advanced param when httpMethod changes to a method without a request body.
  • Also clear payload defensively right before detect/submit to avoid persisting stale payloads.
  • Add unit tests to validate clearing/retaining payload across method changes and submission.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
web-app/src/app/routes/monitor/monitor-form/monitor-form.component.ts Adds a helper to clear payload for no-body methods and invokes it on depend-change and before detect/submit.
web-app/src/app/routes/monitor/monitor-form/monitor-form.component.spec.ts Updates tests to validate payload clearing/retention behavior for method changes and submission.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +275 to +278
private clearPayloadIfHttpMethodHasNoBody(httpMethod: unknown): void {
if (httpMethod == null || ['POST', 'PUT', 'PATCH'].includes(String(httpMethod).toUpperCase())) {
return;
}
Comment on lines +55 to +61
it('should keep payload when httpMethod changes to POST-like methods', () => {
component.advancedParams = [{ field: 'payload', paramValue: 'old body' } as any];

component.onDependChanged('POST', 'httpMethod');

expect(component.advancedParams[0].paramValue).toBe('old body');
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] When http method change by POST to GET,the request body didn't delete

3 participants