-
-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathhttp-protocol.html
More file actions
639 lines (576 loc) · 35.7 KB
/
http-protocol.html
File metadata and controls
639 lines (576 loc) · 35.7 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="icon" type="image/png" href="images/logo.png">
<link rel="apple-touch-icon" href="images/logo.png">
<title>HTTP Protocol Guide - DevDunia</title>
<script src="https://cdn.tailwindcss.com"></script>
<script src="https://cdn.jsdelivr.net/npm/mermaid@10.6.1/dist/mermaid.min.js"></script>
<style>
body {
background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
}
.mermaid {
background: transparent !important;
}
#diagram svg {
max-width: 100% !important;
height: auto !important;
width: auto !important;
display: block;
margin: 0 auto;
}
#diagram {
display: flex;
align-items: flex-start;
justify-content: center;
width: 100%;
min-height: 100%;
padding: 20px;
}
#diagram-container {
overflow: auto;
height: 100%;
}
.code-block {
background: #1e293b;
border: 1px solid #334155;
border-radius: 8px;
padding: 16px;
font-family: 'Courier New', monospace;
overflow-x: auto;
}
</style>
</head>
<body class="h-screen">
<!-- Background -->
<div class="fixed inset-0 -z-10 bg-gradient-to-br from-gray-900 via-slate-900 to-gray-900"></div>
<!-- Main Container -->
<div class="relative z-10 w-full h-screen flex flex-col">
<!-- Header -->
<div class="bg-slate-800/70 backdrop-blur-md border-b border-slate-700/60 px-6 py-4">
<div class="flex items-center justify-between">
<div class="flex items-center space-x-4">
<button id="back-btn" class="px-3 py-2 bg-slate-600 hover:bg-slate-700 text-white text-sm rounded-lg transition-colors duration-200 flex items-center space-x-2">
<svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M10 19l-7-7m0 0l7-7m-7 7h18"></path>
</svg>
<span>Back</span>
</button>
<div>
<h1 class="text-2xl font-bold text-transparent bg-clip-text bg-gradient-to-r from-blue-400 to-cyan-500">
HTTP Protocol Guide
</h1>
<p class="text-sm text-gray-400 mt-1">Hypertext Transfer Protocol - Web Communication Standard</p>
</div>
</div>
</div>
</div>
<!-- Main Content -->
<div class="flex-1 overflow-auto p-6">
<div class="max-w-6xl mx-auto">
<!-- Introduction -->
<div class="mb-8">
<h2 class="text-3xl font-bold text-white mb-4">What is HTTP?</h2>
<p class="text-gray-300 text-lg leading-relaxed mb-6">
HTTP (Hypertext Transfer Protocol) is an application-layer protocol for distributed, collaborative,
hypermedia information systems. It's the foundation of data communication for the World Wide Web.
</p>
<div class="grid grid-cols-1 md:grid-cols-3 gap-6 mb-8">
<div class="bg-blue-500/10 border border-blue-500/20 rounded-lg p-6">
<h3 class="text-lg font-semibold text-blue-300 mb-2">Stateless</h3>
<p class="text-gray-300 text-sm">Each request is independent and doesn't retain information about previous requests.</p>
</div>
<div class="bg-green-500/10 border border-green-500/20 rounded-lg p-6">
<h3 class="text-lg font-semibold text-green-300 mb-2">Request/Response</h3>
<p class="text-gray-300 text-sm">Client sends requests, server responds with data or status information.</p>
</div>
<div class="bg-purple-500/10 border border-purple-500/20 rounded-lg p-6">
<h3 class="text-lg font-semibold text-purple-300 mb-2">Text-based</h3>
<p class="text-gray-300 text-sm">Human-readable protocol that's easy to debug and understand.</p>
</div>
</div>
</div>
<!-- HTTP Request/Response Flow -->
<div class="mb-8">
<h3 class="text-2xl font-bold text-white mb-4">HTTP Request/Response Flow</h3>
<div class="bg-slate-800/50 border border-slate-700 rounded-lg p-6">
<div id="http-flow-diagram" class="w-full"></div>
</div>
</div>
<!-- HTTP Methods -->
<div class="mb-8">
<h3 class="text-2xl font-bold text-white mb-4">HTTP Methods</h3>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<div class="bg-slate-800/50 border border-slate-700 rounded-lg p-4">
<h4 class="text-lg font-semibold text-green-300 mb-2">GET</h4>
<p class="text-gray-300 text-sm mb-3">Retrieve data from server</p>
<div class="code-block text-xs">
GET /api/users HTTP/1.1
Host: example.com
</div>
</div>
<div class="bg-slate-800/50 border border-slate-700 rounded-lg p-4">
<h4 class="text-lg font-semibold text-blue-300 mb-2">POST</h4>
<p class="text-gray-300 text-sm mb-3">Send data to server</p>
<div class="code-block text-xs">
POST /api/users HTTP/1.1
Content-Type: application/json
{"name": "John"}
</div>
</div>
<div class="bg-slate-800/50 border border-slate-700 rounded-lg p-4">
<h4 class="text-lg font-semibold text-orange-300 mb-2">PUT</h4>
<p class="text-gray-300 text-sm mb-3">Update existing resource</p>
<div class="code-block text-xs">
PUT /api/users/123 HTTP/1.1
Content-Type: application/json
{"name": "Jane"}
</div>
</div>
<div class="bg-slate-800/50 border border-slate-700 rounded-lg p-4">
<h4 class="text-lg font-semibold text-red-300 mb-2">DELETE</h4>
<p class="text-gray-300 text-sm mb-3">Remove resource</p>
<div class="code-block text-xs">
DELETE /api/users/123 HTTP/1.1
</div>
</div>
</div>
</div>
<!-- HTTP Status Codes -->
<div class="mb-8">
<h3 class="text-2xl font-bold text-white mb-4">HTTP Status Codes</h3>
<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4">
<div class="bg-green-500/10 border border-green-500/20 rounded-lg p-4">
<h4 class="text-lg font-semibold text-green-300 mb-2">2xx Success</h4>
<ul class="text-gray-300 text-sm space-y-1">
<li>200 OK</li>
<li>201 Created</li>
<li>204 No Content</li>
</ul>
</div>
<div class="bg-blue-500/10 border border-blue-500/20 rounded-lg p-4">
<h4 class="text-lg font-semibold text-blue-300 mb-2">3xx Redirection</h4>
<ul class="text-gray-300 text-sm space-y-1">
<li>301 Moved Permanently</li>
<li>302 Found</li>
<li>304 Not Modified</li>
</ul>
</div>
<div class="bg-orange-500/10 border border-orange-500/20 rounded-lg p-4">
<h4 class="text-lg font-semibold text-orange-300 mb-2">4xx Client Error</h4>
<ul class="text-gray-300 text-sm space-y-1">
<li>400 Bad Request</li>
<li>401 Unauthorized</li>
<li>404 Not Found</li>
</ul>
</div>
<div class="bg-red-500/10 border border-red-500/20 rounded-lg p-4">
<h4 class="text-lg font-semibold text-red-300 mb-2">5xx Server Error</h4>
<ul class="text-gray-300 text-sm space-y-1">
<li>500 Internal Server Error</li>
<li>502 Bad Gateway</li>
<li>503 Service Unavailable</li>
</ul>
</div>
</div>
</div>
<!-- HTTP Headers -->
<div class="mb-8">
<h3 class="text-2xl font-bold text-white mb-4">Common HTTP Headers (Sorted by Popularity)</h3>
<div class="bg-slate-800/50 border border-slate-700 rounded-lg overflow-hidden">
<table class="w-full">
<thead class="bg-slate-700/50">
<tr>
<th class="px-6 py-4 text-left text-white font-semibold">Header</th>
<th class="px-6 py-4 text-left text-white font-semibold">Type</th>
<th class="px-6 py-4 text-left text-white font-semibold">Description</th>
<th class="px-6 py-4 text-left text-white font-semibold">Example</th>
</tr>
</thead>
<tbody>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Content-Type</td>
<td class="px-6 py-4 text-gray-300">Response</td>
<td class="px-6 py-4 text-gray-300">Media type of the resource</td>
<td class="px-6 py-4 text-gray-300">application/json</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">User-Agent</td>
<td class="px-6 py-4 text-gray-300">Request</td>
<td class="px-6 py-4 text-gray-300">Client application info</td>
<td class="px-6 py-4 text-gray-300">Mozilla/5.0...</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Host</td>
<td class="px-6 py-4 text-gray-300">Request</td>
<td class="px-6 py-4 text-gray-300">Target server hostname</td>
<td class="px-6 py-4 text-gray-300">example.com</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Accept</td>
<td class="px-6 py-4 text-gray-300">Request</td>
<td class="px-6 py-4 text-gray-300">Acceptable response types</td>
<td class="px-6 py-4 text-gray-300">application/json</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Cache-Control</td>
<td class="px-6 py-4 text-gray-300">Both</td>
<td class="px-6 py-4 text-gray-300">Caching directives</td>
<td class="px-6 py-4 text-gray-300">no-cache</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Content-Length</td>
<td class="px-6 py-4 text-gray-300">Response</td>
<td class="px-6 py-4 text-gray-300">Size of response body</td>
<td class="px-6 py-4 text-gray-300">1024</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Authorization</td>
<td class="px-6 py-4 text-gray-300">Request</td>
<td class="px-6 py-4 text-gray-300">Authentication credentials</td>
<td class="px-6 py-4 text-gray-300">Bearer token123</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Accept-Encoding</td>
<td class="px-6 py-4 text-gray-300">Request</td>
<td class="px-6 py-4 text-gray-300">Acceptable compression</td>
<td class="px-6 py-4 text-gray-300">gzip, deflate</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Content-Encoding</td>
<td class="px-6 py-4 text-gray-300">Response</td>
<td class="px-6 py-4 text-gray-300">Compression used</td>
<td class="px-6 py-4 text-gray-300">gzip</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Connection</td>
<td class="px-6 py-4 text-gray-300">Both</td>
<td class="px-6 py-4 text-gray-300">Connection control</td>
<td class="px-6 py-4 text-gray-300">keep-alive</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Set-Cookie</td>
<td class="px-6 py-4 text-gray-300">Response</td>
<td class="px-6 py-4 text-gray-300">Cookie to set</td>
<td class="px-6 py-4 text-gray-300">session=abc123</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Cookie</td>
<td class="px-6 py-4 text-gray-300">Request</td>
<td class="px-6 py-4 text-gray-300">Cookies to send</td>
<td class="px-6 py-4 text-gray-300">session=abc123</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Location</td>
<td class="px-6 py-4 text-gray-300">Response</td>
<td class="px-6 py-4 text-gray-300">Redirect URL</td>
<td class="px-6 py-4 text-gray-300">https://example.com/new</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Referer</td>
<td class="px-6 py-4 text-gray-300">Request</td>
<td class="px-6 py-4 text-gray-300">Previous page URL</td>
<td class="px-6 py-4 text-gray-300">https://google.com</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Accept-Language</td>
<td class="px-6 py-4 text-gray-300">Request</td>
<td class="px-6 py-4 text-gray-300">Preferred languages</td>
<td class="px-6 py-4 text-gray-300">en-US, en</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">X-Forwarded-For</td>
<td class="px-6 py-4 text-gray-300">Request</td>
<td class="px-6 py-4 text-gray-300">Client IP address</td>
<td class="px-6 py-4 text-gray-300">192.168.1.1</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">ETag</td>
<td class="px-6 py-4 text-gray-300">Response</td>
<td class="px-6 py-4 text-gray-300">Resource version identifier</td>
<td class="px-6 py-4 text-gray-300">"abc123"</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">If-None-Match</td>
<td class="px-6 py-4 text-gray-300">Request</td>
<td class="px-6 py-4 text-gray-300">Conditional request</td>
<td class="px-6 py-4 text-gray-300">"abc123"</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">Server</td>
<td class="px-6 py-4 text-gray-300">Response</td>
<td class="px-6 py-4 text-gray-300">Server software info</td>
<td class="px-6 py-4 text-gray-300">nginx/1.18.0</td>
</tr>
<tr class="border-t border-slate-700">
<td class="px-6 py-4 text-blue-300 font-medium">X-Requested-With</td>
<td class="px-6 py-4 text-gray-300">Request</td>
<td class="px-6 py-4 text-gray-300">AJAX request indicator</td>
<td class="px-6 py-4 text-gray-300">XMLHttpRequest</td>
</tr>
</tbody>
</table>
</div>
</div>
<!-- HTTP Versions Evolution -->
<div class="mb-8">
<h3 class="text-2xl font-bold text-white mb-4">HTTP Versions Evolution</h3>
<p class="text-gray-300 text-lg leading-relaxed mb-6">
HTTP has evolved through several versions, each bringing new features and improvements to web communication.
</p>
<!-- HTTP/0.9 -->
<div class="mb-8">
<h4 class="text-xl font-semibold text-orange-300 mb-4">HTTP/0.9 (1991) - The Original</h4>
<div class="bg-slate-800/50 border border-slate-700 rounded-lg p-6">
<div id="http-09-diagram" class="w-full"></div>
</div>
<div class="mt-4 grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-orange-500/10 border border-orange-500/20 rounded-lg p-4">
<h5 class="text-lg font-semibold text-orange-300 mb-2">Features</h5>
<ul class="text-gray-300 text-sm space-y-1">
<li>• Only GET method</li>
<li>• No headers</li>
<li>• HTML only responses</li>
<li>• Connection closes after response</li>
</ul>
</div>
<div class="bg-orange-500/10 border border-orange-500/20 rounded-lg p-4">
<h5 class="text-lg font-semibold text-orange-300 mb-2">Example</h5>
<div class="code-block text-xs">
<div class="text-orange-400">Request:</div>
<div class="text-gray-300">GET /index.html</div>
<div class="text-orange-400">Response:</div>
<div class="text-gray-300"><html>...</html></div>
</div>
</div>
</div>
</div>
<!-- HTTP/1.0 -->
<div class="mb-8">
<h4 class="text-xl font-semibold text-blue-300 mb-4">HTTP/1.0 (1996) - Headers & Status Codes</h4>
<div class="bg-slate-800/50 border border-slate-700 rounded-lg p-6">
<div id="http-10-diagram" class="w-full"></div>
</div>
<div class="mt-4 grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-blue-500/10 border border-blue-500/20 rounded-lg p-4">
<h5 class="text-lg font-semibold text-blue-300 mb-2">New Features</h5>
<ul class="text-gray-300 text-sm space-y-1">
<li>• HTTP headers introduced</li>
<li>• Status codes (200, 404, etc.)</li>
<li>• Content-Type support</li>
<li>• POST, HEAD methods</li>
</ul>
</div>
<div class="bg-blue-500/10 border border-blue-500/20 rounded-lg p-4">
<h5 class="text-lg font-semibold text-blue-300 mb-2">Example</h5>
<div class="code-block text-xs">
<div class="text-blue-400">Request:</div>
<div class="text-gray-300">GET /index.html HTTP/1.0</div>
<div class="text-gray-300">Host: example.com</div>
<div class="text-blue-400">Response:</div>
<div class="text-gray-300">HTTP/1.0 200 OK</div>
<div class="text-gray-300">Content-Type: text/html</div>
</div>
</div>
</div>
</div>
<!-- HTTP/1.1 -->
<div class="mb-8">
<h4 class="text-xl font-semibold text-green-300 mb-4">HTTP/1.1 (1997) - Persistent Connections</h4>
<div class="bg-slate-800/50 border border-slate-700 rounded-lg p-6">
<div id="http-11-diagram" class="w-full"></div>
</div>
<div class="mt-4 grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-green-500/10 border border-green-500/20 rounded-lg p-4">
<h5 class="text-lg font-semibold text-green-300 mb-2">Major Improvements</h5>
<ul class="text-gray-300 text-sm space-y-1">
<li>• Persistent connections</li>
<li>• Pipelining support</li>
<li>• Chunked transfer encoding</li>
<li>• Host header required</li>
<li>• PUT, DELETE, OPTIONS methods</li>
</ul>
</div>
<div class="bg-green-500/10 border border-green-500/20 rounded-lg p-4">
<h5 class="text-lg font-semibold text-green-300 mb-2">Example</h5>
<div class="code-block text-xs">
<div class="text-green-400">Multiple requests on same connection:</div>
<div class="text-gray-300">GET /page1.html HTTP/1.1</div>
<div class="text-gray-300">GET /page2.html HTTP/1.1</div>
<div class="text-gray-300">Connection: keep-alive</div>
</div>
</div>
</div>
</div>
<!-- HTTP/2 -->
<div class="mb-8">
<h4 class="text-xl font-semibold text-purple-300 mb-4">HTTP/2 (2015) - Multiplexing & Binary</h4>
<div class="bg-slate-800/50 border border-slate-700 rounded-lg p-6">
<div id="http-2-diagram" class="w-full"></div>
</div>
<div class="mt-4 grid grid-cols-1 md:grid-cols-2 gap-4">
<div class="bg-purple-500/10 border border-purple-500/20 rounded-lg p-4">
<h5 class="text-lg font-semibold text-purple-300 mb-2">Revolutionary Features</h5>
<ul class="text-gray-300 text-sm space-y-1">
<li>• Binary protocol (not text)</li>
<li>• Multiplexing (multiple streams)</li>
<li>• Server push capability</li>
<li>• Header compression (HPACK)</li>
<li>• Stream prioritization</li>
</ul>
</div>
<div class="bg-purple-500/10 border border-purple-500/20 rounded-lg p-4">
<h5 class="text-lg font-semibold text-purple-300 mb-2">Benefits</h5>
<ul class="text-gray-300 text-sm space-y-1">
<li>• Faster page loading</li>
<li>• Reduced latency</li>
<li>• Better resource utilization</li>
<li>• Backward compatible</li>
</ul>
</div>
</div>
</div>
</div>
<!-- HTTP vs HTTPS -->
<div class="mb-8">
<h3 class="text-2xl font-bold text-white mb-4">HTTP vs HTTPS</h3>
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
<div class="bg-slate-800/50 border border-slate-700 rounded-lg p-6">
<h4 class="text-xl font-semibold text-orange-300 mb-4">HTTP (Port 80)</h4>
<ul class="text-gray-300 space-y-2">
<li>• Unencrypted communication</li>
<li>• Faster performance</li>
<li>• No SSL/TLS overhead</li>
<li>• Vulnerable to attacks</li>
<li>• Data can be intercepted</li>
</ul>
</div>
<div class="bg-slate-800/50 border border-slate-700 rounded-lg p-6">
<h4 class="text-xl font-semibold text-green-300 mb-4">HTTPS (Port 443)</h4>
<ul class="text-gray-300 space-y-2">
<li>• Encrypted with SSL/TLS</li>
<li>• Secure data transmission</li>
<li>• Certificate validation</li>
<li>• Slightly slower due to encryption</li>
<li>• Required for modern web apps</li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<script>
document.addEventListener('DOMContentLoaded', function() {
const backBtn = document.getElementById('back-btn');
// Back button
backBtn.addEventListener('click', () => {
window.history.back();
});
// Initialize Mermaid
mermaid.initialize({
startOnLoad: false,
theme: 'dark',
themeVariables: {
primaryColor: '#3b82f6',
primaryTextColor: '#f8fafc',
primaryBorderColor: '#334155',
lineColor: '#64748b',
secondaryColor: '#1e293b',
tertiaryColor: '#0f172a',
background: '#0f172a',
mainBkg: '#1e293b',
secondBkg: '#334155'
}
});
// Render all HTTP diagrams
const httpFlowDiagram = `
sequenceDiagram
participant C as Client
participant S as Server
C->>S: HTTP Request
Note over C,S: GET /api/users HTTP/1.1<br/>Host: example.com
S->>S: Process Request
Note over S: Validate request<br/>Query database<br/>Prepare response
S->>C: HTTP Response
Note over C,S: HTTP/1.1 200 OK<br/>Content-Type: application/json<br/>JSON data response
Note over C,S: Connection may close<br/>(HTTP/1.0) or persist<br/>(HTTP/1.1+)
`;
const http09Diagram = `
sequenceDiagram
participant C as Client
participant S as Server
Note over C,S: HTTP/0.9 - Simple Request/Response
C->>S: GET /index.html
Note over C: Simple request<br/>No headers<br/>No version
S->>C: HTML Response
Note over S: Direct HTML response<br/>No status code<br/>No headers
Note over C,S: Connection closes immediately
`;
const http10Diagram = `
sequenceDiagram
participant C as Client
participant S as Server
Note over C,S: HTTP/1.0 - Headers & Status Codes
C->>S: GET /index.html HTTP/1.0
Note over C: Request with version<br/>Optional headers
S->>S: Process Request
Note over S: Check resource<br/>Prepare response
S->>C: HTTP/1.0 200 OK
Note over S: Status line<br/>Content-Type: text/html<br/>Content-Length: 1024
S->>C: HTML Content
Note over C,S: Connection closes after response
`;
const http11Diagram = `
sequenceDiagram
participant C as Client
participant S as Server
Note over C,S: HTTP/1.1 - Persistent Connections
C->>S: GET /page1.html HTTP/1.1
Note over C: Host header required<br/>Connection: keep-alive
S->>C: HTTP/1.1 200 OK
Note over S: Response with headers<br/>Connection: keep-alive
C->>S: GET /page2.html HTTP/1.1
Note over C: Reuse same connection<br/>Pipelining possible
S->>C: HTTP/1.1 200 OK
Note over S: Multiple requests<br/>on same connection
Note over C,S: Connection stays open<br/>for multiple requests
`;
const http2Diagram = `
sequenceDiagram
participant C as Client
participant S as Server
Note over C,S: HTTP/2 - Binary Multiplexing
C->>S: Connection Setup
Note over C: TLS handshake<br/>HTTP/2 negotiation
C->>S: GET /page1.html (Stream 1)
C->>S: GET /style.css (Stream 2)
C->>S: GET /script.js (Stream 3)
S->>C: 200 OK + HTML (Stream 1)
S->>C: 200 OK + CSS (Stream 2)
S->>C: 200 OK + JS (Stream 3)
Note over C,S: Multiple streams<br/>in parallel<br/>Binary frames
S->>C: Server Push
Note over S: Push resources<br/>before requested
`;
// Render all diagrams
Promise.all([
mermaid.render('http-flow-svg', httpFlowDiagram),
mermaid.render('http-09-svg', http09Diagram),
mermaid.render('http-10-svg', http10Diagram),
mermaid.render('http-11-svg', http11Diagram),
mermaid.render('http-2-svg', http2Diagram)
]).then(([flow, http09, http10, http11, http2]) => {
document.getElementById('http-flow-diagram').innerHTML = flow.svg;
document.getElementById('http-09-diagram').innerHTML = http09.svg;
document.getElementById('http-10-diagram').innerHTML = http10.svg;
document.getElementById('http-11-diagram').innerHTML = http11.svg;
document.getElementById('http-2-diagram').innerHTML = http2.svg;
});
});
</script>
</body>
</html>