5 ms·
I wrote http-translator which is one of the linked related projects. It has a smaller feature set, but is just a few hundred lines and can be easily extended to
by rgovostes 5y ago
I wrote http-translator which is one of the linked related projects. It has a smaller feature set, but is just a few hundred lines and can be easily extended to support new frontends (input formats other than curl) and backends (i.e., output languages).
https://ryan.govost.es/http-translator/ https://ryan.govost.es/http-translator/ | https://github.com/rgov/http-translator https://github.com/rgov/http-translator
Mine was a project for learning modern-ish JavaScript, and I found that packages for parsing command line arguments in JS were generally poor. I wrote my own shell lexer that is simpler than Eric S. Raymond's in the Python standard library while passing the test suite, and since Burp Suite generates curl commands that use Bash ANSI C strings, I support those too. https://www.npmjs.com/package/shlex https://www.npmjs.com/package/shlex
If I were to do further development, I would ditch my curl command line parsing in favor of building curl with Emscripten and having it generate the full HTTP request, then leverage the existing request parser.
curl already supports a —-libcurl flag that generates equivalent C code, and it might be easy to extract the curl_easy_setopt() calls from it.
Both our projects should probably support the built-in urllib.request for Python; Requests isn’t always necessary anymore.