|
| 1 | +#include "_doctype.html" |
| 2 | +<html> |
| 3 | +<head> <title>curl - Cheat Sheet</title> |
| 4 | +#include "css.t" |
| 5 | +<link rel="stylesheet" type="text/css" href="cheat-sheet.css"> |
| 6 | +</head> |
| 7 | + |
| 8 | +#define CURL_DOCS |
| 9 | +#define CURL_URL docs/cheat-sheet.html |
| 10 | + |
| 11 | +#define TOOL_DOCS |
| 12 | +#include "_menu.html" |
| 13 | +#include "setup.t" |
| 14 | + |
| 15 | +WHERE2(Docs, "/docs/", Cheat Sheet) |
| 16 | + |
| 17 | +TITLE(curl HTTP cheat sheet) |
| 18 | +<div class="relatedbox"> |
| 19 | +<b>Related:</b> |
| 20 | +<br><a href="manpage.html">curl man page</a> |
| 21 | +<br><a href="tutorial.html">Tutorial</a> |
| 22 | +</div> |
| 23 | + |
| 24 | +<section> |
| 25 | + <h2>GET requests</h2> |
| 26 | + <div class="item"> |
| 27 | + <h3>GET a website</h3> |
| 28 | + <code>curl https://example.com</code> |
| 29 | + </div> |
| 30 | + |
| 31 | + <div class="item"> |
| 32 | + <h3>Follow redirects</h3> |
| 33 | + <code>curl <a href="https://curl.se/docs/manpage.html#-L"><em>-L</em></a> https://example.com</code> |
| 34 | + </div> |
| 35 | + |
| 36 | + <div class="item"> |
| 37 | + <h3>Hide the progress bar</h3> |
| 38 | + <code>curl <a href="https://curl.se/docs/manpage.html#-s"><em>-s</em></a> https://example.com</code> |
| 39 | + </div> |
| 40 | + |
| 41 | + <div class="item"> |
| 42 | + <h3>Output to a file</h3> |
| 43 | + <code>curl <a href="https://curl.se/docs/manpage.html#-o"><em>-o</em></a> out.html https://example.com/ </code> |
| 44 | + </div> |
| 45 | +</section> |
| 46 | + |
| 47 | +<section> |
| 48 | + <h2> Set or view headers </h2> |
| 49 | + <div class="item"> |
| 50 | + <h3>Show response headers</h3> |
| 51 | + <code>curl <a href="https://curl.se/docs/manpage.html#-i"><em>-i</em></a> https://example.com</code> |
| 52 | + </div> |
| 53 | + |
| 54 | + <div class="item"> |
| 55 | + <h3>Make a HEAD request</h3> |
| 56 | + <code>curl <a href="https://curl.se/docs/manpage.html#-I"><em>-I</em></a> https://example.com</code> |
| 57 | + </div> |
| 58 | + |
| 59 | + <div class="item"> |
| 60 | + <h3>Set a header</h3> |
| 61 | + <code>curl https://pages.github.io |
| 62 | + <span class="nobreak"><a href="https://curl.se/docs/manpage.html#-H"> |
| 63 | + <em>-H</em></a> "Host: raytracing.github.io"</span> |
| 64 | + </code> |
| 65 | + </div> |
| 66 | +</section> |
| 67 | + |
| 68 | +<section> |
| 69 | + <h2>POST requests</h2> |
| 70 | + <div class="item"> |
| 71 | + <h3>POST some JSON</h3> |
| 72 | + <code> |
| 73 | + curl -v httpbin.io/post |
| 74 | + <span class="nobreak"><a href="https://curl.se/docs/manpage.html#--json"><em>--json</em></a> '{"key":"value"}'</span> |
| 75 | + </code> |
| 76 | + </div> |
| 77 | + |
| 78 | + <div class="item"> |
| 79 | + <h3>POST JSON from a file</h3> |
| 80 | + <code> |
| 81 | + curl -v httpbin.io/post |
| 82 | + <span class="nobreak"><a href="https://curl.se/docs/manpage.html#--json"><em>--json</em></a> @file.json</span> |
| 83 | + </code> |
| 84 | + </div> |
| 85 | + |
| 86 | + <div class="item"> |
| 87 | + <h3>POST application/url-encoded data</h3> |
| 88 | + <code> |
| 89 | + curl -v httpbin.io/post |
| 90 | + <span class="nobreak"><a href="https://curl.se/docs/manpage.html#--data-urlencode"><em>--data-urlencode</em></a> name=maya</span> |
| 91 | + <span class="nobreak"><a href="https://curl.se/docs/manpage.html#--data-urlencode"><em>--data-urlencode</em></a> date=2024-01-01</span> |
| 92 | + </code> |
| 93 | + </div> |
| 94 | +</section> |
| 95 | + |
| 96 | +<section> |
| 97 | + <h2>More</h2> |
| 98 | + |
| 99 | + <div class="item"> |
| 100 | + <h3>Make a DELETE request</h3> |
| 101 | + <code>curl <a href="https://curl.se/docs/manpage.html#-X"><em>-X</em></a> DELETE example.com</code> |
| 102 | + </div> |
| 103 | + |
| 104 | + <div class="item"> |
| 105 | + <h3>Override DNS resolution</h3> |
| 106 | + <code>curl example.com <a href="https://curl.se/docs/manpage.html#--resolve"><em>--resolve</em></a> <span class="nobreak">example.com:443:23.220.75.245</span></code> |
| 107 | + </div> |
| 108 | + |
| 109 | + <div class="item"> |
| 110 | + <h3>Do basic authentication</h3> |
| 111 | + <code> |
| 112 | + curl <a href="https://curl.se/docs/manpage.html#-u"><em>-u</em></a> user:pass |
| 113 | + example.com |
| 114 | + </code> |
| 115 | + </div> |
| 116 | + |
| 117 | + |
| 118 | +</section> |
| 119 | + |
| 120 | +#include "_footer.html" |
| 121 | +</body> |
| 122 | +</html> |
0 commit comments