1
0
Fork 0
mirror of https://git.sr.ht/~adnano/go-gemini synced 2024-06-09 21:46:07 +02:00

Request.WriteTo: return int64

This commit is contained in:
adnano 2021-02-28 22:20:43 -05:00
parent 5338fe2b0a
commit 6645e820a1

View File

@ -79,20 +79,20 @@ func ReadRequest(r io.Reader) (*Request, error) {
// WriteTo writes r to w in the Gemini request format.
// This method consults the request URL only.
func (r *Request) WriteTo(w io.Writer) (int, error) {
func (r *Request) WriteTo(w io.Writer) (int64, error) {
bw := bufio.NewWriterSize(w, 1026)
url := r.URL.String()
if len(url) > 1024 {
return 0, ErrInvalidRequest
}
var wrote int
var wrote int64
n, err := bw.WriteString(url)
wrote += n
wrote += int64(n)
if err != nil {
return wrote, err
}
n, err = bw.Write(crlf)
wrote += n
wrote += int64(n)
if err != nil {
return wrote, err
}