[web]bugfix: clear request body when http method changes to GET#4163
Open
Wyh-max-star wants to merge 2 commits into
Open
[web]bugfix: clear request body when http method changes to GET#4163Wyh-max-star wants to merge 2 commits into
Wyh-max-star wants to merge 2 commits into
Conversation
23fe7e6 to
dcc6d54
Compare
Contributor
There was a problem hiding this comment.
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
payloadadvanced param whenhttpMethodchanges to a method without a request body. - Also clear
payloaddefensively 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'); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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