grpc / grpc/grpc-web

How to match an empty reponse body in hcm local reply filter?

Open
#1,206 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
9.3k
Forks
802
Avg merge
1d 7h
Merged PRs (30d)
5

Description

I'm trying to add a local response if there is no response body originally. My config is as below, but it doesn't seem to work very well. Is there an easy way to match a no-body response?

```json
{
"local_reply_config":{
"mappers":[
{
"filter":{
"and_filter":{
"filters":[
{
"status_code_filter":{
"comparison":{
"op":"GE",
"value":{
"runtime_key":"400"
}
}
}
},
{
"or_filter":{
"filters":[
{
"header_filter":{
"header":{
"name":"content-length",
"present_match":false
}
}
},
{
"and_filter":{
"filters":[
{
"header_filter":{
"header":{
"name":"content-length",
"present_match":true
}
}
},
{
"header_filter":{
"header":{
"name":"content-length",
"string_match":{
"exact":"0"
}
}
}
}
]
}
}
]
}
},
{
"or_filter":{
"filters":[
{
"header_filter":{
"header":{
"name":"Transfer-Encoding",
"present_match":false
}
}
},
{
"and_filter":{
"filters":[
{
"header_filter":{
"header":{
"name":"Transfer-Encoding",
"present_match":true
}
}
},
{
"header_filter":{
"header":{
"name":"Transfer-Encoding",
"string_match":{
"exact":"chunked"
},
"invert_match":true
}
}
}
]
}
}
]
}
}
]
}
},
"body_format_override":{
"text_format_source":{
"inline_string":"%RESP(message)%"
}
}
}
]
}
}
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.