http: use an environment-provided proxy
We currently cannot ask the transport for its proxy settings, so for now we'll use the one from the environment.
This commit is contained in:
parent
1be680fdf0
commit
c726f932db
25
http.go
25
http.go
|
@ -82,9 +82,17 @@ func RegisterManagedHttps() error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
type ManagedTransport struct{}
|
type ManagedTransport struct {
|
||||||
|
owner *C.git_transport
|
||||||
|
|
||||||
|
client *http.Client
|
||||||
|
}
|
||||||
|
|
||||||
func (self *ManagedTransport) Action(url string, action SmartService) (SmartSubtransportStream, error) {
|
func (self *ManagedTransport) Action(url string, action SmartService) (SmartSubtransportStream, error) {
|
||||||
|
if err := self.ensureClient(); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
var req *http.Request
|
var req *http.Request
|
||||||
var err error
|
var err error
|
||||||
switch action {
|
switch action {
|
||||||
|
@ -128,6 +136,19 @@ func (self *ManagedTransport) Close() error {
|
||||||
func (self *ManagedTransport) Free() {
|
func (self *ManagedTransport) Free() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (self *ManagedTransport) ensureClient() error {
|
||||||
|
if self.client != nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
transport := &http.Transport{
|
||||||
|
Proxy: http.ProxyFromEnvironment,
|
||||||
|
}
|
||||||
|
self.client = &http.Client{Transport: transport}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
type ManagedHttpStream struct {
|
type ManagedHttpStream struct {
|
||||||
req *http.Request
|
req *http.Request
|
||||||
resp *http.Response
|
resp *http.Response
|
||||||
|
@ -247,7 +268,7 @@ func httpSmartSubtransportCb(out **C.git_smart_subtransport, owner *C.git_transp
|
||||||
}
|
}
|
||||||
|
|
||||||
transport := C.calloc(1, C.size_t(unsafe.Sizeof(C.managed_smart_subtransport{})))
|
transport := C.calloc(1, C.size_t(unsafe.Sizeof(C.managed_smart_subtransport{})))
|
||||||
managed := &ManagedTransport{}
|
managed := &ManagedTransport{owner: owner}
|
||||||
managedPtr := pointerHandles.Track(managed)
|
managedPtr := pointerHandles.Track(managed)
|
||||||
C._go_git_setup_smart_subtransport(transport, managedPtr)
|
C._go_git_setup_smart_subtransport(transport, managedPtr)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue