Zig 0.17.0-dev (Split by item) This is an example of documentation generated by
ZigDoc , an alternative to Zig's built-in
Auto Doc feature. See also
examples in other modes/formats . The project being documented here (as the example) is the Zig standard library.
std › http › Reader › chunkedReadEndless Private Function chunkedReadEndless Doc Source 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 fn chunkedReadEndless (
reader : *Reader ,
w : *Writer ,
limit : std .Io .Limit ,
chunk_len_ptr : *RemainingChunkLen ,
) (BodyError || std .Io .Reader .StreamError )!usize {
const in = reader .in ;
len : switch (chunk_len_ptr .*) {
.head => {
var cp : ChunkParser = .init ;
while (true ) {
const i = cp .feed (in .buffered ());
switch (cp .state ) {
.invalid => return error .HttpChunkInvalid ,
.data => {
in .toss (i );
break ;
},
else => {
in .toss (i );
try in .fillMore ();
continue ;
},
}
}
if (cp .chunk_len == 0 ) return parseTrailers (reader , 0 );
const n = try in .stream (w , limit .min (.limited64 (cp .chunk_len )));
chunk_len_ptr .* = .init (cp .chunk_len + 2 - n );
return n ;
},
.n => {
if ((try in .peekByte ()) != '\n' ) return error .HttpChunkInvalid ;
in .toss (1 );
continue :len .head ;
},
.rn => {
const rn = try in .peekArray (2 );
if (rn [0 ] != '\r' or rn [1 ] != '\n' ) return error .HttpChunkInvalid ;
in .toss (2 );
continue :len .head ;
},
else => |remaining_chunk_len | {
const n = try in .stream (w , limit .min (.limited64 (@backingInt (remaining_chunk_len ) - 2 )));
chunk_len_ptr .* = .init (@backingInt (remaining_chunk_len ) - n );
return n ;
},
}
}