aboutsummaryrefslogtreecommitdiff
path: root/cmd/receivepack9418/gitproto.go
blob: 1375f57cd398f2390069803c29de09e5e2c109ea (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"

	"lindenii.org/go/furgit/network/protocol/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)
}