-
-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathhttp-status.html
More file actions
1624 lines (1510 loc) · 53 KB
/
http-status.html
File metadata and controls
1624 lines (1510 loc) · 53 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
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!doctype html>
<html lang="zh-CN">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>HTTP 状态码查询 - 完整参考手册 - WebUtils</title>
<!-- SEO Meta Tags -->
<meta name="description" content="HTTP 状态码查询 - 完整参考手册 - WebUtils" />
<meta name="keywords" content="http-status,dev,tools,webutils" />
<meta name="author" content="WebUtils" />
<meta name="robots" content="index, follow" />
<link rel="canonical" href="https://tools.realtime-ai.chat/tools/dev/http-status.html" />
<!-- Open Graph -->
<meta property="og:title" content="HTTP 状态码查询 - 完整参考手册 - WebUtils" />
<meta property="og:description" content="HTTP 状态码查询 - 完整参考手册 - WebUtils" />
<meta property="og:type" content="website" />
<meta property="og:url" content="https://tools.realtime-ai.chat/tools/dev/http-status.html" />
<meta property="og:site_name" content="WebUtils" />
<meta property="og:locale" content="zh_CN" />
<meta property="og:image" content="https://tools.realtime-ai.chat/social-preview.png" />
<meta property="og:image:width" content="1280" />
<meta property="og:image:height" content="640" />
<meta property="og:image:type" content="image/png" />
<!-- Twitter Card -->
<meta name="twitter:card" content="summary" />
<meta name="twitter:title" content="HTTP 状态码查询 - 完整参考手册 - WebUtils" />
<meta name="twitter:description" content="HTTP 状态码查询 - 完整参考手册 - WebUtils" />
<meta name="twitter:image" content="https://tools.realtime-ai.chat/social-preview.png" />
<meta
name="description"
content="HTTP状态码完整参考,包含1xx-5xx所有状态码的详细说明、使用场景和示例代码"
/>
<meta name="keywords" content="HTTP状态码,HTTP Status Code,200,404,500,301,302,REST API" />
<style>
:root {
--bg-deep: #0a0a0f;
--bg-surface: #12121a;
--bg-card: #1a1a24;
--bg-input: #0e0e14;
--text-primary: #e8e8ed;
--text-secondary: #8888a0;
--text-muted: #55556a;
--border-subtle: #2a2a3a;
--border-strong: #3a3a4a;
--accent-cyan: #00f5d4;
--accent-magenta: #f72585;
--accent-green: #10b981;
--accent-red: #f43f5e;
--accent-yellow: #fbbf24;
--accent-blue: #4cc9f0;
--accent-purple: #7b2cbf;
--radius-sm: 4px;
--radius-md: 8px;
--radius-lg: 12px;
--font-sans:
"Space Grotesk", -apple-system, blinkmacsystemfont, "Segoe UI", roboto, sans-serif;
--font-mono: "JetBrains Mono", "Courier New", monospace;
--shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}
[data-theme="light"] {
--bg-deep: #fafafa;
--bg-surface: #fff;
--bg-card: #fff;
--bg-input: #f5f5f5;
--text-primary: #1a1a1a;
--text-secondary: #666;
--text-muted: #999;
--border-subtle: #e5e5e5;
--border-strong: #d5d5d5;
--accent-cyan: #00d4b8;
--accent-magenta: #e63975;
--shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}
:root {
--bg-primary: #1a1a2e;
--bg-secondary: #16213e;
--bg-tertiary: #0f3460;
--color-text-primary: #fff;
--color-text-secondary: #a0a0a0;
--accent: #00d9ff;
--accent-hover: #00b8d9;
--border: #2a2a4a;
--success: #00c853;
--warning: #ffc107;
--error: #ff5252;
--info: #2196f3;
}
[data-theme="light"] {
--bg-primary: #f5f5f5;
--bg-secondary: #fff;
--bg-tertiary: #e8e8e8;
--color-text-primary: #1a1a2e;
--color-text-secondary: #666;
--border: #ddd;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
body {
font-family: var(--font-sans);
background: var(--bg-deep);
color: var(--color-text-primary);
min-height: 100vh;
padding: 20px;
transition: all 0.3s ease;
}
.container {
max-width: 1000px;
margin: 0 auto;
}
.header {
text-align: center;
margin-bottom: 30px;
position: relative;
}
.header h1 {
font-size: 2rem;
margin-bottom: 10px;
background: linear-gradient(135deg, var(--accent-cyan), #a855f7);
-webkit-background-clip: text;
-webkit-text-fill-color: transparent;
background-clip: text;
}
.header p {
color: var(--color-text-secondary);
}
.back-link {
position: absolute;
left: 0;
top: 50%;
transform: translateY(-50%);
color: var(--accent-cyan);
text-decoration: none;
display: flex;
align-items: center;
gap: 5px;
font-size: 14px;
opacity: 0.8;
transition: opacity 0.2s;
}
.back-link:hover {
opacity: 1;
}
.theme-toggle {
position: absolute;
right: 0;
top: 50%;
transform: translateY(-50%);
background: var(--bg-tertiary);
border: 1px solid var(--border-subtle);
color: var(--color-text-primary);
padding: 8px 12px;
border-radius: 8px;
cursor: pointer;
font-size: 18px;
transition: all 0.3s ease;
}
.theme-toggle:hover {
border-color: var(--accent-cyan);
}
/* Search */
.search-section {
margin-bottom: 24px;
}
.search-box {
display: flex;
gap: 12px;
}
.search-input {
flex: 1;
padding: 14px 20px;
background: var(--bg-secondary);
border: 1px solid var(--border-subtle);
border-radius: 12px;
color: var(--color-text-primary);
font-size: 16px;
transition: all 0.3s ease;
}
.search-input:focus {
outline: none;
border-color: var(--accent-cyan);
box-shadow: 0 0 0 3px rgba(0, 217, 255, 0.1);
}
.search-input::placeholder {
color: var(--color-text-secondary);
}
/* Category Tabs */
.category-tabs {
display: flex;
gap: 8px;
margin-bottom: 24px;
flex-wrap: wrap;
}
.category-tab {
padding: 10px 20px;
background: var(--bg-secondary);
border: 1px solid var(--border-subtle);
border-radius: 25px;
color: var(--color-text-secondary);
font-size: 14px;
cursor: pointer;
transition: all 0.3s ease;
display: flex;
align-items: center;
gap: 8px;
}
.category-tab:hover {
border-color: var(--accent-cyan);
color: var(--color-text-primary);
}
.category-tab.active {
background: var(--accent-cyan);
border-color: var(--accent-cyan);
color: white;
}
.category-tab .count {
background: rgba(255, 255, 255, 0.2);
padding: 2px 8px;
border-radius: 10px;
font-size: 12px;
}
.category-tab.active .count {
background: rgba(0, 0, 0, 0.2);
}
/* Status Color Indicators */
.status-1xx {
--status-color: #64b5f6;
}
.status-2xx {
--status-color: #81c784;
}
.status-3xx {
--status-color: #ffb74d;
}
.status-4xx {
--status-color: #e57373;
}
.status-5xx {
--status-color: #ba68c8;
}
/* Status Cards */
.status-grid {
display: grid;
gap: 16px;
}
.status-card {
background: var(--bg-secondary);
border: 1px solid var(--border-subtle);
border-radius: 12px;
overflow: hidden;
transition: all 0.3s ease;
cursor: pointer;
}
.status-card:hover {
border-color: var(--accent-cyan);
transform: translateY(-2px);
box-shadow: 0 8px 25px rgba(0, 0, 0, 0.2);
}
.status-card-header {
display: flex;
align-items: center;
padding: 16px 20px;
gap: 16px;
border-left: 4px solid var(--status-color);
}
.status-code {
font-family: Monaco, Menlo, monospace;
font-size: 1.5rem;
font-weight: bold;
color: var(--status-color);
min-width: 60px;
}
.status-info {
flex: 1;
}
.status-name {
font-size: 1rem;
font-weight: 600;
margin-bottom: 4px;
}
.status-brief {
font-size: 13px;
color: var(--color-text-secondary);
}
.status-category-badge {
padding: 4px 12px;
border-radius: 15px;
font-size: 11px;
font-weight: 500;
background: var(--status-color);
color: white;
opacity: 0.9;
}
.expand-icon {
color: var(--color-text-secondary);
transition: transform 0.3s ease;
}
.status-card.expanded .expand-icon {
transform: rotate(180deg);
}
.status-card-body {
display: none;
padding: 0 20px 20px;
border-top: 1px solid var(--border-subtle);
}
.status-card.expanded .status-card-body {
display: block;
}
.detail-section {
margin-top: 16px;
}
.detail-section h4 {
font-size: 13px;
color: var(--accent-cyan);
margin-bottom: 8px;
text-transform: uppercase;
letter-spacing: 0.5px;
}
.detail-section p {
color: var(--color-text-secondary);
font-size: 14px;
line-height: 1.7;
}
.code-block {
background: var(--bg-tertiary);
border-radius: 8px;
padding: 12px 16px;
font-family: Monaco, Menlo, monospace;
font-size: 13px;
overflow-x: auto;
margin-top: 8px;
}
.code-block .comment {
color: var(--color-text-secondary);
}
.code-block .keyword {
color: #f78c6c;
}
.code-block .string {
color: #c3e88d;
}
.code-block .number {
color: #f78c6c;
}
/* Tags */
.tags {
display: flex;
flex-wrap: wrap;
gap: 8px;
margin-top: 8px;
}
.tag {
padding: 4px 10px;
background: var(--bg-tertiary);
border-radius: 15px;
font-size: 12px;
color: var(--color-text-secondary);
}
/* Quick Reference */
.quick-ref {
background: var(--bg-secondary);
border: 1px solid var(--border-subtle);
border-radius: 12px;
padding: 20px;
margin-bottom: 24px;
}
.quick-ref h3 {
font-size: 1rem;
margin-bottom: 16px;
display: flex;
align-items: center;
gap: 8px;
}
.quick-ref-grid {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
gap: 12px;
}
.quick-ref-item {
display: flex;
align-items: center;
gap: 10px;
padding: 10px 14px;
background: var(--bg-tertiary);
border-radius: 8px;
cursor: pointer;
transition: all 0.3s ease;
}
.quick-ref-item:hover {
background: var(--accent-cyan);
color: white;
}
.quick-ref-item .code {
font-family: var(--font-mono);
font-weight: bold;
font-size: 14px;
}
.quick-ref-item .name {
font-size: 12px;
opacity: 0.8;
}
/* No Results */
.no-results {
text-align: center;
padding: 60px 20px;
color: var(--color-text-secondary);
}
.no-results svg {
width: 64px;
height: 64px;
margin-bottom: 16px;
opacity: 0.5;
}
@media (max-width: 600px) {
.header h1 {
font-size: 1.5rem;
}
.back-link span {
display: none;
}
.category-tabs {
justify-content: center;
}
.status-card-header {
flex-wrap: wrap;
}
.quick-ref-grid {
grid-template-columns: 1fr 1fr;
}
}
.breadcrumb {
background: rgba(255, 255, 255, 0.95);
padding: 8px 15px;
border-radius: 20px;
box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
font-size: 0.85rem;
}
.breadcrumb a {
color: #667eea;
text-decoration: none;
}
.breadcrumb a:hover {
text-decoration: underline;
}
.breadcrumb span {
color: #999;
margin: 0 5px;
}
</style>
<!-- Google Fonts -->
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap"
rel="stylesheet"
/>
</head>
<body>
<nav class="breadcrumb">
<a href="../../index.html">首页</a>
<span>›</span>
HTTP 状态码参考
</nav>
<div class="container">
<div class="header">
<h1>📡 HTTP 状态码查询</h1>
<p>完整的HTTP状态码参考手册</p>
<button class="theme-toggle" onclick="toggleTheme()">🌓</button>
</div>
<div class="search-section">
<div class="search-box">
<input
type="text"
class="search-input"
id="searchInput"
placeholder="搜索状态码或描述,如 404、Not Found、重定向..."
oninput="filterCodes()"
/>
</div>
</div>
<div class="quick-ref">
<h3>
<svg
width="20"
height="20"
viewBox="0 0 24 24"
fill="none"
stroke="currentColor"
stroke-width="2"
>
<polygon points="13 2 3 14 12 14 11 22 21 10 12 10 13 2" />
</svg>
常用状态码
</h3>
<div class="quick-ref-grid">
<div class="quick-ref-item" onclick="jumpToCode(200)">
<span class="code" style="color: #81c784">200</span>
<span class="name">OK</span>
</div>
<div class="quick-ref-item" onclick="jumpToCode(201)">
<span class="code" style="color: #81c784">201</span>
<span class="name">Created</span>
</div>
<div class="quick-ref-item" onclick="jumpToCode(301)">
<span class="code" style="color: #ffb74d">301</span>
<span class="name">Moved</span>
</div>
<div class="quick-ref-item" onclick="jumpToCode(302)">
<span class="code" style="color: #ffb74d">302</span>
<span class="name">Found</span>
</div>
<div class="quick-ref-item" onclick="jumpToCode(400)">
<span class="code" style="color: #e57373">400</span>
<span class="name">Bad Request</span>
</div>
<div class="quick-ref-item" onclick="jumpToCode(401)">
<span class="code" style="color: #e57373">401</span>
<span class="name">Unauthorized</span>
</div>
<div class="quick-ref-item" onclick="jumpToCode(403)">
<span class="code" style="color: #e57373">403</span>
<span class="name">Forbidden</span>
</div>
<div class="quick-ref-item" onclick="jumpToCode(404)">
<span class="code" style="color: #e57373">404</span>
<span class="name">Not Found</span>
</div>
<div class="quick-ref-item" onclick="jumpToCode(500)">
<span class="code" style="color: #ba68c8">500</span>
<span class="name">Server Error</span>
</div>
<div class="quick-ref-item" onclick="jumpToCode(502)">
<span class="code" style="color: #ba68c8">502</span>
<span class="name">Bad Gateway</span>
</div>
</div>
</div>
<div class="category-tabs" id="categoryTabs">
<button class="category-tab active" data-category="all" onclick="filterByCategory('all')">
全部
<span class="count" id="countAll">0</span>
</button>
<button class="category-tab" data-category="1xx" onclick="filterByCategory('1xx')">
1xx 信息
<span class="count" id="count1xx">0</span>
</button>
<button class="category-tab" data-category="2xx" onclick="filterByCategory('2xx')">
2xx 成功
<span class="count" id="count2xx">0</span>
</button>
<button class="category-tab" data-category="3xx" onclick="filterByCategory('3xx')">
3xx 重定向
<span class="count" id="count3xx">0</span>
</button>
<button class="category-tab" data-category="4xx" onclick="filterByCategory('4xx')">
4xx 客户端错误
<span class="count" id="count4xx">0</span>
</button>
<button class="category-tab" data-category="5xx" onclick="filterByCategory('5xx')">
5xx 服务器错误
<span class="count" id="count5xx">0</span>
</button>
</div>
<div class="status-grid" id="statusGrid"></div>
<div class="no-results" id="noResults" style="display: none">
<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.5">
<circle cx="11" cy="11" r="8" />
<path d="m21 21-4.35-4.35" />
</svg>
<p>没有找到匹配的状态码</p>
</div>
</div>
<script>
// HTTP Status Codes Database
const statusCodes = [
// 1xx Informational
{
code: 100,
name: "Continue",
nameCn: "继续",
brief: "服务器已收到请求头,客户端应继续发送请求体",
description:
"表示目前为止一切正常,客户端应该继续请求,如果已完成请求则忽略。这通常用于客户端发送带有Expect: 100-continue头的POST请求。",
usage: "用于分块上传大文件前的预检",
tags: ["上传", "预检"],
example: `// 发送带有 Expect 头的请求
fetch('/upload', {
method: 'POST',
headers: {
'Expect': '100-continue',
'Content-Type': 'application/octet-stream'
},
body: largeFile
});`
},
{
code: 101,
name: "Switching Protocols",
nameCn: "切换协议",
brief: "服务器正在根据客户端的请求切换协议",
description:
"服务器理解并同意客户端的协议升级请求。最常见的用途是将HTTP连接升级为WebSocket连接。",
usage: "WebSocket握手、HTTP/2升级",
tags: ["WebSocket", "协议升级"],
example: `// WebSocket 握手
const ws = new WebSocket('wss://example.com/socket');
// 服务器响应 101 Switching Protocols
// Upgrade: websocket
// Connection: Upgrade`
},
{
code: 102,
name: "Processing",
nameCn: "处理中",
brief: "服务器正在处理请求,但尚未完成(WebDAV)",
description:
"此代码表示服务器已收到并正在处理请求,但尚无响应可用。这可以防止客户端在等待响应时超时。",
usage: "WebDAV长时间操作",
tags: ["WebDAV", "长操作"]
},
{
code: 103,
name: "Early Hints",
nameCn: "预提示",
brief: "用于在最终响应之前返回一些响应头",
description:
"允许服务器在准备响应时发送一些响应头,让浏览器提前开始预加载资源,提升页面加载速度。",
usage: "预加载关键资源",
tags: ["性能优化", "Link预加载"],
example: `// 服务器响应
HTTP/1.1 103 Early Hints
Link: </style.css>; rel=preload; as=style
Link: </script.js>; rel=preload; as=script`
},
// 2xx Success
{
code: 200,
name: "OK",
nameCn: "成功",
brief: "请求成功,返回了请求的数据",
description:
"标准的成功响应。对于GET请求,响应将包含请求的资源。对于POST请求,响应将包含描述或包含操作结果的实体。",
usage: "所有成功的GET、POST等请求",
tags: ["GET", "POST", "常用"],
example: `// API 成功响应
{
"status": 200,
"data": {
"id": 1,
"name": "示例数据"
}
}`
},
{
code: 201,
name: "Created",
nameCn: "已创建",
brief: "请求成功,服务器创建了新资源",
description:
"请求已成功且服务器创建了一个新资源。通常用于POST或PUT请求后的响应。响应的Location头应该包含新创建资源的URI。",
usage: "POST创建新资源成功",
tags: ["POST", "REST API", "常用"],
example: `// 创建用户成功
HTTP/1.1 201 Created
Location: /api/users/123
{
"id": 123,
"name": "新用户",
"created_at": "2024-01-01T00:00:00Z"
}`
},
{
code: 202,
name: "Accepted",
nameCn: "已接受",
brief: "请求已接受处理,但处理尚未完成",
description:
"请求已被接受进行处理,但处理尚未完成。请求可能会也可能不会最终执行。适用于异步任务或批处理操作。",
usage: "异步任务、队列处理",
tags: ["异步", "队列"],
example: `// 异步任务接受
{
"status": "accepted",
"task_id": "abc123",
"check_status_url": "/api/tasks/abc123"
}`
},
{
code: 203,
name: "Non-Authoritative Information",
nameCn: "非权威信息",
brief: "返回的元数据可能来自本地或第三方副本",
description:
"服务器成功处理了请求,但返回的信息可能来自另一源。通常用于代理服务器或镜像站点。",
usage: "代理服务器、CDN缓存",
tags: ["代理", "缓存"]
},
{
code: 204,
name: "No Content",
nameCn: "无内容",
brief: "请求成功,但没有返回内容",
description:
"服务器成功处理了请求,但不需要返回任何实体内容。常用于DELETE请求成功后,或更新操作不需要返回更新后的数据时。",
usage: "DELETE成功、更新操作",
tags: ["DELETE", "PUT", "常用"],
example: `// DELETE 请求成功
DELETE /api/users/123 HTTP/1.1
HTTP/1.1 204 No Content`
},
{
code: 205,
name: "Reset Content",
nameCn: "重置内容",
brief: "请求成功,客户端应重置文档视图",
description: "服务器成功处理了请求,告诉客户端重置文档视图,如清空表单以便再次输入。",
usage: "表单提交后重置",
tags: ["表单"]
},
{
code: 206,
name: "Partial Content",
nameCn: "部分内容",
brief: "服务器成功处理了部分GET请求",
description:
"服务器已成功处理了部分GET请求。用于支持断点续传的资源下载,客户端通过Range头指定请求的字节范围。",
usage: "断点续传、视频流媒体",
tags: ["下载", "流媒体", "Range"],
example: `// 请求部分内容
GET /video.mp4 HTTP/1.1
Range: bytes=0-1023
HTTP/1.1 206 Partial Content
Content-Range: bytes 0-1023/10240
Content-Length: 1024`
},
{
code: 207,
name: "Multi-Status",
nameCn: "多状态",
brief: "响应体包含多个状态码(WebDAV)",
description: "响应体是一个XML文档,包含多个独立操作的状态码。用于WebDAV批量操作。",
usage: "WebDAV批量操作",
tags: ["WebDAV", "批量"]
},
{
code: 208,
name: "Already Reported",
nameCn: "已报告",
brief: "成员已在之前的响应中列出(WebDAV)",
description: "用于WebDAV绑定的成员,避免重复枚举。",
usage: "WebDAV",
tags: ["WebDAV"]
},
{
code: 226,
name: "IM Used",
nameCn: "使用了IM",
brief: "服务器已完成对资源的GET请求,响应是对当前实例应用的一个或多个实例操作的结果表示",
description:
"服务器已经完成了对资源的请求,并且响应是应用于当前实例的一个或多个实例操作的结果。",
usage: "Delta编码",
tags: ["Delta"]
},
// 3xx Redirection
{
code: 300,
name: "Multiple Choices",
nameCn: "多种选择",
brief: "请求的资源有多种表示形式",
description: "表示请求的资源有多种可选择的回应。用户或用户代理可以选择其中一个。",
usage: "内容协商",
tags: ["协商"]
},
{
code: 301,
name: "Moved Permanently",
nameCn: "永久移动",
brief: "资源已永久移动到新位置",
description:
"请求的资源已被永久移动到新URI。以后所有请求都应使用新URI。搜索引擎会更新链接。",
usage: "网站迁移、URL规范化",
tags: ["SEO", "重定向", "常用"],
example: `// 永久重定向
HTTP/1.1 301 Moved Permanently
Location: https://new-domain.com/page
// Nginx 配置
server {
return 301 https://new-domain.com$request_uri;
}`
},
{
code: 302,
name: "Found",
nameCn: "临时移动",
brief: "资源临时移动到其他位置",
description:
"请求的资源临时位于另一个URI。由于重定向可能会不时更改,客户端应继续使用原URI。",
usage: "临时重定向、登录跳转",
tags: ["重定向", "常用"],
example: `// 临时重定向
HTTP/1.1 302 Found
Location: /login?redirect=/dashboard`
},
{
code: 303,
name: "See Other",
nameCn: "查看其他",
brief: "应使用GET请求另一个URI来获取资源",
description:
"服务器发送此响应,指示客户端应使用GET请求在另一个URI获取请求的资源。常用于POST处理后重定向到结果页面。",
usage: "POST后重定向(PRG模式)",
tags: ["PRG", "POST"],
example: `// POST-Redirect-Get 模式
POST /order HTTP/1.1
// 处理订单...
HTTP/1.1 303 See Other
Location: /order/123/confirmation`
},
{
code: 304,
name: "Not Modified",
nameCn: "未修改",
brief: "资源未修改,可使用缓存版本",
description:
"表示资源自上次请求后未被修改,客户端可以使用缓存的版本。这是条件请求的结果。",
usage: "浏览器缓存、CDN缓存验证",
tags: ["缓存", "ETag", "常用"],
example: `// 条件请求
GET /style.css HTTP/1.1
If-None-Match: "abc123"
HTTP/1.1 304 Not Modified
ETag: "abc123"`
},
{
code: 305,
name: "Use Proxy",
nameCn: "使用代理",
brief: "请求必须通过代理访问(已废弃)",
description: "被请求的资源必须通过指定的代理才能被访问。由于安全原因,此状态码已被废弃。",
usage: "已废弃",
tags: ["已废弃"]
},
{
code: 307,
name: "Temporary Redirect",
nameCn: "临时重定向",
brief: "临时重定向,保持请求方法不变",
description: "与302类似,但明确要求客户端保持请求方法不变。POST请求重定向后仍使用POST。",
usage: "HTTPS升级、API版本迁移",
tags: ["重定向", "HTTPS"],
example: `// HTTP 到 HTTPS 重定向
HTTP/1.1 307 Temporary Redirect
Location: https://example.com/api/users`
},
{
code: 308,
name: "Permanent Redirect",
nameCn: "永久重定向",
brief: "永久重定向,保持请求方法不变",
description: "与301类似,但明确要求客户端保持请求方法不变。这是301的严格版本。",
usage: "永久迁移,保持POST方法",
tags: ["重定向", "SEO"]
},
// 4xx Client Errors
{
code: 400,
name: "Bad Request",
nameCn: "错误请求",
brief: "服务器无法理解请求的语法",
description:
"服务器无法处理请求,因为客户端错误(如语法错误、无效的请求消息框架或欺骗性请求路由)。",
usage: "参数验证失败、格式错误",
tags: ["验证", "常用"],
example: `// 验证错误响应
{
"error": "Bad Request",
"message": "Invalid email format",
"field": "email"
}`
},
{
code: 401,
name: "Unauthorized",
nameCn: "未授权",
brief: "请求需要身份验证",
description:
"请求需要用户身份验证。响应必须包含WWW-Authenticate头字段,包含适用于请求资源的质询信息。",
usage: "未登录、Token过期",
tags: ["认证", "常用"],
example: `// 未认证响应
HTTP/1.1 401 Unauthorized
WWW-Authenticate: Bearer realm="api"
{
"error": "Unauthorized",
"message": "Invalid or expired token"
}`
},
{
code: 402,
name: "Payment Required",
nameCn: "需要付款",
brief: "保留供将来使用,最初用于数字支付系统",
description:
"此代码保留供将来使用。最初的意图是用于数字现金或微支付系统,但目前未被广泛使用。",
usage: "付费功能、订阅服务",
tags: ["支付"]
},
{
code: 403,
name: "Forbidden",
nameCn: "禁止",
brief: "服务器拒绝执行请求",
description: "服务器理解请求但拒绝授权。与401不同,重新进行身份验证不会有任何帮助。",
usage: "权限不足、IP被封",
tags: ["权限", "常用"],
example: `// 权限不足响应