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

idea: ability to add random string/bytes to the url for dynamic urls #234

Open
timelessnesses opened this issue Jun 13, 2023 · 12 comments
Open

Comments

@timelessnesses
Copy link

Here's my suggestion
There would be something like ${random_string/bytes(length=10)}
And you could put it inside URL like this http://redirect/add?url=${random_string(10)} so you could benchmark the add redirect URL.
This might be useful if you want to stress testing for a path that's dynamic.

@timelessnesses timelessnesses changed the title idea: Random string/Program output for the URL idea: ability to add random string/bytes to the url for dynamic urls Jun 13, 2023
@hatoo
Copy link
Owner

hatoo commented Jun 13, 2023

Interesting!
Perhaps using https://github.com/kennytm/rand_regex would be good.

@hatoo
Copy link
Owner

hatoo commented Jun 17, 2023

I've come up with some implementation
You can install the test version by

cargo install --git https://github.com/hatoo/oha.git --branch rand-url
oha --rand-regex-url ...

I wanna hear your opinion

@timelessnesses
Copy link
Author

sorry for late response, i tested it with subdomain url and it errored out


root@somethingcp-10161:~# oha --rand-regex-url http://redi
rect.api.timelessnesses.me/[0-9]
Error: invalid uri character


@hatoo
Copy link
Owner

hatoo commented Jun 19, 2023

. is a special meaning in regex. So

oha --rand-regex-url http://redirect\\.api\\.timelessnesses\\.me/[0-9]

would work.

This is confusing...

@timelessnesses
Copy link
Author

. is a special meaning in regex. So


oha --rand-regex-url http://redirect\\.api\\.timelessnesses\\.me/[0-9]

would work.

This is confusing...

i would rather wrap the regex with braces or something. kind of like
https://instance.{[0-9]}.timelessnesses.me

@hatoo
Copy link
Owner

hatoo commented Jun 19, 2023

I don't like an approach that wraps the regex with braces because parsing those braces is not trivial in extreme cases such as http://localhost/{[}{]}...

So I've chosen to just escape all .s because . is not useful when generating URLs.

@timelessnesses
Copy link
Author

ah okay I see your reason

@hatoo hatoo closed this as completed Jun 24, 2023
@obriat
Copy link

obriat commented Jul 29, 2024

How do you escape ? (query string), I try \\? or \? without success.
You should add a debug mode to display called urls, no?

@hatoo
Copy link
Owner

hatoo commented Jul 29, 2024

I don't know about escaping either.

You should add a debug mode to display called urls, no?

This is a great idea. I'll implement it.

@hatoo hatoo reopened this Jul 29, 2024
@obriat
Copy link

obriat commented Jul 30, 2024

I find out this escape sequence :

\\/path\\?variable=[a-z]{3,15}

Escaping the slash / should be documented.
I don't get the usefulness of --max-repeat other {x,y}, could you please provide details or examples?

@hatoo
Copy link
Owner

hatoo commented Aug 3, 2024

I merged #549

Escaping on shells depends on how you quote it.
in my Bash

cargo run -- --dump-urls 16 --rand-regex-url 'http://localhost:3000/path/\?variable=[a-z]{3,15}'

Just ok.

I don't get the usefulness of --max-repeat other {x,y}, could you please provide details or examples?

--max-repeat exists because how many times repeated by regex *, + is unknown and ideally a user sets it.
If you use {x, y}, --max-repeat is not effect.

@obriat
Copy link

obriat commented Aug 3, 2024

Thanks !
May be you should update the doc/README and give more details and exemple about regex and quote ?

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

3 participants