| 125 | } |
| 126 | |
| 127 | func postRetry(target HttpClient, reqUrl string, |
| 128 | reqParams map[string]interface{}, contentType string, files []UploadFile, headers map[string]string) (string, error) { |
| 129 | result := "" |
| 130 | var err error = nil |
| 131 | |
| 132 | if target.Sleep > 0 { |
| 133 | defaultTimeout = target.Sleep |
| 134 | } |
| 135 | |
| 136 | Retry(target.RetryMax, target.Sleep, func() error { |
| 137 | result, err = target.post(reqUrl, reqParams, contentType, files, headers) |
| 138 | if err == nil { |
| 139 | if result == "" { |
| 140 | err = errors.New("response body is empty") |
| 141 | } else if !IsJSON(result) && contentType == "application/json" { |
| 142 | err = errors.New("response body is not json") |
| 143 | } |
| 144 | } |
| 145 | return err |
| 146 | }) |
| 147 | |
| 148 | return result, err |
| 149 | } |
| 150 | |
| 151 | type UploadFile struct { |
| 152 | // 表单名称 |