(method, url, requestBody string, headers map[string]string, callbackSuccessContent []string)
| 85 | } |
| 86 | |
| 87 | func (cb *Callback) CallbackHttpClientDo(method, url, requestBody string, headers map[string]string, callbackSuccessContent []string) error { |
| 88 | |
| 89 | globalDDNSConf := config.GetDDNSConfigure() |
| 90 | dnsConf := cb.task.DNS |
| 91 | statusCode, respStr, err := httputils.GetStringGoutDoHttpRequest( |
| 92 | "tcp", |
| 93 | "", |
| 94 | method, |
| 95 | url, |
| 96 | requestBody, |
| 97 | dnsConf.HttpClientProxyType, |
| 98 | dnsConf.HttpClientProxyAddr, |
| 99 | dnsConf.HttpClientProxyUser, |
| 100 | dnsConf.HttpClientProxyPassword, |
| 101 | headers, |
| 102 | !globalDDNSConf.HttpClientSecureVerify, |
| 103 | time.Duration(cb.task.HttpClientTimeout)*time.Second) |
| 104 | if err != nil { |
| 105 | return fmt.Errorf("Callback 调用接口[%s]出错:%s", url, err.Error()) |
| 106 | } |
| 107 | |
| 108 | if cb.task.DNS.Callback.DisableCallbackSuccessContentCheck { |
| 109 | if statusCode == http.StatusOK { |
| 110 | return nil |
| 111 | } |
| 112 | return fmt.Errorf("调用接口失败:\n statusCode:%d\n%s", statusCode, respStr) |
| 113 | } |
| 114 | |
| 115 | //log.Printf("接口[%s]调用响应:%s\n", url, respStr) |
| 116 | |
| 117 | //fmt.Printf("statusCode:%d\n", statusCode) |
| 118 | |
| 119 | for _, successContent := range callbackSuccessContent { |
| 120 | if strings.Contains(respStr, successContent) { |
| 121 | return nil |
| 122 | } |
| 123 | } |
| 124 | |
| 125 | return fmt.Errorf("调用接口失败:\n%s", respStr) |
| 126 | } |
no test coverage detected