{"id":5489,"date":"2014-03-12T21:53:30","date_gmt":"2014-03-12T20:53:30","guid":{"rendered":"http:\/\/daniel.haxx.se\/blog\/?p=5489"},"modified":"2024-03-12T08:29:29","modified_gmt":"2024-03-12T07:29:29","slug":"whats-next-for-curl","status":"publish","type":"post","link":"https:\/\/daniel.haxx.se\/blog\/2014\/03\/12\/whats-next-for-curl\/","title":{"rendered":"what&#8217;s &#8211;next for curl"},"content":{"rendered":"\n<p><a href=\"https:\/\/curl.se\/\">curl<\/a> is finally getting support for doing multiple <em>independent<\/em> requests specified in the same command line, which allows users to make even better use of curl&#8217;s excellent persistent connection handling and more. I don&#8217;t know when I first got the question of how to do a GET <em>and<\/em> a POST in a single command line with curl, but I do know that we&#8217;ve had the <a href=\"https:\/\/curl.se\/docs\/todo.html\">TODO<\/a> item about adding such a feature mentioned since 2004 &#8211; and I know it wasn&#8217;t added there right away&#8230;<\/p>\n\n\n\n<p>Starting in <strong>curl 7.36.0<\/strong>, we can respond with a better answer: use the <a href=\"https:\/\/curl.se\/docs\/manpage.html#OPTIONS\"><code>--next<\/code><\/a> option!<\/p>\n\n\n\n<p>curl has been able to work with multiple URLs on the command line virtually since day 1, but all the command line options would then mostly apply and be used for <em>all<\/em> specified URLs.<\/p>\n\n\n\n<p>This new <code>--next<\/code> option introduces a &#8220;boundary&#8221;, or a wall if you like, between options on the command line. The options set <strong>before<\/strong> &#8211;next will be handled as one request and the options set on <strong>the right side<\/strong> of &#8211;next will start adding up to another request. You of course then need to specify at least one URL per individual such section and you can add any number of &#8211;next on the command line. If the command line then gets too long, we also support the same logic and sequence in the &#8220;config files&#8221; which is the way you can specify command line arguments into a text file and have curl read them from there using <a href=\"https:\/\/curl.se\/docs\/manpage.html#-K\">-K or <code>--config<\/code><\/a>.<\/p>\n\n\n\n<p>Here&#8217;s a somewhat silly example to illustrate. This fist makes a POST and then a HEAD to two different pages on the same host:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -d FOO example.com\/input.cgi --next--head example.com\/robots.txt<\/code><\/pre>\n\n\n\n<p>Thanks to Steve Holme for his hard work on implementing this!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>curl is finally getting support for doing multiple independent requests specified in the same command line, which allows users to make even better use of curl&#8217;s excellent persistent connection handling and more. I don&#8217;t know when I first got the question of how to do a GET and a POST in a single command line &hellip; <a href=\"https:\/\/daniel.haxx.se\/blog\/2014\/03\/12\/whats-next-for-curl\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">what&#8217;s &#8211;next for curl<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":5,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[33,372],"class_list":["post-5489","post","type-post","status-publish","format-standard","hentry","category-curl","tag-curl-and-libcurl","tag-url"],"_links":{"self":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/5489","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/comments?post=5489"}],"version-history":[{"count":18,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/5489\/revisions"}],"predecessor-version":[{"id":24333,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/posts\/5489\/revisions\/24333"}],"wp:attachment":[{"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/media?parent=5489"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/categories?post=5489"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/daniel.haxx.se\/blog\/wp-json\/wp\/v2\/tags?post=5489"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}