[WIP] Use a managed HTTP(S) transport implementation #374

Closed
carlosmn wants to merge 15 commits from cmn/go-http into main
1 changed files with 15 additions and 4 deletions
Showing only changes of commit c5e6dc298e - Show all commits

13
http.go
View File

@ -25,6 +25,8 @@ import (
"bytes"
"errors"
"fmt"
"io"
"io/ioutil"
"net/http"
"reflect"
"runtime"
@ -128,6 +130,7 @@ func (self *ManagedTransport) Action(url string, action SmartService) (SmartSubt
}
func (self *ManagedTransport) Close() error {
self.client = nil
return nil
}
@ -193,6 +196,8 @@ func (self *ManagedHttpStream) sendRequest() error {
Method: self.req.Method,
URL: self.req.URL,
Header: self.req.Header,
Body: ioutil.NopCloser(&self.postBuffer),
ContentLength: int64(self.postBuffer.Len()),
}
req.SetBasicAuth(userName, password)
@ -352,7 +357,13 @@ func smartSubtransportRead(s *C.git_smart_subtransport_stream, data *C.char, l C
n, err := stream.Read(p)
if err != nil {
return setLibgit2Error(err)
if err == io.EOF {
*read = C.size_t(0)
return 0
}
setLibgit2Error(err)
return -1
}
*read = C.size_t(n)