aboutsummaryrefslogtreecommitdiff
path: root/cmd/receivepack9418/gitproto.go
blob: 609f2c12c7819839453cf461c5ff2ba734e29ac7 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
package main

import (
	"fmt"
	"io"

	"codeberg.org/lindenii/furgit/format/pktline"
)

func readGitProtoRequest(r io.Reader) (gitProtoRequest, error) {
	dec := pktline.NewDecoder(r, pktline.ReadOptions{})

	frame, err := dec.ReadFrame()
	if err != nil {
		return gitProtoRequest{}, err
	}

	if frame.Type != pktline.PacketData {
		return gitProtoRequest{}, fmt.Errorf("expected initial pkt-line data, got %v", frame.Type)
	}

	return parseGitProtoRequestPayload(frame.Payload)
}