Skip to content

Commit 292930b

Browse files
committed
Add an HTTP cheat sheet
1 parent 11865cd commit 292930b

File tree

4 files changed

+246
-0
lines changed

4 files changed

+246
-0
lines changed

docs/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ PAGES = \
197197
bugbounty.html \
198198
bugs.html \
199199
caextract.html \
200+
cheat-sheet.html \
200201
code-of-conduct.html \
201202
companies.html \
202203
comparison-table.html \
@@ -315,6 +316,9 @@ bugs.html: _bugs.html $(MAINPARTS) bugs.gen
315316
bugs.gen: $(DOCROOT)/BUGS.md faqparse.pl
316317
$(MARKDOWN) < $< > $@
317318

319+
cheat-sheet.html: _cheat-sheet.html $(MAINPARTS)
320+
$(ACTION)
321+
318322
bugbounty.html: _bugbounty.html $(MAINPARTS) bugbounty.gen $(ADVBOX)
319323
$(ACTION)
320324
bugbounty.gen: $(DOCROOT)/BUG-BOUNTY.md

docs/_cheat-sheet.html

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
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>

docs/_menu.html

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@
7171
<a href="/docs/httpscripting.html">HTTP Scripting</a>
7272
<a href="/docs/mk-ca-bundle.html">mk-ca-bundle</a>
7373
<a href="/docs/tutorial.html">Tutorial</a>
74+
<a href="/docs/cheat-sheet.html">Cheat Sheet</a>
7475
<a href="optionswhen.html">When options were added</a>
7576
</div>
7677
</div>

docs/cheat-sheet.css

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
:root {
2+
--darkblue: #093754;
3+
--darkgreen: #0c544c;
4+
}
5+
6+
body {
7+
color: black;
8+
font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
9+
background: white;
10+
border-radius: 16px;
11+
}
12+
13+
.item {
14+
background: white;
15+
padding: 14px 16px;
16+
border-radius: 8px;
17+
border: 1px solid rgba(9, 55, 84, 0.15);
18+
display: flex;
19+
font-size: 1rem;
20+
flex-direction: column;
21+
gap: 6px;
22+
box-shadow: 0 1px 4px rgba(9, 55, 84, 0.08);
23+
transition: all 0.3s ease;
24+
25+
p {
26+
font-size: 1rem;
27+
margin: 0 8px;
28+
}
29+
30+
h3 {
31+
line-height: 1.2em;
32+
font-size: 1.1rem;
33+
margin: 0;
34+
margin-bottom: .4rem;
35+
font-weight: 600;
36+
color: var(--darkblue);
37+
}
38+
39+
40+
label {
41+
display: block;
42+
margin-top: 10px;
43+
}
44+
45+
code {
46+
color: var(--darkgreen);
47+
background: #f8fafc;
48+
font-family: 'SF Mono', 'Monaco', 'Cascadia Code', 'Courier New', monospace;
49+
margin-bottom: 0;
50+
line-height: 1.4rem;
51+
padding: 10px 12px;
52+
border-radius: 6px;
53+
border: 1px solid rgba(9, 55, 84, 0.15);
54+
font-size: 1rem;
55+
text-indent: -1.5em;
56+
padding-left: calc(12px + 1.5em);
57+
}
58+
59+
em {
60+
padding: .2rem .4rem;
61+
background: var(--darkgreen);
62+
color: white;
63+
border-radius: 4px;
64+
font-weight: 600;
65+
font-style: normal;
66+
text-decoration: none;
67+
cursor: pointer;
68+
transition: background-color 0.2s ease;
69+
}
70+
71+
a em {
72+
color: white;
73+
text-decoration: none;
74+
}
75+
76+
a:hover em {
77+
background: var(--darkblue);
78+
text-decoration: underline;
79+
}
80+
81+
h3 code {
82+
padding: 0;
83+
background: transparent;
84+
}
85+
86+
.or {
87+
font-weight: 700;
88+
font-size: 0.8em;
89+
display: block;
90+
margin-left: 30px;
91+
font-family: sans-serif;
92+
}
93+
94+
.nobreak {
95+
white-space: nowrap;
96+
}
97+
}
98+
99+
section {
100+
margin-bottom: 24px;
101+
width: 100%;
102+
display: grid;
103+
gap: 12px;
104+
grid-template-columns: 1fr 1fr;
105+
106+
@media (max-width: 700px) {
107+
& {
108+
display: flex;
109+
flex-direction: column;
110+
gap: 10px;
111+
}
112+
}
113+
114+
h2 {
115+
grid-column: 1/3;
116+
margin: 0;
117+
}
118+
119+
}

0 commit comments

Comments
 (0)