Hi.

Never mind. I have send the header in base64 and decode it.

```shell
curl -vH 'Authorization: '$(< 
/datadisk/git-repos/haproxy/dev/json/test-data.json.base64 ) http://127.0.0.1:8080

*   Trying 127.0.0.1:8080...
* TCP_NODELAY set
* Connected to 127.0.0.1 (127.0.0.1) port 8080 (#0)
> GET / HTTP/1.1
> Host: 127.0.0.1:8080
> User-Agent: curl/7.68.0
> Accept: */*
> Authorization: 
eyJpc3MiOiJrdWJlcm5ldGVzL3NlcnZpY2VhY2NvdW50Iiwia3ViZXJuZXRlcy5pby9zZXJ2aWNlYWNjb3VudC9uYW1lc3BhY2UiOiJvcGVuc2hpZnQtbG9nZ2luZyIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VjcmV0Lm5hbWUiOiJkZXBsb3llci10b2tlbi1tOTh4aCIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50Lm5hbWUiOiJkZXBsb3llciIsImt1YmVybmV0ZXMuaW8vc2VydmljZWFjY291bnQvc2VydmljZS1hY2NvdW50LnVpZCI6IjM1ZGRkZWZkLTNiNWEtMTFlOS05NDdjLWZhMTYzZTQ4MDkxMCIsInN1YiI6InN5c3RlbTpzZXJ2aWNlYWNjb3VudDpvcGVuc2hpZnQtbG9nZ2luZzpkZXBsb3llciJ9
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 200 OK
< x-var: 
json={"iss":"kubernetes/serviceaccount","kubernetes.io/serviceaccount/namespace":"openshift-logging","kubernetes.io/serviceaccount/secret.name":"deployer-token-m98xh","kubernetes.io/serviceaccount/service-account.name":"deployer","kubernetes.io/serviceaccount/service-account.uid":"35dddefd-3b5a-11e9-947c-fa163e480910","sub":"system:serviceaccount:openshift-logging:deployer"}
 val=
< content-length: 10
< content-type: text/plain

```

```
http-request set-var(req.json)  req.hdr(Authorization),b64dec
http-request return status 200 content-type text/plain lf-string %[date] hdr x-var 
"json=%[var(req.json)] val=%[var(sess.json)]"

```

regards
alex

On 08.04.21 01:27, Aleksandar Lazic wrote:
Hi.

I try to implement "sample_fetch_json_string" based on 
https://github.com/cesanta/mjson.
My current test looks good but I'm struggling with the test setup.

```
git-repos/haproxy$ ./haproxy -c -f ../test-haproxy.conf
[NOTICE] 097/012132 (1043229) : haproxy version is 2.4-dev15-8daf8d-30
[NOTICE] 097/012132 (1043229) : path to executable is ./haproxy
[ALERT] 097/012132 (1043229) : parsing [../test-haproxy.conf:9] : error 
detected in frontend 'fe1' while parsing
'http-request set-var(req.json)' rule : fetch method 'str' : expected ')' before 
',\"kubernetes.io/serviceaccount/namespace\":\"openshift-logging\",\"kubernetes.io/serviceaccount/secret.name\":\"deployer-token-m98xh\",\"kubernetes.io/serviceaccount/service-account.name\":\"deployer\",\"kubernetes.io/serviceaccount/service-account.uid\":\"35dddefd-3b5a-11e9-947c-fa163e480910\",\"sub\":\"system:serviceaccount:openshift-logging:deployer\"})'.

[ALERT] 097/012132 (1043229) : Error(s) found in configuration file : 
../test-haproxy.conf

```

That's the config.
```
defaults
        mode http
        timeout connect 1s
        timeout client  1s
        timeout server  1s

frontend fe1
        bind "127.0.0.1:8080"
        http-request set-var(req.json)  
'str({\"iss\":\"kubernetes/serviceaccount\",\"kubernetes.io/serviceaccount/namespace\":\"openshift-logging\",\"kubernetes.io/serviceaccount/secret.name\":\"deployer-token-m98xh\",\"kubernetes.io/serviceaccount/service-account.name\":\"deployer\",\"kubernetes.io/serviceaccount/service-account.uid\":\"35dddefd-3b5a-11e9-947c-fa163e480910\",\"sub\":\"system:serviceaccount:openshift-logging:deployer\"})'

```

I have tried several combos like.
str("...")
str('...')
str(...)
I have also added more '\' in the string.

But I get always the error above.

Any Idea how to fix the error?

Regards
Alex



Reply via email to