@@ -1133,27 +1133,23 @@ func (h *apiClientImpl) Do(ctx context.Context, req *http.Request) (*http.Respon
1133
1133
// DoGetFallback will attempt to do the request as-is, and on a 405 or 501 it
1134
1134
// will fallback to a GET request.
1135
1135
func (h * apiClientImpl ) DoGetFallback (ctx context.Context , u * url.URL , args url.Values ) (* http.Response , []byte , Warnings , error ) {
1136
- req , err := http .NewRequest (http .MethodPost , u .String (), strings .NewReader (args .Encode ()))
1136
+ encodedArgs := args .Encode ()
1137
+ req , err := http .NewRequest (http .MethodPost , u .String (), strings .NewReader (encodedArgs ))
1137
1138
if err != nil {
1138
1139
return nil , nil , nil , err
1139
1140
}
1140
1141
req .Header .Set ("Content-Type" , "application/x-www-form-urlencoded" )
1141
1142
1142
1143
resp , body , warnings , err := h .Do (ctx , req )
1143
1144
if resp != nil && (resp .StatusCode == http .StatusMethodNotAllowed || resp .StatusCode == http .StatusNotImplemented ) {
1144
- u .RawQuery = args . Encode ()
1145
+ u .RawQuery = encodedArgs
1145
1146
req , err = http .NewRequest (http .MethodGet , u .String (), nil )
1146
1147
if err != nil {
1147
1148
return nil , nil , warnings , err
1148
1149
}
1149
-
1150
- } else {
1151
- if err != nil {
1152
- return resp , body , warnings , err
1153
- }
1154
- return resp , body , warnings , nil
1150
+ return h .Do (ctx , req )
1155
1151
}
1156
- return h . Do ( ctx , req )
1152
+ return resp , body , warnings , err
1157
1153
}
1158
1154
1159
1155
func formatTime (t time.Time ) string {
0 commit comments