Hacker News new | ask | show | jobs
by lettergram 3075 days 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...

6 comments

There is one for generating goalang code as well: https://github.com/mholt/curl-to-go Also, it does not depend on libcurl.
That's amazing. Never knew that. Learn something today.
It 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.

If you invoke "curl http://example.com/a.htm http://example.com/b.htm", curl will only use a single connection.
Yes, but it will wait for Response A before sending Request B.
It probably isn't too obvious here, but yeah I know how it works =)

(I'm Daniel, who wrote the blog post discussed here and leads the curl development...)

To 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
Here 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.

Here 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.

Brilliant, thanks for sharing.
This is amazing! Thanks for sharing
Amazing tip!