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

Request Rewriting not working as expected with regex #1236

Open
Deepak1711 opened this issue Jan 18, 2024 · 2 comments
Open

Request Rewriting not working as expected with regex #1236

Deepak1711 opened this issue Jan 18, 2024 · 2 comments

Comments

@Deepak1711
Copy link

I am using following tar: gor_1.3.3_x64.tar.gz

Gor command used:
./gor --input-raw :3000 --output-http="http://athena-service.uranus.svc.cluster.local"
--http-rewrite-url "/onemg-internal/end_user/v1/drug_skus/(\d+)/dynamic:/pharma-pdp/v1/drug/dynamic/$1"
--http-allow-url "/onemg-internal/end_user/v1/drug_skus/(\d+)/dynamic"

Request is being received at the output server, but the regex group is not captured inside $1.
Screenshot 1945-10-28 at 8 42 31 PM

As you can see in the above SS, the uri is /pharma-pdp/v1/drug/dynamic/ while it should have been /pharma-pdp/v1/drug/dynamic/1234.

Can somebody help with this?

Copy link

dosubot bot commented Jan 18, 2024

🤖

Hello @Deepak1711! 👋

I'm Dosu, an AI bot that helps with bug-solving, Q&A, and onboarding contributors. While we're waiting for a human maintainer, I'm here to help with your GoReplay journey. Don't worry, we'll get your issue sorted out! 😊💻🚀

Based on your description, it seems like you're experiencing an issue with the --http-rewrite-url command in GoReplay v1.3.3. The regular expression group should indeed be captured inside $1 when using this command.

Your command appears to be correct:

./gor --input-raw :3000 --output-http="http://athena-service.uranus.svc.cluster.local" \
--http-rewrite-url "/__onemg-internal__/end_user/v1/drug_skus/(\d+)/dynamic:/pharma-pdp/v1/drug/dynamic/$1" \
--http-allow-url "/__onemg-internal__/end_user/v1/drug_skus/(\d+)/dynamic"

This command should rewrite all /__onemg-internal__/end_user/v1/drug_skus/<drug_id>/dynamic requests to /pharma-pdp/v1/drug/dynamic/<drug_id>.

If the regex group is not being captured correctly, it might be a bug in the version of GoReplay you're using. I would recommend updating to the latest version of GoReplay and trying again. If the problem persists, it might be worth reporting this as a bug to the GoReplay team.

The --http-rewrite-url command in GoReplay v1.3.3 is used for rewriting URLs based on a mapping. It expects a value in the ":" format, where ":" is a delimiter. In the <replace> section, you can use captured regexp group values. This works similarly to the replace method in Javascript or gsub in Ruby.

For more information, you can refer to the Request Rewriting section in the GoReplay documentation.

I hope this helps! If you have any other questions or need further clarification, feel free to ask.

-Dosu

Sources


This response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research.

Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant.

If you want to continue the conversation, start your reply with @dosu-bot.

@Deepak1711
Copy link
Author

It seems I am already on the latest stable version. Reference: https://github.com/buger/goreplay/releases

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

No branches or pull requests

1 participant