HTTP Status Code

本文全面解析HTTP状态码,包括1xx临时响应、2xx成功、4xx请求错误、5xx服务器错误等类别,涵盖各代码具体含义,如200成功、404未找到、503服务不可用等。

常见的状态码

HTTP: Status 200 – 服务器成功返回网页
HTTP: Status 404 – 请求的网页不存在
HTTP: Status 503 – 服务不可用
  • 1xx

说明:

HTTP: Status 1xx  (临时响应)
->表示临时响应并需要请求者继续执行操作的状态代码。

详细代码及说明:
HTTP: Status 100 (继续)
-> 请求者应当继续提出请求。 服务器返回此代码表示已收到请求的第一部分,正在等待其余部分。
HTTP: Status 101 (切换协议)
-> 请求者已要求服务器切换协议,服务器已确认并准备切换。
  • 2xx

说明:
HTTP Status 2xx  (成功)
->表示成功处理了请求的状态代码;

详细代码及说明:

HTTP Status 200 (成功)
-> 服务器已成功处理了请求。 通常,这表示服务器提供了请求的网页。
HTTP Status 201 (已创建)
-> 请求成功并且服务器创建了新的资源。
HTTP Status 202 (已接受)
-> 服务器已接受请求,但尚未处理。
HTTP Status 203 (非授权信息)
-> 服务器已成功处理了请求,但返回的信息可能来自另一来源。
HTTP Status 204 (无内容)
-> 服务器成功处理了请求,但没有返回任何内容。
HTTP Status 205 (重置内容)
-> 服务器成功处理了请求,但没有返回任何内容。
HTTP Status 206 (部分内容)
-> 服务器成功处理了部分 GET 请求。
  • 4xx

说明:

HTTP Status 4xx (请求错误)
->这些状态代码表示请求可能出错,妨碍了服务器的处理。

详细代码说明:
HTTP Status 400 (错误请求) 
->服务器不理解请求的语法。
HTTP Status 401 (未授权) 
->请求要求身份验证。 对于需要登录的网页,服务器可能返回此响应。
HTTP Status 403 (禁止)
-> 服务器拒绝请求。
HTTP Status 404 (未找到) 
->服务器找不到请求的网页。
HTTP Status 405 (方法禁用) 
->禁用请求中指定的方法。
HTTP Status 406 (不接受) 
->无法使用请求的内容特性响应请求的网页。
HTTP Status 407 (需要代理授权) 
->此状态代码与 401(未授权)类似,但指定请求者应当授权使用代理。
HTTP Status 408 (请求超时) 
->服务器等候请求时发生超时。
HTTP Status 409 (冲突) 
->服务器在完成请求时发生冲突。 服务器必须在响应中包含有关冲突的信息。
HTTP Status 410 (已删除)
-> 如果请求的资源已永久删除,服务器就会返回此响应。
HTTP Status 411 (需要有效长度) 
->服务器不接受不含有效内容长度标头字段的请求。
HTTP Status 412 (未满足前提条件) 
->服务器未满足请求者在请求中设置的其中一个前提条件。
HTTP Status 413 (请求实体过大) 
->服务器无法处理请求,因为请求实体过大,超出服务器的处理能力。
HTTP Status 414 (请求的 URI 过长) 请求的 URI(通常为网址)过长,服务器无法处理。
HTTP Status 415 (不支持的媒体类型) 
->请求的格式不受请求页面的支持。
HTTP Status 416 (请求范围不符合要求) 
->如果页面无法提供请求的范围,则服务器会返回此状态代码。
HTTP Status 417 (未满足期望值) 
->服务器未满足”期望”请求标头字段的要求。
  • 5xx

说明
HTTP Status 5xx (服务器错误)
->这些状态代码表示服务器在尝试处理请求时发生内部错误。 这些错误可能是服务器本身的错误,而不是请求出错。

代码详细及说明:
HTTP Status 500 (服务器内部错误) 
->服务器遇到错误,无法完成请求。
HTTP Status 501 (尚未实施) 
->服务器不具备完成请求的功能。 例如,服务器无法识别请求方法时可能会返回此代码。
HTTP Status 502 (错误网关) 
->服务器作为网关或代理,从上游服务器收到无效响应。
HTTP Status 503 (服务不可用)
-> 服务器目前无法使用(由于超载或停机维护)。 通常,这只是暂时状态。
HTTP Status 504 (网关超时) 
->服务器作为网关或代理,但是没有及时从上游服务器收到请求。
HTTP Status 505 (HTTP 版本不受支持)
-> 服务器不支持请求中所用的 HTTP 协议版本。
wkhtmltopdf ce.html output.pdfLoading page (1/2) Warning: Blocked access to file /usr/share/remarkable/media/highlightjs.default.min.css Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/未识别/E0AB34963F1FPNFW0706_1740045746604_4281494272.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/未识别/E05E36080G1FPQ3N0102_1750901910075_2823700716.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/未识别/E0AB34963F1FPNFW0569_1739880983686_3304443251.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/未识别/E04836080G1FPPQC1144_1750579259054_2452813871.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/未识别/E0A734963F1FPNFK1370_1740275295569_3665225174.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E0A734963F1FPNFK0492_1740185733688_543816353.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E0A734963F1FPNFK1096_1740616516418_246766233.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E0AC34963F1FPNGZ0991_1737162383220_3022446520.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E0A634635F1FPNF90897_1750206882406_2254228376.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E04236080G1FPPNK2061_1750929726477_1278595401.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E06936080G1FPQ7W0698_1750666432575_3361535253.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/少分/E05L36080G1FPQ5A1962_1750993358502_56213211.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/分类错误/E05T36080G1FPPWB0047_1749868927317_2915249529.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/分类错误/E03D36080G1FPPEW0171_1749952830839_4237369372.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/分类错误/E0AB34963F1FPNFW0654_1740284158643_2500741493.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/多分/E0AC34963F1FPNGZ0145_1740403419675_2969073058.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/多分/E0AC34963F1FPNGZ0416_1737166251826_3536604772.jpg Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/多分/E0A734963F1FPNFK1053_1740042571110_128121444.jpg Warning: Blocked access to file /usr/share/remarkable/media/highlight.min.js Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/多分/E0A534963F1FPNFJ0044_1739835514791_1026479677.jpg Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/多分/E0A734963F1FPNFK1245_1740707000665_2537930183.jpg Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Warning: Blocked access to file /home/chenchengzhang/PycharmProjects/PythonProject/yolo/new_7_28_FP/多分/E03636080G1FPPE10087_1750032382444_4154186674.jpg Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Error: Failed to load about:blank, with network status code 301 and http status code 0 - Protocol "about" is unknown Printing pages (2/2)
07-31
在使用 `wkhtmltopdf` 将 HTML 转换为 PDF 时,如果遇到资源访问被阻止和加载 `about:blank` 失败的问题,通常是由以下两个原因导致的: 1. **本地文件访问被限制**:从较新版本的 `wkhtmltopdf` 开始,默认情况下禁用了对本地文件的访问权限,这会导致 HTML 文件中引用的本地图片、CSS 或 JS 文件无法正常加载,从而出现类似 `Blocked access to file` 的警告信息[^2]。 解决方法是通过添加 `--enable-local-file-access` 参数来启用本地文件访问权限。例如,在命令行中使用以下命令进行转换: ```bash wkhtmltopdf --enable-local-file-access index.html output.pdf ``` 如果是通过 Python 的 `pdfkit` 库调用 `wkhtmltopdf`,则可以在选项中添加 `'enable-local-file-access': None`,如下所示: ```python import pdfkit options = { 'enable-local-file-access': None } pdfkit.from_file('index.html', 'output.pdf', options=options) ``` 2. **加载 `about:blank` 页面失败**:`Failed to load about:blank` 错误通常出现在 HTML 文件中引用了 `about:blank` 或者某些框架页面加载失败时。这个错误的原因是 `wkhtmltopdf` 不支持某些协议(如 `about:`),并且在某些版本中会尝试加载空白页面导致错误[^4]。 解决方法包括: - 确保 HTML 文件中没有显式引用 `about:blank` 或者不必要的框架标签。 - 如果错误不影响最终 PDF 的生成效果,可以在命令行中使用 `--no-stop-slow-scripts` 参数来忽略脚本执行超时问题,或者使用 `--quiet` 参数来抑制警告输出: ```bash wkhtmltopdf --enable-local-file-access --no-stop-slow-scripts --quiet index.html output.pdf ``` - 如果使用的是嵌入式框架或 iframe,建议将其内容内联到主 HTML 文件中,或者确保其指向的 URL 是有效的 HTTP 地址,而不是 `about:blank`。 此外,如果 HTML 文件中引用了本地路径的资源(如图片、CSS),应确保路径格式为绝对路径或完整的 `file://` 协议格式,以避免路径解析失败。例如: ```html <img src="file:///home/user/images/logo.png"> <link rel="stylesheet" href="file:///home/user/css/style.css"> ``` 这样可以提高 `wkhtmltopdf` 对本地资源的识别能力,减少加载失败的情况[^5]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值