Commit 83b80af 1 parent a892fd2 commit 83b80af Copy full SHA for 83b80af
File tree 5 files changed +28
-9
lines changed
components/outbound-redis/src
outbound-redis-no-permission
outbound-redis-variable-permission
5 files changed +28
-9
lines changed Original file line number Diff line number Diff line change @@ -31,11 +31,12 @@ impl Guest for Component {
31
31
const REDIS_ADDRESS_HEADER : & str = "REDIS_ADDRESS" ;
32
32
33
33
fn handle ( request : IncomingRequest ) -> anyhow:: Result < OutgoingResponse > {
34
- let Some ( address) = request. headers ( ) . entries ( ) . into_iter ( ) . find_map ( |( k, v) | {
35
- ( k == REDIS_ADDRESS_HEADER )
36
- . then_some ( v)
37
- . and_then ( |v| String :: from_utf8 ( v) . ok ( ) )
38
- } ) else {
34
+ let Some ( address) = request
35
+ . headers ( )
36
+ . get ( & REDIS_ADDRESS_HEADER . to_owned ( ) )
37
+ . pop ( )
38
+ . and_then ( |v| String :: from_utf8 ( v) . ok ( ) )
39
+ else {
39
40
// Otherwise, return a 400 Bad Request response.
40
41
return Ok ( response ( 400 , b"Bad Request" ) ) ;
41
42
} ;
@@ -94,12 +95,15 @@ fn handle(request: IncomingRequest) -> anyhow::Result<OutgoingResponse> {
94
95
] ,
95
96
) ?;
96
97
97
- connection. execute (
98
+ let values = connection. execute (
98
99
"incr" ,
99
100
& [ redis:: RedisParameter :: Binary ( b"int-key" . to_vec ( ) ) ] ,
100
101
) ?;
101
102
102
- anyhow:: ensure!( matches!( values. as_slice( ) , & [ redis:: RedisResult :: Int64 ( 1 ) ] ) ) ;
103
+ anyhow:: ensure!(
104
+ matches!( values. as_slice( ) , & [ redis:: RedisResult :: Int64 ( 1 ) ] ) ,
105
+ "call to `execute('incr')` returned unexpected result: {values:?} != &[redis::RedisResult::Int64(1)]"
106
+ ) ;
103
107
104
108
let values =
105
109
connection. execute ( "get" , & [ redis:: RedisParameter :: Binary ( b"int-key" . to_vec ( ) ) ] ) ?;
Original file line number Diff line number Diff line change 7
7
{
8
8
"name" : "Host" ,
9
9
"value" : "example.com"
10
+ } ,
11
+ {
12
+ "name" : "redis_address" ,
13
+ "value" : "redis://localhost:%{port=6379}" ,
10
14
}
11
15
]
12
16
} ,
15
19
"headers" : [
16
20
{
17
21
"name" : "Content-Length" ,
18
- "value" : "0"
22
+ "optional" : true ,
23
+ } ,
24
+ {
25
+ "name" : "transfer-encoding" ,
26
+ "optional" : true
19
27
} ,
20
28
{
21
29
"name" : "Date" ,
Original file line number Diff line number Diff line change 7
7
{
8
8
"name" : "Host" ,
9
9
"value" : "example.com"
10
+ } ,
11
+ {
12
+ "name" : "redis_address" ,
13
+ "value" : "redis://localhost:%{port=6379}" ,
10
14
}
11
15
]
12
16
} ,
Original file line number Diff line number Diff line change @@ -11,5 +11,4 @@ component = "test"
11
11
12
12
[component .test ]
13
13
source = " %{source=outbound-redis}"
14
- environment = { REDIS_ADDRESS = " redis://localhost:%{port=6379}" }
15
14
allowed_outbound_hosts = [" redis://localhost:%{port=6379}" ]
Original file line number Diff line number Diff line change 7
7
{
8
8
"name" : "Host" ,
9
9
"value" : "example.com"
10
+ } ,
11
+ {
12
+ "name" : "redis_address" ,
13
+ "value" : "redis://localhost:%{port=6379}" ,
10
14
}
11
15
]
12
16
} ,
You can’t perform that action at this time.
0 commit comments