X-Git-Url: http://www.git.stargrave.org/?a=blobdiff_plain;f=warc%2Frecord.go;h=e5dc633bcd1cedb91aad1f015791dce68bcd0ecb;hb=HEAD;hp=a2fa6bc5a2370838cdb4c4d5d867003a2a037ee9;hpb=bae1cfe5ce46a1b758ccc4dddda2751b6ac47f3e;p=tofuproxy.git diff --git a/warc/record.go b/warc/record.go index a2fa6bc..38181ab 100644 --- a/warc/record.go +++ b/warc/record.go @@ -1,19 +1,18 @@ -/* -tofuproxy -- flexible HTTP/WARC proxy with TLS certificates management -Copyright (C) 2021 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 @@ -52,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() } @@ -72,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 {