Skip to content

Commit db15573

Browse files
committed
Stream tedge http get response
Signed-off-by: Didier Wenzek <[email protected]>
1 parent 788e74f commit db15573

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

crates/core/tedge/src/cli/http/command.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -79,11 +79,8 @@ impl HttpCommand {
7979

8080
fn send(request: blocking::RequestBuilder) -> Result<(), Error> {
8181
let http_result = request.send()?;
82-
let http_response = http_result.error_for_status()?;
83-
let bytes = http_response.bytes()?.to_vec();
84-
let content = String::from_utf8(bytes)?;
85-
86-
println!("{content}");
82+
let mut http_response = http_result.error_for_status()?;
83+
http_response.copy_to(&mut std::io::stdout())?;
8784
Ok(())
8885
}
8986
}

tests/RobotFramework/tests/tedge/http_file_transfer_api.robot

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,15 @@ Get Put Delete
2727
Should Be Equal ${get} test of put
2828
Execute Command curl -X DELETE http://${DEVICE_IP}:${PORT}/tedge/file-transfer/file_a
2929

30+
File transfer using tedge cli
31+
Setup skip_bootstrap=False
32+
33+
Execute Command tedge http put /tedge/file-transfer/file_b "content to be transfered"
34+
${content}= Execute Command tedge http get /tedge/file-transfer/file_b
35+
Should Be Equal ${content} content to be transfered
36+
Execute Command tedge http delete /tedge/file-transfer/file_b
37+
Execute Command tedge http get /tedge/file-transfer/file_b exp_exit_code=1
38+
3039

3140
*** Keywords ***
3241
Custom Setup

0 commit comments

Comments
 (0)