|
|
@ -47,8 +47,12 @@ func (h *HTTPTransport) nextID() uint64 {
|
|
|
|
return h.nextid
|
|
|
|
return h.nextid
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Call call a remote method
|
|
|
|
|
|
|
|
func (h *HTTPTransport) Call(method string, args interface{}, reply interface{}) error {
|
|
|
|
func (h *HTTPTransport) Call(method string, args interface{}, reply interface{}) error {
|
|
|
|
|
|
|
|
return h.CallWithHeader(method, args, reply, nil)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Call call a remote method
|
|
|
|
|
|
|
|
func (h *HTTPTransport) CallWithHeader(method string, args interface{}, reply interface{}, header http.Header) error {
|
|
|
|
if args == nil {
|
|
|
|
if args == nil {
|
|
|
|
args = []string{}
|
|
|
|
args = []string{}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -57,7 +61,7 @@ func (h *HTTPTransport) Call(method string, args interface{}, reply interface{})
|
|
|
|
Version: "2.0",
|
|
|
|
Version: "2.0",
|
|
|
|
Method: method,
|
|
|
|
Method: method,
|
|
|
|
Params: args,
|
|
|
|
Params: args,
|
|
|
|
ID: fmt.Sprintf("%d", h.nextID()),
|
|
|
|
ID: h.nextID(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
data, err := json.Marshal(r)
|
|
|
|
data, err := json.Marshal(r)
|
|
|
@ -74,6 +78,14 @@ func (h *HTTPTransport) Call(method string, args interface{}, reply interface{})
|
|
|
|
return err
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if header != nil {
|
|
|
|
|
|
|
|
for k, v := range header {
|
|
|
|
|
|
|
|
for _, v1 := range v {
|
|
|
|
|
|
|
|
req.Header.Add(k, v1)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
req.Header.Set("Content-Type", "application/json")
|
|
|
|
req.Header.Set("Content-Type", "application/json")
|
|
|
|
|
|
|
|
|
|
|
|
resp, err := h.Client.Do(req)
|
|
|
|
resp, err := h.Client.Do(req)
|
|
|
|