apiclient: fix http roundtrip (clone body also)
This pr allows to retry properly the HTTP request when it receives a 401 HTTP code including the request body.
Codecov Report
Merging #1758 (8130698) into master (fe23da6) will increase coverage by
0.03%. The diff coverage is93.75%.
@@ Coverage Diff @@
## master #1758 +/- ##
==========================================
+ Coverage 53.73% 53.77% +0.03%
==========================================
Files 151 151
Lines 20280 20301 +21
==========================================
+ Hits 10898 10917 +19
- Misses 8205 8206 +1
- Partials 1177 1178 +1
| Flag | Coverage Δ | |
|---|---|---|
| func-crowdsec | 47.07% <ø> (ø) |
|
| func-cscli | 44.57% <ø> (-0.05%) |
:arrow_down: |
| unit-linux | 58.37% <93.75%> (+0.15%) |
:arrow_up: |
| unit-windows | 53.41% <93.75%> (-0.08%) |
:arrow_down: |
Flags with carried forward coverage won't be shown. Click here to find out more.
| Impacted Files | Coverage Δ | |
|---|---|---|
| pkg/apiclient/auth.go | 78.31% <93.54%> (-0.46%) |
:arrow_down: |
| pkg/apiclient/client.go | 77.31% <100.00%> (+0.23%) |
:arrow_up: |
| cmd/crowdsec-cli/machines.go | 50.17% <0.00%> (-1.07%) |
:arrow_down: |
| pkg/acquisition/modules/docker/docker.go | 61.51% <0.00%> (+0.24%) |
:arrow_up: |
| pkg/acquisition/modules/cloudwatch/cloudwatch.go | 78.82% <0.00%> (+0.98%) |
:arrow_up: |
:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more
Need a fix server side too
The PR is ready, the server side fixed is done.
/kind enhancement /area agent
Before merging, we need to test this behavior,
Having LAPI and agent separated then, restart LAPI and check if the agent can send a heartbeat.
Before merging, we need to test this behavior,
Having LAPI and agent separated then, restart LAPI and check if the agent can send a heartbeat.
Tested,
INFO[12-12-2022 14:11:35] 127.0.0.1 - [Mon, 12 Dec 2022 14:11:35 CET] "GET /v1/heartbeat HTTP/1.1 401 91.671µs "crowdsec/v1.4.3-linux-9e6781aad2acc249e875e5dc64fd52d0cf9f842d" "
INFO[12-12-2022 14:11:35] 127.0.0.1 - [Mon, 12 Dec 2022 14:11:35 CET] "POST /v1/watchers/login HTTP/1.1 200 63.247137ms "crowdsec/v1.4.3-linux-9e6781aad2acc249e875e5dc64fd52d0cf9f842d" "
INFO[12-12-2022 14:11:35] 127.0.0.1 - [Mon, 12 Dec 2022 14:11:35 CET] "GET /v1/heartbeat HTTP/1.1 200 5.105604ms "crowdsec/v1.4.3-linux-9e6781aad2acc249e875e5dc64fd52d0cf9f842d" "
INFO[12-12-2022 14:12:35] 127.0.0.1 - [Mon, 12 Dec 2022 14:12:35 CET] "GET /v1/heartbeat HTTP/1.1 200 20.727092ms "crowdsec/v1.4.3-linux-9e6781aad2acc249e875e5dc64fd52d0cf9f842d" "
It works fine.