--libcurl
everything.curl.dev
everything.curl.dev
Then I'd use something like https://curlconverter.com/ to convert it into request code of the language I'm using.
In a way curl is like the "intermediate representation" that we can use to translate into anything.
Eg an HTTP request should have a client header, but they're typically not relevant to what you're trying to do.
curl is like an HTTP request that specifies only the parts you care about. It's brief, and having access to bash makes it easy to express something like "set this field to a timestamp".
That's kind of what I mean. E.g. I believe curl will add a Content-Length header, which is good to have, but I don't need every example HTTP call to show me that.
To me a curl call is kind of shorthand for "these are the parts unique to this request, do the appropriate thing for general-use headers". If I see a raw HTTP request missing a Content-Length header (assuming it could use one), I don't know whether to assume that I do the normal thing, or whether the server ignores Content-Length, or perhaps if the server specifically errors out when it's set.
Vice-versa, if a raw HTTP request does have a Content-Length header, I'm not sure if that means it's required or just supported.
If I see a curl call specifying Content-Length, it sets off the "something weird is going on" bells in my head. Nobody specifies that in curl, so it's presence is odd and worth looking at.
HTTP is more flexible than "Copy as cURL". There are things that can be done with HTTP that cannot be done with cURL.
Such as?
(NB. I am not a developer. I am not writing software for other people. I do not profit from online advertising. I use a text-only browser with no auto-loading of resources and no Javascript engine; I never see ads. Been using HTTP/1.1 pipelining, which all major httpds support, outside the browser, daily, for many years. It works really well for me; I rely on it. As such, I am not the appropriate person with which to debate the relative merits of HTTP protocols for developers who profit from online ads served via "modern" web browsers.)
I also use the browser's 'copy as curl' function quite frequently as it's so convenient, having all auth and encoding headers set to _definitely_ work (instead of messing around with handmade, multi-line curl command lines)
It would be nice if more sites offered themselves as PWAs that worked when you set "throttling" to "offline" in the dev menu, so that you could ensure that no data is leaving the browser when working with sensitive info.
> We do not transmit or record the curl commands you enter or what they're converted to. This is a static website (hosted on GitHub Pages) and the conversion happens entirely in your browser using JavaScript.
Not to mention the pattern nowadays is: offer a free service, pay a little lip service to privacy concerns, then the enshittification train comes rolling down the tracks a few years/ months later.
Not saying this site is going to go down that path but IMO giving the benefit of the doubt with regard to privacy on the internet is bad practice for 2024.
See: https://github.com/curlconverter/curlconverter.github.io/blo...
You'd simply run:
CURL url: "https://example.com" method: 'post
in an interactive system, that can either represent your shell, or your application code. We need --libcurl because UNIX is not an interactive environment, so there is an enormous abyss between runtime and compile time.(Syntax in this example from a Smalltalk-like environment I have been designing, should be understandable enough)
---
1: "An operating system is a collection of things that don't fit in a language. There shouldn't be one." — Dan Ingalls, 1981
Too bad we're stuck with UNIX/POSIX model - you could even take this idea of exported data structures and have the terminal represent data in the preferred users format instead of having tools like jq.
The only way is starting from scratch, with a novel approach and programming model.
The calling convention can be assumed to be the same as used by the OS/arch combination.
I'm talking about the status quo today, not how you can improve in a perfect world where everybody adopts a better way of doing things.
Implementing an half-baked Smalltalk layer on top of UNIX will not turn UNIX into a Smalltalk environment.
Invoke-WebRequest -Method 'Get' -Uri 'https://example.com'
And the response is a typed object:That you can pipe properly by piping objects not strings, e.g. :
Invoke-WebRequest -Method 'Get' -Uri 'https://example.com' | Select-Object -ExpandProperty Headers
Outputs: Key Value
--- -----
Age 438810
Vary Accept-Encoding
X-Cache HIT
Content-Length 1256
Cache-Control max-age=604800
Content-Type text/html; charset=UTF-8
Date Mon, 29 Jan 2024 15:08:42 GMT
Expires Mon, 05 Feb 2024 15:08:42 GMT
ETag "3147526947+ident"
Last-Modified Thu, 17 Oct 2019 07:18:26 GMT
Server ECS (nyb/1D15)Powershell has a high level object model but it doesn't make Windows itself anymore programmable and interactive, as a whole than zsh does for Linux. It is no Lisp Machine.
[1] https://github.com/dotnet/Open-XML-SDK/releases/tag/v2.5
curl https://ifconfig.me --libcurl ip_fetcher.c
# Output: your ip address, and a file ip_fetcher.c
gcc -o ip_fetcher ip_fetcher.c -lcurl
# Output: no errors, just a file ip_fetcher
./ip_fetcher
# Output: your ip address
(I'm sure most people are saying "no duh" right now, but I'm probably not the only one on here who doesn't write C code every day!) $ curl https://ifconfig.me --libcurl ip_fetcher.c
$ make LDFLAGS=-lcurl ip_fetcher
$ ./ip_fetcher
(I just find make a heck of a lot easier than running direct cc commands)We use libcurl for the super reliability and top features (HTTP/3 for instance) and we've added little features like:
- requests chaining,
- capturing and passing data from a response to another request,
- response tests (JSONPath, XPath, etc...)
There is nice syntax sugar for requesting REST/SOAP/GraphQL APIs but, at the core, it's just libcurl! Using verbose option, you can grep the curl commands for instance. (I'm one of the maintainers)
[1]: https://hurl.dev
Thanks for your work
It was a multi-day process and every time like two days in I'd hit some snag.
But yes, perhaps as a follow-up, we would need to ask for
1. a speed-up of the process or
2. find a way to look up and redistribute existing conversion flows
So 'quinino' might work here.
They are deterministic tools which does what you want in a battle tested way, and will let me sleep well at night, which is an underappreciated feature of mature programs.
curl-as-librucl https://www.example.comso this isn't a new trend...
Possibly via the Eclipse extension: https://marketplace.eclipse.org/content/bytecode-outline
Rust-evangelism aside, I guess one can run the program under ltrace to achieve almost the same result.
Fair point about memory allocations in C, but often alt languages rely on other people's code which you'd implicitly trust to do the same thing. So then it becomes an argument of testing and trust. All the same, you trust strangers code or you write your own.
Stabilisers for some, but definitely not others.
Assuming (as usual) that the code generation is solid because of curl’s reputation: why not trust it? It would be pretty bad if the generator could emit memory-unsafe code. (I don’t know.)
It’s the consumer of this tool and all the code around it that will get written I don’t trust.
—-libcurl example.py