X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=warc%2Frecord.go;h=e5dc633bcd1cedb91aad1f015791dce68bcd0ecb;hb=HEAD;hp=d755acea56c7a1fbaeaed4d349ed111e3d930998;hpb=decb4bfb406665dde1233e9936fee3edfe3e81da;p=tofuproxy.git diff --git a/warc/record.go b/warc/record.go index d755ace..38181ab 100644 --- a/warc/record.go +++ b/warc/record.go @@ -1,20 +1,18 @@ -/* -tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU - manager, WARC/geminispace browser -Copyright (C) 2021-2022 Sergey Matveev - -This program is free software: you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation, version 3 of the License. - -This program is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see . -*/ +// tofuproxy -- flexible HTTP/HTTPS proxy, TLS terminator, X.509 TOFU +// manager, WARC/geminispace browser +// Copyright (C) 2021-2024 Sergey Matveev +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, version 3 of the License. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . package warc @@ -53,7 +51,7 @@ type SelfRecordReader struct { } func (srr *SelfRecordReader) Read(p []byte) (n int, err error) { - n, err = srr.rrr.Read(p) + n, err = srr.lr.Read(p) if err != nil { srr.Close() } @@ -73,7 +71,11 @@ func (rec *Record) selfReader(noHdr bool, offsets []Offset) (*SelfRecordReader, if err != nil { return nil, err } - return &SelfRecordReader{lr: &io.LimitedReader{R: rrr, N: rec.Size}, rrr: rrr}, nil + size := rec.Size + if !noHdr { + size += int64(rec.HdrLen) + } + return &SelfRecordReader{lr: &io.LimitedReader{R: rrr, N: size}, rrr: rrr}, nil } type RecordReader struct {