Commit bdde6205 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Small fixes

parent 17dd7cb7
...@@ -121,7 +121,7 @@ func handlePostRPC(w http.ResponseWriter, r *http.Request, a *api.Response) { ...@@ -121,7 +121,7 @@ func handlePostRPC(w http.ResponseWriter, r *http.Request, a *api.Response) {
// either. // either.
_, err = io.Copy(buffer, io.LimitReader(r.Body, 4096)) _, err = io.Copy(buffer, io.LimitReader(r.Body, 4096))
if err != nil { if err != nil {
helper.Fail500(w, r, &copyError{fmt.Errorf("handlePostRPC: buffer git-upload-pack body: %v")}) helper.Fail500(w, r, &copyError{fmt.Errorf("handlePostRPC: buffer git-upload-pack body: %v", err)})
return return
} }
......
...@@ -34,14 +34,9 @@ func scanDeepen(body io.Reader) (bool, error) { ...@@ -34,14 +34,9 @@ func scanDeepen(body io.Reader) (bool, error) {
} }
func pktLineSplitter(data []byte, atEOF bool) (advance int, token []byte, err error) { func pktLineSplitter(data []byte, atEOF bool) (advance int, token []byte, err error) {
truncatedData := data
if len(data) > 100 {
truncatedData = truncatedData[:100]
}
if len(data) < 4 { if len(data) < 4 {
if atEOF && len(data) > 0 { if atEOF && len(data) > 0 {
return 0, nil, fmt.Errorf("pktLineSplitter: incomplete length prefix on %q", truncatedData) return 0, nil, fmt.Errorf("pktLineSplitter: incomplete length prefix on %q", data)
} }
return 0, nil, nil // want more data return 0, nil, nil // want more data
} }
...@@ -67,7 +62,7 @@ func pktLineSplitter(data []byte, atEOF bool) (advance int, token []byte, err er ...@@ -67,7 +62,7 @@ func pktLineSplitter(data []byte, atEOF bool) (advance int, token []byte, err er
if len(data) < pktLength { if len(data) < pktLength {
if atEOF { if atEOF {
return 0, nil, fmt.Errorf("pktLineSplitter: less than %d bytes in input %q", pktLength, truncatedData) return 0, nil, fmt.Errorf("pktLineSplitter: less than %d bytes in input %q", pktLength, data)
} }
return 0, nil, nil // want more data return 0, nil, nil // want more data
} }
......
...@@ -16,13 +16,13 @@ func TestSuccessfulScanDeepen(t *testing.T) { ...@@ -16,13 +16,13 @@ func TestSuccessfulScanDeepen(t *testing.T) {
} }
for _, example := range examples { for _, example := range examples {
ok, err := scanDeepen(bytes.NewReader([]byte(example.input))) hasDeepen, err := scanDeepen(bytes.NewReader([]byte(example.input)))
if err != nil { if err != nil {
t.Fatalf("error scanning %q: %v", example.input, err) t.Fatalf("error scanning %q: %v", example.input, err)
} }
if ok != example.output { if hasDeepen != example.output {
t.Fatalf("scanDeepen %q: expected %v, got %v", example.input, example.output, ok) t.Fatalf("scanDeepen %q: expected %v, got %v", example.input, example.output, hasDeepen)
} }
} }
} }
...@@ -35,14 +35,14 @@ func TestFailedScanDeepen(t *testing.T) { ...@@ -35,14 +35,14 @@ func TestFailedScanDeepen(t *testing.T) {
} }
for _, example := range examples { for _, example := range examples {
ok, err := scanDeepen(bytes.NewReader([]byte(example))) hasDeepen, err := scanDeepen(bytes.NewReader([]byte(example)))
if err == nil { if err == nil {
t.Fatalf("expected error scanning %q", example) t.Fatalf("expected error scanning %q", example)
} }
t.Log(err) t.Log(err)
if ok == true { if hasDeepen == true {
t.Fatalf("scanDeepen %q: expected result to be false, got true", example) t.Fatalf("scanDeepen %q: expected result to be false, got true", example)
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment