Skip to content
New issue

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

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

Already on GitHub? # to your account

Issue with Passing Multiple Command Line Arguments to WAGI Handler via URL #192

Open
FerrazArthur opened this issue Oct 5, 2023 · 2 comments

Comments

@FerrazArthur
Copy link

I'm currently working with the WAGI interface and I'm facing an issue when trying to pass multiple arguments to a C to WebAssembly (WASM) handler. The handler code uses argv to iterate through arguments. While I've been successful in passing individual arguments like '--tamanho=10000' or '--help' with QUERY_STRING, I'm struggling to pass multiple arguments.

Valid Arguments:

--tamanho=<integer>: Specifies the number of elements to be sorted.
--imprime: Enables the printing of elements before and after sorting.
--help: Prints the help information.

Problem:
I need to pass multiple arguments simultaneously, such as --tamanho=20 and --imprime, but I haven't been able to do this successfully.

Attempts:
I've tried various ways to pass these multiple arguments, but none of them have worked:

curl http://127.0.0.1:3000/quicksort?--tamanho=20+--imprime
curl http://127.0.0.1:3000/quicksort?--tamanho=20\+--imprime
curl http://127.0.0.1:3000/quicksort?"--tamanho=20\+--imprime"
curl "http://127.0.0.1:3000/quicksort?--tamanho=20\+--imprime"
curl http://127.0.0.1:3000/quicksort?param1=--tamanho=20&param2=--imprime
curl http://127.0.0.1:3000/quicksort?param1=--tamanho=20\&param2=--imprime
curl http://127.0.0.1:3000/quicksort?--tamanho=1000%20--imprime
curl http://127.0.0.1:3000/quicksort?--tamanho=1000\%20--imprime
curl http://127.0.0.1:3000/quicksort?--tamanho=1000\ --imprime

Expected Behavior:
I should be able to pass multiple arguments, such as --tamanho=20 and --imprime, to the handler via the URL, and the handler should be able to correctly interpret and process these arguments.

Actual Behavior:
None of the above methods have successfully allowed me to pass multiple arguments to the WAGI handler in such a way that the argv[] identify them individually. Please advise on the correct way to pass multiple arguments in this scenario or provide a solution to this issue. In order to bypass this, i changed the design of the arguments string, but thats not ideal for my use case.

Thank you for your assistance in resolving this problem.

@itowlson
Copy link
Contributor

itowlson commented Oct 5, 2023

Could you try please:

curl localhost:3000/?--tamanho=20\&--imprime

With this URL, for me the argv contains

/
--tamanho=20
--imprime

@FerrazArthur
Copy link
Author

I thought i had tried it already, but it actually worked this time! thank you for the help, really appreciate.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants