FastWARC 2.0.0__tar.gz → 2.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (27) hide show
  1. {fastwarc-2.0.0 → fastwarc-2.1.0}/Cargo.lock +105 -94
  2. {fastwarc-2.0.0 → fastwarc-2.1.0}/Cargo.toml +3 -3
  3. {fastwarc-2.0.0 → fastwarc-2.1.0}/PKG-INFO +1 -1
  4. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/src/warc.rs +73 -17
  5. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/tests/test_fastwarc_cli.py +55 -0
  6. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/tests/test_warc.py +63 -11
  7. {fastwarc-2.0.0 → fastwarc-2.1.0}/python/fastwarc/cli.py +25 -18
  8. {fastwarc-2.0.0 → fastwarc-2.1.0}/python/fastwarc/warc.pyi +5 -4
  9. {fastwarc-2.0.0 → fastwarc-2.1.0}/README.md +0 -0
  10. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/.gitignore +0 -0
  11. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/Cargo.toml +0 -0
  12. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/README.md +0 -0
  13. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/build.rs +0 -0
  14. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/src/lib.rs +0 -0
  15. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/src/stream_io/brotli.rs +0 -0
  16. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/src/stream_io/chunked.rs +0 -0
  17. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/src/stream_io/gzip.rs +0 -0
  18. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/src/stream_io/lz4.rs +0 -0
  19. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/src/stream_io/mod.rs +0 -0
  20. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/src/stream_io/zstd.rs +0 -0
  21. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/stubtest-allowlist.txt +0 -0
  22. {fastwarc-2.0.0 → fastwarc-2.1.0}/fastwarc-py/tests/test_stream_io.py +0 -0
  23. {fastwarc-2.0.0 → fastwarc-2.1.0}/pyproject.toml +0 -0
  24. {fastwarc-2.0.0 → fastwarc-2.1.0}/python/fastwarc/__init__.py +0 -0
  25. {fastwarc-2.0.0 → fastwarc-2.1.0}/python/fastwarc/__init__.pyi +0 -0
  26. {fastwarc-2.0.0 → fastwarc-2.1.0}/python/fastwarc/py.typed +0 -0
  27. {fastwarc-2.0.0 → fastwarc-2.1.0}/python/fastwarc/stream_io.pyi +0 -0
@@ -34,9 +34,9 @@ checksum = "e9d4ee0d472d1cd2e28c97dfa124b3d8d992e10eb0a035f33f5d12e3a177ba3b"
34
34
 
35
35
  [[package]]
36
36
  name = "anyhow"
37
- version = "1.0.104"
37
+ version = "1.0.105"
38
38
  source = "registry+https://github.com/rust-lang/crates.io-index"
39
- checksum = "330a5ed07fa54e4702c9d6c4174f74427fc0ef6e214bbd677ae50a5099946470"
39
+ checksum = "2cb931c189b85683d69a5cfad41d4d418671e1ac413dd209f3f2fc31e3cfd902"
40
40
 
41
41
  [[package]]
42
42
  name = "async-trait"
@@ -46,7 +46,7 @@ checksum = "82f6aeea286b8eb4dd3431a1be1b59d290ace00f5bfd8e2a159bc2a05e2c1667"
46
46
  dependencies = [
47
47
  "proc-macro2",
48
48
  "quote",
49
- "syn 3.0.9",
49
+ "syn 3.0.10",
50
50
  ]
51
51
 
52
52
  [[package]]
@@ -119,7 +119,7 @@ dependencies = [
119
119
  "regex",
120
120
  "rustc-hash",
121
121
  "shlex",
122
- "syn 3.0.9",
122
+ "syn 3.0.10",
123
123
  ]
124
124
 
125
125
  [[package]]
@@ -139,9 +139,9 @@ dependencies = [
139
139
 
140
140
  [[package]]
141
141
  name = "brotli"
142
- version = "9.1.1"
142
+ version = "9.1.3"
143
143
  source = "registry+https://github.com/rust-lang/crates.io-index"
144
- checksum = "627b7cfb0578f0eafce087a90fcd40add1231900b69e4d4de2d456260a4f5d81"
144
+ checksum = "9071f285ed78f04f37d675abaaef5de7689e2f30a216c8dc6795465d81910a13"
145
145
  dependencies = [
146
146
  "alloc-no-stdlib",
147
147
  "alloc-stdlib",
@@ -150,9 +150,9 @@ dependencies = [
150
150
 
151
151
  [[package]]
152
152
  name = "brotli-decompressor"
153
- version = "6.2.0"
153
+ version = "6.4.0"
154
154
  source = "registry+https://github.com/rust-lang/crates.io-index"
155
- checksum = "34c6783f42c21c952ad7112b354f0ba2f10760e9decea5b1b60523d6e270faaf"
155
+ checksum = "664148598c930650998ef56df301329ffe7b4cdb02d49b2a3fca3bcaf2185bcb"
156
156
  dependencies = [
157
157
  "alloc-no-stdlib",
158
158
  "alloc-stdlib",
@@ -160,15 +160,15 @@ dependencies = [
160
160
 
161
161
  [[package]]
162
162
  name = "bumpalo"
163
- version = "3.20.3"
163
+ version = "3.20.4"
164
164
  source = "registry+https://github.com/rust-lang/crates.io-index"
165
- checksum = "72f5acc6cb2ba439de613abc23857ec3d78374d8ed5ac84e9d11336e87da8649"
165
+ checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db"
166
166
 
167
167
  [[package]]
168
168
  name = "bytes"
169
- version = "1.12.1"
169
+ version = "1.12.2"
170
170
  source = "registry+https://github.com/rust-lang/crates.io-index"
171
- checksum = "fc652a48c352aef3ea3aed32080501cf3ef6ed5da78602a020c991775b0aff04"
171
+ checksum = "776dfebd015e2d8732c684a2c71003674ccb49457b539b9e82151ba38e96dd7c"
172
172
 
173
173
  [[package]]
174
174
  name = "cap-primitives"
@@ -202,9 +202,9 @@ dependencies = [
202
202
 
203
203
  [[package]]
204
204
  name = "cc"
205
- version = "1.10.0"
205
+ version = "1.12.0"
206
206
  source = "registry+https://github.com/rust-lang/crates.io-index"
207
- checksum = "86e055fa6e3e40ad6187ba25b6855eeb635d5271f8e0f0e1e9a5826b8d75bea0"
207
+ checksum = "95e45cf2980b2d467be49a9ed942c9179b701063a7ca3d037de7ee9bd67f8d66"
208
208
  dependencies = [
209
209
  "find-msvc-tools",
210
210
  "jobserver",
@@ -240,9 +240,9 @@ dependencies = [
240
240
 
241
241
  [[package]]
242
242
  name = "const-oid"
243
- version = "0.10.2"
243
+ version = "0.10.3"
244
244
  source = "registry+https://github.com/rust-lang/crates.io-index"
245
- checksum = "a6ef517f0926dd24a1582492c791b6a4818a4d94e789a334894aa15b0d12f55c"
245
+ checksum = "be95d4a884358a21a199689323c29e9256b4a1b315e22f183d155422041d3a9a"
246
246
 
247
247
  [[package]]
248
248
  name = "cpufeatures"
@@ -369,9 +369,9 @@ checksum = "00d174d5400e5e8fd687ad1049e2f578285fa914201b1af7e8b112a4546bd826"
369
369
 
370
370
  [[package]]
371
371
  name = "errno"
372
- version = "0.3.14"
372
+ version = "0.3.15"
373
373
  source = "registry+https://github.com/rust-lang/crates.io-index"
374
- checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
374
+ checksum = "e35d6e78f4cebb90e51d543db8fe41528851d6deeef6ef21ebd4bfdc1e784776"
375
375
  dependencies = [
376
376
  "libc",
377
377
  "windows-sys 0.61.2",
@@ -385,7 +385,7 @@ checksum = "da7c62ceae207dd37ea5b845da6a0696c799f85e97da1ab5b7910be3c1c80223"
385
385
 
386
386
  [[package]]
387
387
  name = "fastwarc"
388
- version = "2.0.0"
388
+ version = "2.1.0"
389
389
  dependencies = [
390
390
  "brotli",
391
391
  "data-encoding",
@@ -406,7 +406,7 @@ dependencies = [
406
406
 
407
407
  [[package]]
408
408
  name = "fastwarc-grpc"
409
- version = "2.0.0"
409
+ version = "2.1.0"
410
410
  dependencies = [
411
411
  "cap-std",
412
412
  "fastwarc",
@@ -426,7 +426,7 @@ dependencies = [
426
426
 
427
427
  [[package]]
428
428
  name = "fastwarc-py"
429
- version = "2.0.0"
429
+ version = "2.1.0"
430
430
  dependencies = [
431
431
  "fastwarc",
432
432
  "pyo3",
@@ -436,15 +436,15 @@ dependencies = [
436
436
 
437
437
  [[package]]
438
438
  name = "find-msvc-tools"
439
- version = "0.1.15"
439
+ version = "0.1.16"
440
440
  source = "registry+https://github.com/rust-lang/crates.io-index"
441
- checksum = "1c66915cc5391097de7a2b0b972e8505aa33c0df401fd3a6811dbdb32881ba48"
441
+ checksum = "3e44f110d1777dc6559a51e7d45083945ded4f1bf3305494350f693b6d20b9c8"
442
442
 
443
443
  [[package]]
444
444
  name = "fixedbitset"
445
- version = "0.5.7"
445
+ version = "0.5.9"
446
446
  source = "registry+https://github.com/rust-lang/crates.io-index"
447
- checksum = "1d674e81391d1e1ab681a28d99df07927c6d4aa5b027d7da16ba32d1d21ecd99"
447
+ checksum = "5905ec755cc8386d7928353e4d356d2be3e89e81e5ca01fe630a1ca4d08dc175"
448
448
 
449
449
  [[package]]
450
450
  name = "fnv"
@@ -527,9 +527,9 @@ checksum = "e4eba85ea1d0a966a983acd07deee566e67395d2d96b6fb39e62b5a833f1eb0b"
527
527
 
528
528
  [[package]]
529
529
  name = "h2"
530
- version = "0.4.20"
530
+ version = "0.4.21"
531
531
  source = "registry+https://github.com/rust-lang/crates.io-index"
532
- checksum = "7d29020232d6aa3fb1daca64c1127cf662cf97f254ae16c18c05b8ab635fc118"
532
+ checksum = "b634322c4924093fe6a6e05ecbe5717cd3c6014934455f4ae8e5cf14ba3264a8"
533
533
  dependencies = [
534
534
  "atomic-waker",
535
535
  "bytes",
@@ -555,9 +555,9 @@ dependencies = [
555
555
 
556
556
  [[package]]
557
557
  name = "hashbrown"
558
- version = "0.17.1"
558
+ version = "0.17.2"
559
559
  source = "registry+https://github.com/rust-lang/crates.io-index"
560
- checksum = "ed5909b6e89a2db4456e54cd5f673791d7eca6732202bbf2a9cc504fe2f9b84a"
560
+ checksum = "735eaa21a6a5ffb2e84362faaeb90c05ba8e19797ca30428478cb6ea3a4921bc"
561
561
 
562
562
  [[package]]
563
563
  name = "heck"
@@ -621,9 +621,9 @@ dependencies = [
621
621
 
622
622
  [[package]]
623
623
  name = "hyper"
624
- version = "1.12.0"
624
+ version = "1.13.0"
625
625
  source = "registry+https://github.com/rust-lang/crates.io-index"
626
- checksum = "2c3e324da4c95177d6291d4c8730197c0d1822f8a9766814a4a44fa5ab797c9c"
626
+ checksum = "229c6ff5584df4c6becbfe00567128bac768c8cd32ebc8a8366bd81ed072e8f3"
627
627
  dependencies = [
628
628
  "atomic-waker",
629
629
  "bytes",
@@ -682,7 +682,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
682
682
  checksum = "cc4e190f5d26ca7051642629da2c52fc03bde85a03197c99408dcd291734c855"
683
683
  dependencies = [
684
684
  "equivalent",
685
- "hashbrown 0.17.1",
685
+ "hashbrown 0.17.2",
686
686
  ]
687
687
 
688
688
  [[package]]
@@ -715,18 +715,18 @@ checksum = "791930b43c0d5973160d90a8f3894509f2b273430f5c5c73b668636d0287c5c0"
715
715
 
716
716
  [[package]]
717
717
  name = "itertools"
718
- version = "0.14.0"
718
+ version = "0.15.0"
719
719
  source = "registry+https://github.com/rust-lang/crates.io-index"
720
- checksum = "2b192c782037fadd9cfa75548310488aabdbf3d2da73885b31bd0abd03351285"
720
+ checksum = "8b4baf93f58d4425749ca49a51c50ebab072c5df6994d08fed93541c331481dc"
721
721
  dependencies = [
722
722
  "either",
723
723
  ]
724
724
 
725
725
  [[package]]
726
726
  name = "itoa"
727
- version = "1.0.18"
727
+ version = "1.0.19"
728
728
  source = "registry+https://github.com/rust-lang/crates.io-index"
729
- checksum = "8f42a60cbdf9a97f5d2305f08a87dc4e09308d1276d28c869c684d7777685682"
729
+ checksum = "3bd1574e617a9a6c1f8f8181bd7e841e1f20e4277607ef28945765188d6284d4"
730
730
 
731
731
  [[package]]
732
732
  name = "jobserver"
@@ -782,15 +782,15 @@ dependencies = [
782
782
 
783
783
  [[package]]
784
784
  name = "log"
785
- version = "0.4.34"
785
+ version = "0.4.35"
786
786
  source = "registry+https://github.com/rust-lang/crates.io-index"
787
- checksum = "f9f8bd3e56ce4dfc153cf470fffbfa98c7620958b312ca5c3a4b8d5181fd13c6"
787
+ checksum = "5d15f86d12da44cd8d4ec3c73984537eb7f4cadcb9776a575a0a8a05ca11005c"
788
788
 
789
789
  [[package]]
790
790
  name = "lz4_flex"
791
- version = "0.14.0"
791
+ version = "0.14.2"
792
792
  source = "registry+https://github.com/rust-lang/crates.io-index"
793
- checksum = "ecbdfe44b1bd960b68170b417450a628c43f7cf56bb3c5317e61cb230ee7f226"
793
+ checksum = "f56455fff36934a9500d69062aec1c77037179b6f0669e4d5d6b72b84722d6a3"
794
794
  dependencies = [
795
795
  "twox-hash",
796
796
  ]
@@ -825,9 +825,9 @@ checksum = "cf8baf1c55e62ffcace7a9f06f4bd9cd3f0c4beb022d3b367256b91b87513d98"
825
825
 
826
826
  [[package]]
827
827
  name = "mime"
828
- version = "0.3.17"
828
+ version = "0.3.18"
829
829
  source = "registry+https://github.com/rust-lang/crates.io-index"
830
- checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
830
+ checksum = "d5848f5a9e8117cf94f2f90faac24a87ff81600ff8628c1e3deaab572e76bfa1"
831
831
 
832
832
  [[package]]
833
833
  name = "minimal-lexical"
@@ -837,9 +837,9 @@ checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a"
837
837
 
838
838
  [[package]]
839
839
  name = "mio"
840
- version = "1.2.4"
840
+ version = "1.2.5"
841
841
  source = "registry+https://github.com/rust-lang/crates.io-index"
842
- checksum = "1788edb87fdc09c7e26304471e2f5be8cdefb1b6930d6e3985fc02ff53bf86ee"
842
+ checksum = "20521a903f02b0a573cd6840e9d0a5a0cc043d361fe924092cd70f8556cc9c4a"
843
843
  dependencies = [
844
844
  "libc",
845
845
  "wasi",
@@ -915,29 +915,29 @@ dependencies = [
915
915
 
916
916
  [[package]]
917
917
  name = "pin-project"
918
- version = "1.1.13"
918
+ version = "1.2.0"
919
919
  source = "registry+https://github.com/rust-lang/crates.io-index"
920
- checksum = "2466b2336ed02bcdca6b294417127b90ec92038d1d5c4fbeac971a922e0e0924"
920
+ checksum = "a6c2123f4708bbd422630a6dae7c03f678b1ce1f1c99e4c4b3beac69c8174cc9"
921
921
  dependencies = [
922
922
  "pin-project-internal",
923
923
  ]
924
924
 
925
925
  [[package]]
926
926
  name = "pin-project-internal"
927
- version = "1.1.13"
927
+ version = "1.2.0"
928
928
  source = "registry+https://github.com/rust-lang/crates.io-index"
929
- checksum = "c96395f0a926bc13b1c17622aaddda1ecb55d49c8f1bf9777e4d877800a43f8b"
929
+ checksum = "358938fd6df944c1e44bb328b60fb275f13c804aac47ba26a1165d45a3f87756"
930
930
  dependencies = [
931
931
  "proc-macro2",
932
932
  "quote",
933
- "syn 2.0.119",
933
+ "syn 3.0.10",
934
934
  ]
935
935
 
936
936
  [[package]]
937
937
  name = "pin-project-lite"
938
- version = "0.2.17"
938
+ version = "0.2.18"
939
939
  source = "registry+https://github.com/rust-lang/crates.io-index"
940
- checksum = "a89322df9ebe1c1578d689c92318e070967d1042b512afbe49518723f4e6d5cd"
940
+ checksum = "c938015719552d665fd0553b90d96cd7ff58e83e4c061ca99e6bb78865a72752"
941
941
 
942
942
  [[package]]
943
943
  name = "pkg-config"
@@ -977,6 +977,16 @@ dependencies = [
977
977
  "syn 2.0.119",
978
978
  ]
979
979
 
980
+ [[package]]
981
+ name = "prettyplease"
982
+ version = "0.3.0"
983
+ source = "registry+https://github.com/rust-lang/crates.io-index"
984
+ checksum = "2bfe0f4c752e450fc2faf62654f1c134747922825d5b04ca717b8874f41a40c0"
985
+ dependencies = [
986
+ "proc-macro2",
987
+ "syn 3.0.10",
988
+ ]
989
+
980
990
  [[package]]
981
991
  name = "proc-macro2"
982
992
  version = "1.0.107"
@@ -988,9 +998,9 @@ dependencies = [
988
998
 
989
999
  [[package]]
990
1000
  name = "prost"
991
- version = "0.14.4"
1001
+ version = "0.14.6"
992
1002
  source = "registry+https://github.com/rust-lang/crates.io-index"
993
- checksum = "528ac67416ff8646872a3c02cad9cc4ee5dc9f9540c9b10771855c95cb2e5ae1"
1003
+ checksum = "3ef0b569d1d907ab3a28596aee62cf1f61dacb0529a4bedcd8e7460e2d5228b4"
994
1004
  dependencies = [
995
1005
  "bytes",
996
1006
  "prost-derive",
@@ -998,30 +1008,30 @@ dependencies = [
998
1008
 
999
1009
  [[package]]
1000
1010
  name = "prost-build"
1001
- version = "0.14.4"
1011
+ version = "0.14.6"
1002
1012
  source = "registry+https://github.com/rust-lang/crates.io-index"
1003
- checksum = "03da047801ff44bb6a4d407d4860c05fd70bb81714e6b2f3812603d5b145b042"
1013
+ checksum = "b6e4d69d0fa3e7f6f9cf6b53a0e83e4fc99ba3586f65ce166cff30bd13bb4ad2"
1004
1014
  dependencies = [
1005
1015
  "heck",
1006
1016
  "itertools",
1007
1017
  "log",
1008
1018
  "multimap",
1009
1019
  "petgraph",
1010
- "prettyplease",
1020
+ "prettyplease 0.3.0",
1011
1021
  "prost",
1012
1022
  "prost-types",
1013
1023
  "pulldown-cmark",
1014
1024
  "pulldown-cmark-to-cmark",
1015
1025
  "regex",
1016
- "syn 2.0.119",
1026
+ "syn 3.0.10",
1017
1027
  "tempfile",
1018
1028
  ]
1019
1029
 
1020
1030
  [[package]]
1021
1031
  name = "prost-derive"
1022
- version = "0.14.4"
1032
+ version = "0.14.6"
1023
1033
  source = "registry+https://github.com/rust-lang/crates.io-index"
1024
- checksum = "b570b25f7617e43d59005d0990ccb79e950a423952cea19671b7a876da390adf"
1034
+ checksum = "1ad9c5423459fa2f729b8d9235fab810aa29628b171467744fc86d21460ad70d"
1025
1035
  dependencies = [
1026
1036
  "anyhow",
1027
1037
  "itertools",
@@ -1032,9 +1042,9 @@ dependencies = [
1032
1042
 
1033
1043
  [[package]]
1034
1044
  name = "prost-types"
1035
- version = "0.14.4"
1045
+ version = "0.14.6"
1036
1046
  source = "registry+https://github.com/rust-lang/crates.io-index"
1037
- checksum = "f94967dc7688f3054c7fac87473ffae4cc4c3904800e2d9f5b857246d8963b0a"
1047
+ checksum = "f29a7c4c7a84cef41a53d338a2d10d4f1b043ea5c3dde26db22ee2c9c1b1c75b"
1038
1048
  dependencies = [
1039
1049
  "prost",
1040
1050
  ]
@@ -1101,7 +1111,7 @@ dependencies = [
1101
1111
  "proc-macro2",
1102
1112
  "pyo3-macros-backend",
1103
1113
  "quote",
1104
- "syn 3.0.9",
1114
+ "syn 3.0.10",
1105
1115
  ]
1106
1116
 
1107
1117
  [[package]]
@@ -1113,7 +1123,7 @@ dependencies = [
1113
1123
  "heck",
1114
1124
  "proc-macro2",
1115
1125
  "quote",
1116
- "syn 3.0.9",
1126
+ "syn 3.0.10",
1117
1127
  ]
1118
1128
 
1119
1129
  [[package]]
@@ -1142,9 +1152,9 @@ dependencies = [
1142
1152
 
1143
1153
  [[package]]
1144
1154
  name = "regex"
1145
- version = "1.13.1"
1155
+ version = "1.13.2"
1146
1156
  source = "registry+https://github.com/rust-lang/crates.io-index"
1147
- checksum = "f020237b6c8eed93db2e2cb53c00c60a8e1bc73da7d073199a1180401450218d"
1157
+ checksum = "9807af0e638c12e753aa1b4e601791bf2a8f71274023c8bbeec12fc149950857"
1148
1158
  dependencies = [
1149
1159
  "aho-corasick",
1150
1160
  "memchr",
@@ -1154,9 +1164,9 @@ dependencies = [
1154
1164
 
1155
1165
  [[package]]
1156
1166
  name = "regex-automata"
1157
- version = "0.4.18"
1167
+ version = "0.4.19"
1158
1168
  source = "registry+https://github.com/rust-lang/crates.io-index"
1159
- checksum = "ad8553b9b26413251cbf30e620595c7a41b3887f03da04579c0e6b0d6a06b4b2"
1169
+ checksum = "41d60ef07df457506a0a1a2073112eb4aae5733dbd2813c3da77d1b0fd441158"
1160
1170
  dependencies = [
1161
1171
  "aho-corasick",
1162
1172
  "memchr",
@@ -1165,9 +1175,9 @@ dependencies = [
1165
1175
 
1166
1176
  [[package]]
1167
1177
  name = "regex-syntax"
1168
- version = "0.8.11"
1178
+ version = "0.8.12"
1169
1179
  source = "registry+https://github.com/rust-lang/crates.io-index"
1170
- checksum = "d6f6ff9a378485b298a5286656da665ba74413d36db0979633275d2e708145d4"
1180
+ checksum = "d902046e6a28a1e4c3cab97258a0ce11e994903f01c2d97a9447a0b3df85f4f6"
1171
1181
 
1172
1182
  [[package]]
1173
1183
  name = "relative-path"
@@ -1177,17 +1187,18 @@ checksum = "ba39f3699c378cd8970968dcbff9c43159ea4cfbd88d43c00b22f2ef10a435d2"
1177
1187
 
1178
1188
  [[package]]
1179
1189
  name = "resiliparse"
1180
- version = "2.0.0"
1190
+ version = "2.1.0"
1181
1191
  dependencies = [
1182
1192
  "bindgen",
1183
1193
  "parking_lot",
1184
1194
  "regex",
1195
+ "rstest",
1185
1196
  "serde_json",
1186
1197
  ]
1187
1198
 
1188
1199
  [[package]]
1189
1200
  name = "resiliparse-py"
1190
- version = "2.0.0"
1201
+ version = "2.1.0"
1191
1202
  dependencies = [
1192
1203
  "libc",
1193
1204
  "pyo3",
@@ -1303,7 +1314,7 @@ checksum = "e7a5d71263a5a7d47b41f6b3f06ba276f10cc18b0931f1799f710578e2309348"
1303
1314
  dependencies = [
1304
1315
  "proc-macro2",
1305
1316
  "quote",
1306
- "syn 3.0.9",
1317
+ "syn 3.0.10",
1307
1318
  ]
1308
1319
 
1309
1320
  [[package]]
@@ -1332,9 +1343,9 @@ dependencies = [
1332
1343
 
1333
1344
  [[package]]
1334
1345
  name = "sha2"
1335
- version = "0.11.1"
1346
+ version = "0.11.2"
1336
1347
  source = "registry+https://github.com/rust-lang/crates.io-index"
1337
- checksum = "47d7069beb7d6ac7b9acd1039986e73443f24234f41074da099d6f994ac9ad19"
1348
+ checksum = "5b0e5c7d67bc53f435386b2130fdc900488c5703770f6d8a4633060e34288a27"
1338
1349
  dependencies = [
1339
1350
  "cfg-if",
1340
1351
  "cpufeatures",
@@ -1365,9 +1376,9 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5"
1365
1376
 
1366
1377
  [[package]]
1367
1378
  name = "smallvec"
1368
- version = "1.16.4"
1379
+ version = "1.16.6"
1369
1380
  source = "registry+https://github.com/rust-lang/crates.io-index"
1370
- checksum = "d0d5d4b1981b8bbbb7aed204cae5726d683d5d6ac7e74ec54122ea28f315e7c8"
1381
+ checksum = "3244542535d5de959d90ec55d1b5ff0fd2bb7b1310223907d5f11932847f7b59"
1371
1382
 
1372
1383
  [[package]]
1373
1384
  name = "socket2"
@@ -1392,9 +1403,9 @@ dependencies = [
1392
1403
 
1393
1404
  [[package]]
1394
1405
  name = "syn"
1395
- version = "3.0.9"
1406
+ version = "3.0.10"
1396
1407
  source = "registry+https://github.com/rust-lang/crates.io-index"
1397
- checksum = "d78c8dee4c7bf0e14673097256fed6142ce9d3b85a408189d07482442145823b"
1408
+ checksum = "4ae9ccbea3a7b0b09443036490c8f34a8b1b760fd345e5c0dae0aac718faea79"
1398
1409
  dependencies = [
1399
1410
  "proc-macro2",
1400
1411
  "quote",
@@ -1409,9 +1420,9 @@ checksum = "0bf256ce5efdfa370213c1dabab5935a12e49f2c58d15e9eac2870d3b4f27263"
1409
1420
 
1410
1421
  [[package]]
1411
1422
  name = "target-lexicon"
1412
- version = "0.13.5"
1423
+ version = "0.13.6"
1413
1424
  source = "registry+https://github.com/rust-lang/crates.io-index"
1414
- checksum = "adb6935a6f5c20170eeceb1a3835a49e12e19d792f6dd344ccc76a985ca5a6ca"
1425
+ checksum = "8c447be3a2abfa84b2d91680c56600bd6b2873866de27b36ec911be705e291da"
1415
1426
 
1416
1427
  [[package]]
1417
1428
  name = "tempfile"
@@ -1480,7 +1491,7 @@ checksum = "78773a2a397f451582ce068015985c33193cf6dea8b74d2a639fe457b2f07b0e"
1480
1491
  dependencies = [
1481
1492
  "proc-macro2",
1482
1493
  "quote",
1483
- "syn 3.0.9",
1494
+ "syn 3.0.10",
1484
1495
  ]
1485
1496
 
1486
1497
  [[package]]
@@ -1545,7 +1556,7 @@ version = "0.14.9"
1545
1556
  source = "registry+https://github.com/rust-lang/crates.io-index"
1546
1557
  checksum = "ac6d916d206ed7bdda1778ddff9bda43303789c258877e7bc22fb44ee5c984b4"
1547
1558
  dependencies = [
1548
- "prettyplease",
1559
+ "prettyplease 0.2.37",
1549
1560
  "proc-macro2",
1550
1561
  "quote",
1551
1562
  "syn 2.0.119",
@@ -1581,7 +1592,7 @@ version = "0.14.9"
1581
1592
  source = "registry+https://github.com/rust-lang/crates.io-index"
1582
1593
  checksum = "2ea216ddc448e08e7839ab09e20e60b06b6a1c32745ccb212c0ebd161c199f1b"
1583
1594
  dependencies = [
1584
- "prettyplease",
1595
+ "prettyplease 0.2.37",
1585
1596
  "proc-macro2",
1586
1597
  "prost-build",
1587
1598
  "prost-types",
@@ -1699,9 +1710,9 @@ checksum = "a2c754d6c33795a1c324727428e5a7dedb5b06195f9890bdbcba760d3e246563"
1699
1710
 
1700
1711
  [[package]]
1701
1712
  name = "uuid"
1702
- version = "1.29.0"
1713
+ version = "1.29.3"
1703
1714
  source = "registry+https://github.com/rust-lang/crates.io-index"
1704
- checksum = "4a0e2d11620c50695fe12bbbfde96b3477fe606e7284c22d505c12ce51214514"
1715
+ checksum = "3c14b15dffa2f4bd712103e857140aa04a4f2ff6e955c77d7eb8e53ee02a3b64"
1705
1716
  dependencies = [
1706
1717
  "getrandom",
1707
1718
  "js-sys",
@@ -1754,7 +1765,7 @@ dependencies = [
1754
1765
  "bumpalo",
1755
1766
  "proc-macro2",
1756
1767
  "quote",
1757
- "syn 3.0.9",
1768
+ "syn 3.0.10",
1758
1769
  "wasm-bindgen-shared",
1759
1770
  ]
1760
1771
 
@@ -1947,9 +1958,9 @@ checksum = "cfe53a6657fd280eaa890a3bc59152892ffa3e30101319d168b781ed6529b049"
1947
1958
 
1948
1959
  [[package]]
1949
1960
  name = "zlib-rs"
1950
- version = "0.6.8"
1961
+ version = "0.6.9"
1951
1962
  source = "registry+https://github.com/rust-lang/crates.io-index"
1952
- checksum = "b268e58e7c693d7c271f93ffc4ba3b380412554231c85bf61ca7af91042a4112"
1963
+ checksum = "aa76918995d776d9dd34d371030be228d021137449771493d56e29f77e4148ac"
1953
1964
 
1954
1965
  [[package]]
1955
1966
  name = "zmij"
@@ -1959,27 +1970,27 @@ checksum = "29666d0abbfad1e3dc4dcf6144730dd3a3ab225bbbdac83319345b1b44ccfc1b"
1959
1970
 
1960
1971
  [[package]]
1961
1972
  name = "zstd"
1962
- version = "0.14.3"
1973
+ version = "0.14.5"
1963
1974
  source = "registry+https://github.com/rust-lang/crates.io-index"
1964
- checksum = "db3ae9bf90af6e40197bef767eeefc46ad6397420fe873830bd85e5fbbfb3c70"
1975
+ checksum = "465cb081cac3a28a84ef547702dba1fe0f4a9f22e4e57a0b675ceee028c2af80"
1965
1976
  dependencies = [
1966
1977
  "zstd-safe",
1967
1978
  ]
1968
1979
 
1969
1980
  [[package]]
1970
1981
  name = "zstd-safe"
1971
- version = "8.2.0"
1982
+ version = "8.4.0"
1972
1983
  source = "registry+https://github.com/rust-lang/crates.io-index"
1973
- checksum = "ded520f16b29e1a9b771c722221b2b0a0398c2316d9bb3c42b458a5414d7434b"
1984
+ checksum = "9b09bddd92c53b91833f4df03e0ea07e02d8367cfcd15a3b9acda94fc273f793"
1974
1985
  dependencies = [
1975
1986
  "zstd-sys",
1976
1987
  ]
1977
1988
 
1978
1989
  [[package]]
1979
1990
  name = "zstd-sys"
1980
- version = "2.1.2+zstd.1.5.7"
1991
+ version = "2.2.0+zstd.1.6.0"
1981
1992
  source = "registry+https://github.com/rust-lang/crates.io-index"
1982
- checksum = "481ada9c543b2323cbb7bbdbb5249177fbf0188ed959ed2c15e4b22421c84ed3"
1993
+ checksum = "c3f4089cda6dda4dc43c43dd9f8964140064fd2f752f3da46c3a483c3c175160"
1983
1994
  dependencies = [
1984
1995
  "cc",
1985
1996
  "pkg-config",
@@ -3,7 +3,7 @@ resolver = "2"
3
3
  members = ["fastwarc-py"]
4
4
 
5
5
  [workspace.package]
6
- version = "2.0.0"
6
+ version = "2.1.0"
7
7
  edition = "2024"
8
8
  publish = true
9
9
  description = "A collection of robust and fast processing tools for parsing and analyzing (not only) web archive data."
@@ -13,8 +13,8 @@ repository = "https://github.com/chatnoir-eu/chatnoir-resiliparse/"
13
13
  license = "Apache-2.0"
14
14
 
15
15
  [workspace.dependencies]
16
- fastwarc = "=2.0.0"
17
- resiliparse = "=2.0.0"
16
+ fastwarc = "=2.1.0"
17
+ resiliparse = "=2.1.0"
18
18
  bindgen = { version = "0.73", default-features = false, features = ["logging", "runtime"] }
19
19
  pyo3 = "0.30"
20
20
  pyo3-build-config = "0.30"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: FastWARC
3
- Version: 2.0.0
3
+ Version: 2.1.0
4
4
  Requires-Dist: brotli
5
5
  Requires-Dist: click
6
6
  Requires-Dist: tqdm
@@ -21,13 +21,14 @@ use fastwarc::warc::header::{HeaderEncoding, HeaderMap, WarcHeader};
21
21
  use fastwarc::warc::iter::{ArchiveIteratorOptions, ArchiveIteratorThreadSafe, ArchiveIteratorTrait, filter};
22
22
  use fastwarc::warc::record::{AutoDecode, WarcRecord, WarcRecordType};
23
23
  use fastwarc::warc::record::{DigestError::StreamError, SharedWarcRecord};
24
- use pyo3::exceptions::{PyKeyError, PyOSError, PyValueError};
25
- use pyo3::intern;
24
+ use pyo3::exceptions::{PyKeyError, PyOSError, PyTypeError, PyValueError};
26
25
  use pyo3::prelude::*;
27
26
  use pyo3::types::{
28
27
  PyBool, PyBytes, PyDateAccess, PyDateTime, PyDelta, PyDeltaAccess, PyDict, PyIterator, PyString, PyTimeAccess,
29
28
  PyTuple, PyType,
30
29
  };
30
+ use pyo3::{PyTypeInfo, intern};
31
+ use std::fmt::Debug;
31
32
  use std::io::{self, Read, Seek};
32
33
  use std::sync::{Arc, Mutex, MutexGuard};
33
34
  use time::{Date, Month, OffsetDateTime, Time, UtcOffset};
@@ -96,6 +97,10 @@ impl From<WarcRecordType> for WarcRecordTypePy {
96
97
 
97
98
  #[pymethods]
98
99
  impl WarcRecordTypePy {
100
+ pub fn __reduce__<'py>(&self, py: Python<'py>) -> PyResult<ReduceByName<'py>> {
101
+ reduce_by_name(py, self)
102
+ }
103
+
99
104
  pub fn __index__(&self) -> u16 {
100
105
  *self as u16
101
106
  }
@@ -133,6 +138,15 @@ impl WarcRecordTypePy {
133
138
  }
134
139
  }
135
140
 
141
+ /// Pickle reduction tuple that restores an enum member via ``getattr(cls, name)``.
142
+ type ReduceByName<'py> = (Bound<'py, PyAny>, (Bound<'py, PyType>, String));
143
+
144
+ /// Reduce a simple enum member to a lookup of its variant name on its class.
145
+ fn reduce_by_name<'py, T: PyTypeInfo + Debug>(py: Python<'py>, value: &T) -> PyResult<ReduceByName<'py>> {
146
+ let getattr = PyModule::import(py, "builtins")?.getattr("getattr")?;
147
+ Ok((getattr, (py.get_type::<T>(), format!("{value:?}"))))
148
+ }
149
+
136
150
  // ===========================================================
137
151
  // WarcHeader
138
152
  // ===========================================================
@@ -198,6 +212,10 @@ impl From<WarcHeaderPy> for WarcHeader {
198
212
 
199
213
  #[pymethods]
200
214
  impl WarcHeaderPy {
215
+ pub fn __reduce__<'py>(&self, py: Python<'py>) -> PyResult<ReduceByName<'py>> {
216
+ reduce_by_name(py, self)
217
+ }
218
+
201
219
  pub fn __str__(&self) -> &'static str {
202
220
  WarcHeader::from(*self).as_str()
203
221
  }
@@ -867,7 +885,8 @@ impl WarcRecordPy {
867
885
  let (serialized, http_parsed) = state;
868
886
  let mut record = WarcRecord::from_bytes(serialized)?;
869
887
  if http_parsed {
870
- record.parse_http()?;
888
+ // The snapshot contains the payload reader's output, which may already be decoded.
889
+ record.parse_http_with_decode(AutoDecode::None)?;
871
890
  }
872
891
  self.inner = Arc::new(Mutex::new(record));
873
892
  Ok(())
@@ -1219,6 +1238,9 @@ impl WarcRecordPy {
1219
1238
  ///
1220
1239
  /// Quirks mode allows parsing of headers terminated with only LF instead of CRLF.
1221
1240
  ///
1241
+ /// .. versionchanged:: 2.1.0
1242
+ /// HTTP transfer encoding is decoded by default. Use ``auto_decode='none'`` to read the stored body.
1243
+ ///
1222
1244
  /// :param auto_decode: Automatically decode HTTP payload encodings
1223
1245
  /// (accepted values: ``'none'``, ``'content'``, ``'transfer'``, ``'all'``).
1224
1246
  /// :param max_header_len: Maximum allowed header length (throws an error if exceeded)
@@ -1226,7 +1248,7 @@ impl WarcRecordPy {
1226
1248
  /// :param strict_mode: This argument is deprecated and ignored.
1227
1249
  /// :raise ValueError: If auto_decode is not a supported decoding mode
1228
1250
  /// :raise OSError: If HTTP headers are invalid, exceed max_header_len, or cannot be read
1229
- #[pyo3(signature = (auto_decode="none", max_header_len=32 << 10, quirks_mode=false, *, strict_mode=true))]
1251
+ #[pyo3(signature = (auto_decode="transfer", max_header_len=32 << 10, quirks_mode=false, *, strict_mode=true))]
1230
1252
  pub fn parse_http(
1231
1253
  &mut self,
1232
1254
  auto_decode: &str,
@@ -1258,15 +1280,22 @@ impl WarcRecordPy {
1258
1280
 
1259
1281
  /// Verify whether ``WARC-Payload-Digest`` matches the current HTTP payload.
1260
1282
  ///
1261
- /// HTTP headers must have been parsed first with :meth:`parse_http`.
1262
- /// Returns ``False`` for missing or invalid digest metadata and raises
1263
- /// :class:`OSError` only for stream I/O failures.
1283
+ /// Parse HTTP headers first with :meth:`parse_http`. Revisit payloads require
1284
+ /// interpreting the revisit profile and may come from another record.
1285
+ /// Verify before decoding HTTP content encoding.
1286
+ ///
1287
+ /// .. versionchanged:: 2.1.0
1288
+ /// Verification decodes HTTP transfer encoding by default. To verify against the stored bytes,
1289
+ /// parse with ``auto_decode='none'`` and pass ``decode_transfer=False``.
1264
1290
  ///
1265
1291
  /// :param consume: Consume the remaining payload instead of preserving it
1292
+ /// :param decode_transfer: Decode HTTP transfer encoding for the digest (default: ``True``)
1293
+ /// :return: Whether the digest matches. Returns ``False`` when verification is unavailable,
1294
+ /// including for revisit records and missing or invalid digest metadata.
1266
1295
  /// :raise OSError: If reading the payload fails
1267
- #[pyo3(signature = (consume=false))]
1268
- pub fn verify_payload_digest(&mut self, consume: bool) -> PyResult<bool> {
1269
- match self.lock().verify_payload_digest(consume) {
1296
+ #[pyo3(signature = (consume=false, decode_transfer=true))]
1297
+ pub fn verify_payload_digest(&mut self, consume: bool, decode_transfer: bool) -> PyResult<bool> {
1298
+ match self.lock().verify_payload_digest_with_opts(consume, decode_transfer) {
1270
1299
  Ok(valid) => Ok(valid),
1271
1300
  Err(StreamError(e)) => Err(PyOSError::new_err(e.to_string())),
1272
1301
  Err(_) => Ok(false),
@@ -1275,13 +1304,21 @@ impl WarcRecordPy {
1275
1304
 
1276
1305
  /// Write this record to a stream.
1277
1306
  ///
1307
+ /// Read with ``auto_decode='none'`` to preserve the stored HTTP block for writing.
1308
+ /// Parse HTTP headers before writing to generate a payload digest.
1309
+ ///
1310
+ /// .. versionchanged:: 2.1.0
1311
+ /// When generating a payload digest, HTTP transfer encoding is decoded by default.
1312
+ /// The stored HTTP bytes are written as-is. Pass ``decode_transfer=False`` to hash those bytes.
1313
+ ///
1278
1314
  /// :param stream: Output stream
1279
1315
  /// :param checksum_data: Calculate and add block and payload digests
1280
1316
  /// :param payload_digest: Optional SHA-1 payload digest bytes
1281
1317
  /// :param chunk_size: Write block size
1318
+ /// :param decode_transfer: Decode HTTP transfer encoding when generating the payload digest (default: ``True``)
1282
1319
  /// :return: Number of bytes written
1283
1320
  /// :raise OSError: If the record stream operation fails
1284
- #[pyo3(signature = (stream, checksum_data=false, payload_digest=None, chunk_size=16384))]
1321
+ #[pyo3(signature = (stream, checksum_data=false, payload_digest=None, chunk_size=16384, decode_transfer=true))]
1285
1322
  pub fn write<'py>(
1286
1323
  &mut self,
1287
1324
  py: Python<'py>,
@@ -1289,6 +1326,7 @@ impl WarcRecordPy {
1289
1326
  checksum_data: bool,
1290
1327
  payload_digest: Option<&[u8]>,
1291
1328
  chunk_size: usize,
1329
+ decode_transfer: bool,
1292
1330
  ) -> PyResult<usize> {
1293
1331
  if let Some(payload_digest) = payload_digest {
1294
1332
  let encoded = py
@@ -1312,12 +1350,9 @@ impl WarcRecordPy {
1312
1350
  };
1313
1351
 
1314
1352
  let mut writer = PyWriterAdapter::new(stream.clone().unbind())?;
1315
- let bytes_written = if checksum_data {
1353
+ let bytes_written =
1316
1354
  self.lock()
1317
- .write_with_block_size_checksum(&mut writer, chunk_size, true)?
1318
- } else {
1319
- self.lock().write_with_block_size(&mut writer, chunk_size)?
1320
- };
1355
+ .write_with_block_size_checksum_opts(&mut writer, chunk_size, checksum_data, decode_transfer)?;
1321
1356
 
1322
1357
  // Call legacy shim end_member and calculate bytes written.
1323
1358
  // TODO: Remove when shims are removed.
@@ -1361,6 +1396,9 @@ fn http_datetime_to_py<'py>(py: Python<'py>, value: Option<&str>) -> PyResult<Op
1361
1396
  ///
1362
1397
  /// Exceptions raised by func_filter or a supplied Python stream propagate during iteration.
1363
1398
  ///
1399
+ /// .. versionchanged:: 2.1.0
1400
+ /// HTTP transfer encoding is decoded by default. Use ``auto_decode='none'`` to read the stored body.
1401
+ ///
1364
1402
  /// :param stream: Input stream, file-like object, file name, or URL
1365
1403
  /// :param record_types: Bitmask of :class:`WarcRecordType` values to return
1366
1404
  /// :param parse_http: Parse HTTP records automatically
@@ -1438,7 +1476,7 @@ impl ArchiveIteratorPy {
1438
1476
  func_filter=None,
1439
1477
  verify_digests=false,
1440
1478
  quirks_mode=false,
1441
- auto_decode="none",
1479
+ auto_decode="transfer",
1442
1480
  max_header_len=32 << 10,
1443
1481
  stream_detect=true,
1444
1482
  buffer_size=64 << 10,
@@ -1678,6 +1716,21 @@ pub struct NativeFilterPy {
1678
1716
 
1679
1717
  #[pymethods]
1680
1718
  impl NativeFilterPy {
1719
+ /// Reduce to a call of the factory function that created this filter.
1720
+ ///
1721
+ /// :raise TypeError: If the filter is not parameterized
1722
+ pub fn __reduce__<'py>(&self, py: Python<'py>) -> PyResult<(Bound<'py, PyAny>, (u64,))> {
1723
+ let (factory, arg) = match self.kind {
1724
+ NativeFilterKind::HasRecordType(mask) => ("has_record_type", mask as u64),
1725
+ NativeFilterKind::HasContentLengthLte(max) => ("has_content_length_lte", max),
1726
+ NativeFilterKind::HasContentLengthGte(min) => ("has_content_length_gte", min),
1727
+ // Parameterless filters are exposed as plain module functions and never wrapped
1728
+ _ => return Err(PyTypeError::new_err("Unparameterized filters are not pickled.")),
1729
+ };
1730
+ let module = py.import(intern!(py, "fastwarc.warc"))?;
1731
+ Ok((module.getattr(factory)?, (arg,)))
1732
+ }
1733
+
1681
1734
  pub fn __call__(&self, record: &WarcRecordPy) -> bool {
1682
1735
  let mut record = record.lock();
1683
1736
  self.kind.apply(&mut record)
@@ -1731,6 +1784,9 @@ pub fn has_payload_digest_py(record: &WarcRecordPy) -> bool {
1731
1784
 
1732
1785
  /// Filter predicate for checking if a record has a valid payload digest.
1733
1786
  ///
1787
+ /// .. versionchanged:: 2.1.0
1788
+ /// The filter verifies the payload digest after HTTP transfer decoding.
1789
+ ///
1734
1790
  /// :param record: WARC record
1735
1791
  #[pyfunction(name = "has_valid_payload_digest")]
1736
1792
  pub fn has_valid_payload_digest_py(record: &WarcRecordPy) -> bool {
@@ -50,6 +50,34 @@ def invoke(*arguments):
50
50
  return result
51
51
 
52
52
 
53
+ @pytest.mark.parametrize('body, write_options, check_options', [
54
+ pytest.param(b'5\r\nhello\r\n0\r\n\r\n', {}, (), id='chunked'),
55
+ pytest.param(b'hello', {'decode_transfer': False}, ('--no-decode-transfer',), id='stale-header'),
56
+ ])
57
+ def test_check_decode_transfer(tmp_path, body, write_options, check_options):
58
+ record = WarcRecord()
59
+ record.init_headers(WarcRecordType.response, b'uuid:cli-chunked')
60
+ record.is_http = True
61
+ record.set_bytes_payload(b'HTTP/1.1 200 OK\r\nTransfer-Encoding: chunked\r\n\r\n' + body)
62
+ record.parse_http(auto_decode='none')
63
+ source = tmp_path / 'chunked.warc'
64
+ with source.open('wb') as output:
65
+ record.write(output, checksum_data=True, **write_options)
66
+
67
+ if not check_options:
68
+ assert next(ArchiveIterator(source)).reader.read() == b'hello'
69
+ extracted = tmp_path / 'body.bin'
70
+ invoke('extract', source, 0, '--payload', '-o', extracted)
71
+ assert extracted.read_bytes() == b'hello'
72
+ copied = tmp_path / 'record.warc'
73
+ invoke('extract', source, 0, '-o', copied)
74
+ assert copied.read_bytes() == source.read_bytes()
75
+ assert copied.read_bytes().endswith(body + b'\r\n\r\n')
76
+ details = tmp_path / 'check.txt'
77
+ invoke('check', source, '--verify-payloads', *check_options, '-o', details)
78
+ assert details.read_text().strip() == '<urn:uuid:cli-chunked>: OK, PAYLOAD_OK'
79
+
80
+
53
81
  def snapshot(source):
54
82
  return [(record.record_id, record.reader.read()) for record in ArchiveIterator(source, parse_http=False)]
55
83
 
@@ -132,6 +160,33 @@ def test_check_invalid_digest_returns_failure(warc_file, quiet):
132
160
  assert not result.output
133
161
 
134
162
 
163
+ @pytest.mark.parametrize('corrupt_block', [False, True], ids=['valid-block', 'corrupt-block'])
164
+ def test_check_revisit_skips_referenced_payload_digest(tmp_path, corrupt_block):
165
+ record = WarcRecord()
166
+ record.init_headers(WarcRecordType.revisit, b'uuid:cli-revisit')
167
+ record.is_http = True
168
+ record.headers['WARC-Target-URI'] = 'https://example.org/'
169
+ record.headers['WARC-Profile'] = 'http://netpreserve.org/warc/1.1/revisit/identical-payload-digest'
170
+ record.headers['WARC-Truncated'] = 'length'
171
+ record.headers['WARC-Refers-To'] = '<urn:uuid:original>'
172
+ record.headers['WARC-Payload-Digest'] = 'sha1:RB2FWY2CZX4TMUPXBVPL6SWKSQ4UKV2S'
173
+ record.set_bytes_content(b'HTTP/1.1 200 OK\r\nContent-Type: text/plain\r\n\r\n')
174
+ output = io.BytesIO()
175
+ record.write(output, checksum_data=True)
176
+ data = output.getvalue()
177
+ if corrupt_block:
178
+ data = data.replace(b'200 OK', b'201 OK')
179
+ source = tmp_path / 'revisit.warc'
180
+ source.write_bytes(data)
181
+ details = tmp_path / 'digests.txt'
182
+
183
+ result = CliRunner().invoke(cli.main, ['check', str(source), '--verify-payloads', '-o', str(details)])
184
+
185
+ assert result.exit_code == int(corrupt_block), (result.output, result.exception)
186
+ status = 'FAIL' if corrupt_block else 'OK'
187
+ assert details.read_text() == f'{record.record_id}: {status}\n'
188
+
189
+
135
190
  def test_check_reports_missing_digests(tmp_path):
136
191
  record = WarcRecord()
137
192
  record.init_headers(WarcRecordType.resource, b'uuid:no-digest')
@@ -69,6 +69,14 @@ def _serialize_records(*records: WarcRecord) -> io.BytesIO:
69
69
  return stream
70
70
 
71
71
 
72
+ def test_verify_revisit_payload_digest():
73
+ record = _make_http_record(revisit, body=b"")
74
+ record.headers[WarcHeader.WARC_PAYLOAD_DIGEST] = f"sha1:{hashlib.sha1(b'').hexdigest()}"
75
+ record.parse_http()
76
+
77
+ assert record.verify_payload_digest() is False
78
+
79
+
72
80
  def test_package_reexports():
73
81
  assert WarcRecord is WarcRecord
74
82
  assert HeaderMap is HeaderMap
@@ -341,18 +349,61 @@ def test_warc_record_write():
341
349
  assert restored.http_content_type == "text/plain"
342
350
 
343
351
 
344
- def test_record_and_header_pickle():
345
- record = WarcRecord()
346
- record.init_headers(unknown, b"urn:uuid:test-record")
347
- record.record_type = response
348
- record.is_http = True
349
- record.set_bytes_content(_http_payload())
350
- assert record.is_frozen
352
+ @pytest.mark.parametrize("value", [
353
+ response,
354
+ WarcRecordType.any_type,
355
+ WarcRecordType.no_type,
356
+ WarcHeader.WARC_TYPE,
357
+ WarcHeader.WARC_SEGMENT_TOTAL_LENGTH,
358
+ ])
359
+ @pytest.mark.parametrize("protocol", [0, pickle.HIGHEST_PROTOCOL])
360
+ def test_enum_pickle(value, protocol):
361
+ # Enum members unpickle to the canonical class members
362
+ assert pickle.loads(pickle.dumps(value, protocol)) is value
351
363
 
352
- # Pickle headers
353
- assert pickle.loads(pickle.dumps(record.headers)) == record.headers
354
364
 
355
- # Pickle entire record
365
+ def _owned_header_map(encoding: str) -> HeaderMap:
366
+ headers = HeaderMap(encoding)
367
+ headers["X-Test"] = "ä"
368
+ return headers
369
+
370
+
371
+ def _http_header_map() -> HeaderMap:
372
+ record = _make_http_record()
373
+ record.parse_http()
374
+ return record.http_headers
375
+
376
+
377
+ @pytest.mark.parametrize("make_headers", [
378
+ lambda: _owned_header_map("utf-8"),
379
+ lambda: _owned_header_map("latin1"),
380
+ lambda: _make_http_record().headers,
381
+ _http_header_map,
382
+ ], ids=["utf-8", "latin1", "warc", "http"])
383
+ def test_header_map_pickle(make_headers):
384
+ headers = make_headers()
385
+ restored = pickle.loads(pickle.dumps(headers))
386
+ assert restored == headers
387
+ assert restored.encoding() == headers.encoding()
388
+ assert restored.status_line == headers.status_line
389
+
390
+
391
+ @pytest.mark.parametrize(("make_filter", "expected"), [
392
+ (lambda: has_record_type(response), True),
393
+ (lambda: has_record_type(request | revisit), False),
394
+ (lambda: has_content_length_lte(0), False),
395
+ (lambda: has_content_length_gte(1), True),
396
+ ])
397
+ def test_native_filter_pickle(make_filter, expected):
398
+ restored = pickle.loads(pickle.dumps(make_filter()))
399
+ assert type(restored) is type(make_filter())
400
+ assert restored(_make_http_record()) is expected
401
+
402
+
403
+ def test_record_pickle():
404
+ record = _make_http_record()
405
+ assert record.is_frozen
406
+
356
407
  record_roundtrip = pickle.loads(pickle.dumps(record))
357
408
  assert record_roundtrip == record
358
409
  assert record_roundtrip is not record
@@ -469,7 +520,8 @@ def test_warc_record_auto_decode_content_and_transfer():
469
520
  + b"\r\n"
470
521
  + chunked_payload
471
522
  )
472
- transfer_record.parse_http(auto_decode="transfer", strict_mode=False)
523
+ transfer_record.parse_http()
524
+ assert pickle.loads(pickle.dumps(transfer_record)).reader.read() == payload
473
525
  assert transfer_record.reader.read() == payload
474
526
 
475
527
 
@@ -28,7 +28,6 @@ from tqdm import tqdm
28
28
  from fastwarc.stream_io import GzipReader, GzipWriter, Lz4Reader, Lz4Writer, ZstdReader, ZstdWriter
29
29
  from fastwarc.warc import ArchiveIterator, WarcRecordType
30
30
 
31
-
32
31
  COMPRESSION_ALGORITHMS = ['gzip', 'lz4', 'zstd', 'uncompressed', 'auto']
33
32
  _READERS = {'gzip': GzipReader, 'lz4': Lz4Reader, 'zstd': ZstdReader}
34
33
  _WRITERS = {'gzip': GzipWriter, 'lz4': Lz4Writer, 'zstd': ZstdWriter}
@@ -78,19 +77,21 @@ def _recompress_records(infile, outfile, decompress_alg, compress_alg, compress_
78
77
  yield output.tell() - before
79
78
 
80
79
 
81
- def _verify_digests(infile, verify_payloads, decompress_alg):
80
+ def _verify_digests(infile, verify_payloads, decompress_alg, decode_transfer):
82
81
  with closing(_warc_records(infile, decompress_alg, parse_http=False, inplace=True)) as records:
83
82
  for record in records:
83
+ # Omit a payload verdict for revisits so an unavailable check is not reported as a mismatch.
84
+ check_payload = verify_payloads and record.record_type != WarcRecordType.revisit
84
85
  result = {
85
86
  'record_id': record.record_id,
86
- 'block_digest_ok': record.verify_block_digest(not verify_payloads or not record.is_http)
87
+ 'block_digest_ok': record.verify_block_digest(not check_payload or not record.is_http)
87
88
  if 'WARC-Block-Digest' in record.headers else None,
88
89
  }
89
- if verify_payloads:
90
+ if check_payload:
90
91
  if 'WARC-Payload-Digest' in record.headers:
91
92
  if record.is_http:
92
- record.parse_http()
93
- result['payload_digest_ok'] = record.verify_payload_digest(True)
93
+ record.parse_http(auto_decode='transfer' if decode_transfer else 'none')
94
+ result['payload_digest_ok'] = record.verify_payload_digest(True, decode_transfer=decode_transfer)
94
95
  else:
95
96
  result['payload_digest_ok'] = None
96
97
  yield result
@@ -153,15 +154,19 @@ def recompress(infile, outfile, compress_alg, decompress_alg, compress_level, qu
153
154
  @click.option('-d', '--decompress-alg', type=click.Choice(COMPRESSION_ALGORITHMS),
154
155
  default='auto', show_default=True, help='Decompression algorithm')
155
156
  @click.option('-p', '--verify-payloads', is_flag=True, help='Also verify payload digests')
157
+ @click.option('--no-decode-transfer', is_flag=True,
158
+ help='Do not decode HTTP transfer encoding when verifying payload digests')
156
159
  @click.option('-q', '--quiet', is_flag=True, help='Do not print progress information')
157
160
  @click.option('-o', '--output', type=click.File('w'), help='Output file with verification details')
158
- def check(infile, decompress_alg, verify_payloads, quiet, output):
161
+ def check(infile, decompress_alg, verify_payloads, no_decode_transfer, quiet, output):
159
162
  """
160
163
  Verify WARC record consistency.
161
164
 
162
- Check digests of all records in a WARC file and print a summary. You can verify all block and
163
- payload digests in the given WARC file and print a summary of all corrupted and (optionally)
164
- all intact records.
165
+ Check block digests in a WARC file and print a summary of corrupted records. Use --verify-payloads
166
+ to also check payload digests. Payload verification decodes HTTP transfer encoding by
167
+ default. Use --no-decode-transfer to hash the stored HTTP body. Revisit payload checks
168
+ are skipped because their interpretation depends on the WARC profile. Use --output
169
+ to write per-record results.
165
170
 
166
171
  The command will exit with a non-zero exit code if at least one record fails verification.
167
172
  """
@@ -171,7 +176,7 @@ def check(infile, decompress_alg, verify_payloads, quiet, output):
171
176
  num_no_digest = 0
172
177
  try:
173
178
  desc_tpl = 'Verifying digests ({} failed)'
174
- pbar = tqdm(_verify_digests(infile, verify_payloads, decompress_alg),
179
+ pbar = tqdm(_verify_digests(infile, verify_payloads, decompress_alg, not no_decode_transfer),
175
180
  desc=desc_tpl.format(0), unit=' record(s)', leave=False, disable=quiet, mininterval=0.2)
176
181
 
177
182
  for v in pbar:
@@ -222,7 +227,7 @@ def check(infile, decompress_alg, verify_payloads, quiet, output):
222
227
  @click.option('-o', '--output', type=click.File('wb'), default='-',
223
228
  help='Output file, default is stdout')
224
229
  @click.option('--payload', is_flag=True,
225
- help='Output only record payload (transfer and/or content encoding are preserved')
230
+ help='Output only the payload, with any HTTP transfer encoding decoded')
226
231
  @click.option('--headers', is_flag=True, help='Output only record (and HTTP) headers')
227
232
  def extract(infile, offset, output, payload, headers):
228
233
  """
@@ -236,7 +241,7 @@ def extract(infile, offset, output, payload, headers):
236
241
  with open(infile, 'rb') as stream:
237
242
  stream.seek(offset)
238
243
  try:
239
- iterator = ArchiveIterator(stream)
244
+ iterator = ArchiveIterator(stream, parse_http=not compl_record)
240
245
  record = next(iterator)
241
246
  if compl_record:
242
247
  record.write(output)
@@ -390,8 +395,9 @@ def _expand_s3_prefixes(input_urls, endpoint_url, aws_access_key, aws_secret_key
390
395
  help='Use Python I/O instead of native file readers for local files')
391
396
  @click.option('-H', '--parse-http', is_flag=True, help='Parse HTTP headers')
392
397
  @click.option('-v', '--verify-digests', is_flag=True, help='Verify record block digests')
393
- @click.option('-f', '--filter-type', type=click.Choice(['warcinfo', 'response', 'resource', 'request', 'metadata',
394
- 'revisit', 'conversion', 'continuation', 'unknown', 'any_type']),
398
+ @click.option('-f', '--filter-type', type=click.Choice(
399
+ ['warcinfo', 'response', 'resource', 'request', 'metadata', 'revisit',
400
+ 'conversion', 'continuation', 'unknown', 'any_type']),
395
401
  default=['any_type'], multiple=True, show_default=True, help='Filter for specific WARC record types')
396
402
  @click.option('-w', '--bench-warcio', is_flag=True, help='Compare FastWARC performance with WARCIO')
397
403
  def benchmark(input_url, decompress_alg, endpoint_url, aws_access_key, aws_secret_key, is_prefix, use_python_stream,
@@ -423,7 +429,8 @@ def benchmark(input_url, decompress_alg, endpoint_url, aws_access_key, aws_secre
423
429
  break
424
430
 
425
431
  if bench_warcio:
426
- algorithms = {_compression_from_path(url) for url in input_url} if decompress_alg == 'auto' else {decompress_alg}
432
+ algorithms = {_compression_from_path(url) for url in input_url} if decompress_alg == 'auto' else {
433
+ decompress_alg}
427
434
  if algorithms & {'lz4', 'zstd'}:
428
435
  raise click.UsageError('WARCIO does not support LZ4 or Zstandard.')
429
436
 
@@ -482,8 +489,8 @@ def benchmark(input_url, decompress_alg, endpoint_url, aws_access_key, aws_secre
482
489
  def _warcio_iterator(f):
483
490
  source = _get_raw_stream_from_url(f, True)
484
491
  try:
485
- for rec in warcio.ArchiveIterator(source, no_record_parse=not parse_http,
486
- check_digests=verify_digests):
492
+ for rec in warcio.ArchiveIterator(
493
+ source, no_record_parse=not parse_http, check_digests=verify_digests):
487
494
  if rec_type_filter & getattr(WarcRecordType, rec.rec_type):
488
495
  yield rec
489
496
  finally:
@@ -333,19 +333,20 @@ class WarcRecord:
333
333
 
334
334
  def parse_warc_headers(self, quirks_mode: bool = False, max_header_len: int = 32 << 10) -> int: ...
335
335
 
336
- def parse_http(self, auto_decode: Literal['none', 'content', 'transfer', 'all'] = 'none',
336
+ def parse_http(self, auto_decode: Literal['none', 'content', 'transfer', 'all'] = 'transfer',
337
337
  max_header_len: int = 32 << 10, quirks_mode: bool = False, *, strict_mode: bool = True): ...
338
338
 
339
339
  def verify_block_digest(self, consume: bool = False) -> bool: ...
340
340
 
341
- def verify_payload_digest(self, consume: bool = False) -> bool: ...
341
+ def verify_payload_digest(self, consume: bool = False, decode_transfer: bool = True) -> bool: ...
342
342
 
343
343
  def write(
344
344
  self,
345
345
  stream: WarcWriter | BinaryIO | _GenericWriter,
346
346
  checksum_data: bool = False,
347
347
  payload_digest: bytes | None = None,
348
- chunk_size: int = 16384
348
+ chunk_size: int = 16384,
349
+ decode_transfer: bool = True,
349
350
  ) -> int: ...
350
351
 
351
352
  def __eq__(self, other, /) -> bool: ...
@@ -375,7 +376,7 @@ class ArchiveIterator(Iterable[WarcRecord]):
375
376
  func_filter: Callable[[WarcRecord], bool] | None = None,
376
377
  verify_digests: bool = False,
377
378
  quirks_mode: bool = False,
378
- auto_decode: Literal['none', 'content', 'transfer', 'all'] = 'none',
379
+ auto_decode: Literal['none', 'content', 'transfer', 'all'] = 'transfer',
379
380
  max_header_len: int = 32 << 10,
380
381
  stream_detect: bool = True,
381
382
  buffer_size: int = 64 << 10,
File without changes
File without changes
File without changes
File without changes