|
4 | 4 | "bytes" |
5 | 5 | "context" |
6 | 6 | "encoding/json" |
7 | | - "fmt" |
8 | 7 | "io" |
9 | 8 | "net" |
10 | 9 | "net/http" |
@@ -52,12 +51,6 @@ func (c *RawClient) Get(ctx context.Context, endpoint string, v any) error { |
52 | 51 | } |
53 | 52 | defer response.Body.Close() |
54 | 53 |
|
55 | | - // Check for HTTP errors |
56 | | - if response.StatusCode >= 400 { |
57 | | - buf, _ := io.ReadAll(response.Body) |
58 | | - return fmt.Errorf("HTTP %d: %s", response.StatusCode, string(buf)) |
59 | | - } |
60 | | - |
61 | 54 | buf, err := io.ReadAll(response.Body) |
62 | 55 | if err != nil { |
63 | 56 | return err |
@@ -97,12 +90,6 @@ func (c *RawClient) Post(ctx context.Context, endpoint string, v any, result any |
97 | 90 | } |
98 | 91 | defer response.Body.Close() |
99 | 92 |
|
100 | | - // Check for HTTP errors |
101 | | - if response.StatusCode >= 400 { |
102 | | - buf, _ := io.ReadAll(response.Body) |
103 | | - return fmt.Errorf("HTTP %d: %s", response.StatusCode, string(buf)) |
104 | | - } |
105 | | - |
106 | 93 | if result == nil { |
107 | 94 | _, err := io.Copy(io.Discard, response.Body) |
108 | 95 | return err |
@@ -136,12 +123,6 @@ func (c *RawClient) Delete(ctx context.Context, endpoint string) error { |
136 | 123 | } |
137 | 124 | defer response.Body.Close() |
138 | 125 |
|
139 | | - // Check for HTTP errors |
140 | | - if response.StatusCode >= 400 { |
141 | | - buf, _ := io.ReadAll(response.Body) |
142 | | - return fmt.Errorf("HTTP %d: %s", response.StatusCode, string(buf)) |
143 | | - } |
144 | | - |
145 | 126 | _, err = io.Copy(io.Discard, response.Body) |
146 | 127 | return err |
147 | 128 | } |
0 commit comments