HTTP Status code

HTTP状态码详解
本文详细介绍了HTTP状态码的分类及常见代码的意义,包括临时响应、成功、重定向、请求错误和服务器错误等类别,帮助读者理解HTTP通信过程中的各种状态。

常见状态码

  • 1xx(临时响应):表示临时响应并需要请求者继续执行操作的状态代码
代码说明
100000(继续) 请求者应当继续提出请求。 服务器返回此代码表示已收到请求的第一部分,正在等待其余部分。
101(切换协议) 请求者已要求服务器切换协议,服务器已确认并准备切换。


  • 2xx(成功):表示成功处理了请求的状态代码。
代码说明
200服务器已成功处理了请求。 通常,这表示服务器提供了请求的网页。
202 服务器已接受请求,但尚未处理。
206 服务器成功处理了部分 GET 请求。


  • 3xx(重定向):表示要完成请求,需要进一步操作。 通常,这些状态代码用来重定向。
代码说明
302(Temporarily Moved 临时移动) 服务器目前从不同位置的网页响应请求,但请求者应继续使用原有位置来进行以后的请求。
  • 4xx(请求错误):这些状态代码表示请求可能出错,妨碍了服务器的处理。
代码说明
404not found
  • 5xx(服务器错误):这些状态代码表示请求可能出错,妨碍了服务器的处理。
代码 说明
500(服务器内部错误) 服务器遇到错误,无法完成请求。
503(服务不可用) 服务器目前无法使用(由于超载或停机维护)。 通常,这只是暂时状态。
504(网关超时) 服务器作为网关或代理,但是没有及时从上游服务器收到请求。
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]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值