Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: merge redirect chains #232

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

cristianoventura
Copy link
Collaborator

Description

Currently, when exporting a script, the Studio generates checks for all requests in a redirect chain. For example, the URL http://www.k6.io does 3 redirects.

$ curl -v -L http://www.k6.io 2>&1 | grep -i "^< location:"
< Location: https://www.k6.io/
< location: http://k6.io/index.html
< Location: https://k6.io/index.html

Right now, one check for each request above is generated when exporting the script, which is unexpected behaviour.

This PR introduces logic responsible for identifying and resolving a redirect chain, ensuring that only the initial request and the check for the final response are present.

Example: Request to http://www.k6.io (first request in the chain) checks for the response in https://k6.io/index.html (final response in the chain).

How to Test

  • Create a recording and browse to a website that does at least one redirect, such as http://www.k6.io (note the HTTP protocol)
  • Check the redirect chain in the request list
    image
  • Export a script and verify that only one check is present (checking for the HTTP status of the last request in the chain)

Checklist

  • I have performed a self-review of my code.
  • I have added tests for my changes.
  • I have run linter locally (npm run lint) and all checks pass.
  • I have run tests locally (npm test) and all tests pass.
  • I have commented on my code, particularly in hard-to-understand areas.

Related PR(s)/Issue(s)

Resolves #206

@cristianoventura cristianoventura self-assigned this Oct 2, 2024
@cristianoventura cristianoventura marked this pull request as ready for review October 2, 2024 17:46
@cristianoventura cristianoventura requested a review from a team as a code owner October 2, 2024 17:46
@cristianoventura cristianoventura requested review from e-fisher and Llandy3d and removed request for a team October 2, 2024 17:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Requests generated for 302 redirects chains
1 participant