Skip to content

Commit a1b2d41

Browse files
committed
test fetch_with_meta
1 parent b5759d5 commit a1b2d41

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

src/webserver/database/sqlpage_functions/functions.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,9 @@ async fn fetch_with_meta(
261261
String::from_utf8_lossy(&body_bytes).into_owned(),
262262
),
263263
}
264-
} else if let Ok(text) = String::from_utf8(body_bytes.clone()) { serde_json::Value::String(text) } else {
264+
} else if let Ok(text) = String::from_utf8(body_bytes.clone()) {
265+
serde_json::Value::String(text)
266+
} else {
265267
let mut base64_string = String::new();
266268
base64::Engine::encode_string(
267269
&base64::engine::general_purpose::STANDARD,
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
set res = sqlpage.fetch_with_meta('{
2+
"method": "PUT",
3+
"url": "http://localhost:62802/hello_world",
4+
"headers": {
5+
"user-agent": "myself"
6+
}
7+
}');
8+
select 'text' as component,
9+
case
10+
when json_extract($res, '$.status') = 200
11+
and cast(json_extract($res, '$.headers.content-length') as int) > 100
12+
and json_extract($res, '$.body') like 'PUT /hello_world%'
13+
then 'It works !'
14+
else 'It failed! Got: ' || $res
15+
end as contents;

0 commit comments

Comments
 (0)