4 ms·
One thing I am always sure to share with collegues when we discuss curl, is the fact from the command line you can generate the underlying C code. This is pret
by lettergram 9y ago
One thing I am always sure to share with collegues when we discuss curl, is the fact from the command line you can generate the underlying C code.
This is pretty useful when creating a CLI for pretty much any app, and I've used it regularly to generate a CLI for an app.
My post on how to do it: http://austingwalters.com/export-a-command-line-curl-command-to-an-executable/ http://austingwalters.com/export-a-command-line-curl-command...
- ww520 9y agoThat's amazing. Never knew that. Learn something today.
- andrestc 9y agoThis is amazing! Thanks for sharing
- 0xFFFE 9y agoBrilliant, thanks for sharing.
- henvic 9y agoAmazing tip!
- innagadadavida 9y agoThere is one for generating goalang code as well: https://github.com/mholt/curl-to-go https://github.com/mholt/curl-to-go Also, it does not depend on libcurl.
- aplorbust 9y agoIt wasnt until 2006 that curl added HTTP/1.1 pipelining support. Hence I always used netcat instead of curl because I utilised pipelining heavily for text/html retrieval (IME, most servers supported it). Imagine something like this with curl: curl << eof http://example.com/a.htm http://example.com/b.htm eof where curl only opens a single connection. Alas, AFAIK, pipelining is still not enabled in the curl binary. As I understand it, the --libcurl option only generates code for what is possible with the curl binary, e.g., curl_easy_init(), curl_easy_setopt(), etc. As such, it will not generate code using curl_multi_init(), curl_multi_setopt(), etc. I have to automate the code generation myself.
- bagder 9y agoIf you invoke "curl http://example.com/a.htm http://example.com/a.htm http://example.com/b.htm" http://example.com/b.htm", curl will only use a single connection.
- aplorbust 9y agoTo reproduce: curl --libcurl 1.c http://example.com/a.htm http://example.com/b.htm grep curl_multi_init 1.c https://curl.haxx.se/mail/archive-2008-02/0036.html https://curl.haxx.se/mail/archive-2008-02/0036.html
- aplorbust 9y agoHere is how RFC 7230 defines "HTTP/1.1 pipelining": "6.3.2. Pipelining A client that supports persistent connections MAY "pipeline" its requests (i.e., send multiple requests without waiting for each response)." AFAIK, the curl binary does not do pipelining. And, AFAIK, it will not generate code to do pipelining by invoking it with --libcurl.
- aplorbust 9y agoHere is how RFC 7230 defines "HTTP/1.1 pipelining": "6.3.2. Pipelining A client that supports persistent connections MAY "pipeline" its requests (i.e., send multiple requests without waiting for each response)." AFAIK, the curl binary does not do pipelining by this definition. And, AFAIK, it will not generate code to do pipelining by invoking it with --libcurl.
- deleted 9y ago[deleted]