aboutsummaryrefslogtreecommitdiffstats
path: root/clients/http/git_upload_pack.go
diff options
context:
space:
mode:
Diffstat (limited to 'clients/http/git_upload_pack.go')
-rw-r--r--clients/http/git_upload_pack.go23
1 files changed, 20 insertions, 3 deletions
diff --git a/clients/http/git_upload_pack.go b/clients/http/git_upload_pack.go
index 96dbdce..b128c1c 100644
--- a/clients/http/git_upload_pack.go
+++ b/clients/http/git_upload_pack.go
@@ -1,6 +1,7 @@
package http
import (
+ "fmt"
"io"
"net/http"
"strings"
@@ -28,7 +29,8 @@ func (s *GitUploadPackService) Connect(url common.Endpoint) error {
}
func (s *GitUploadPackService) Info() (*common.GitUploadPackInfo, error) {
- res, err := s.doRequest("GET", common.GitUploadPackServiceName, nil)
+ url := fmt.Sprintf("%s/info/refs?service=%s", s.endpoint, common.GitUploadPackServiceName)
+ res, err := s.doRequest("GET", url, nil)
if err != nil {
return nil, err
}
@@ -39,13 +41,28 @@ func (s *GitUploadPackService) Info() (*common.GitUploadPackInfo, error) {
return common.NewGitUploadPackInfo(dec)
}
-func (s *GitUploadPackService) doRequest(method, service string, content *strings.Reader) (*http.Response, error) {
+func (s *GitUploadPackService) Fetch(r *common.GitUploadPackRequest) (io.ReadCloser, error) {
+ url := fmt.Sprintf("%s/%s", s.endpoint, common.GitUploadPackServiceName)
+ res, err := s.doRequest("POST", url, r.Reader())
+ if err != nil {
+ return nil, err
+ }
+
+ h := make([]byte, 8)
+ if _, err := res.Body.Read(h); err != nil {
+ return nil, err
+ }
+
+ return res.Body, nil
+}
+
+func (s *GitUploadPackService) doRequest(method, url string, content *strings.Reader) (*http.Response, error) {
var body io.Reader
if content != nil {
body = content
}
- req, err := http.NewRequest(method, s.endpoint.Service(service), body)
+ req, err := http.NewRequest(method, url, body)
if err != nil {
return nil, err
}