# Haproxy1.6 modify response body by Lua problem

**URL:** <https://discourse.haproxy.org/t/haproxy1-6-modify-response-body-by-lua-problem/2570>\
**Category:** Help!\
**Created:** [June 7, 2018, 1:35am UTC](https://discourse.haproxy.org/t/haproxy1-6-modify-response-body-by-lua-problem/2570 "2018-06-07T01:35:46Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![cnzzr](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/cnzzr/32/519_2.png) [@cnzzr](https://discourse.haproxy.org/u/cnzzr)\
**Post date:** [June 7, 2018, 1:35am UTC](https://discourse.haproxy.org/t/haproxy1-6-modify-response-body-by-lua-problem/2570/1 "2018-06-07T01:35:46Z")

</div>

Ubuntu 14 Server with Hparoxy 1.6  
My problem is when response’s body size just 505 then browser return ERR\_EMPTY\_RESPONSE  
but when response’s body size big then 2877 return OK.

[WARNING] 157/093512 (14599) : config : log format ignored for frontend ‘http\_80\_in’ since it has no log address.  
[info] 157/093516 (14599) : start debug …  
[info] 157/093516 (14599) : in: 505  
[info] 157/093516 (14599) : out: 0  
[info] 157/093516 (14599) : before send  
[info] 157/093516 (14599) : out: 0  
[info] 157/093516 (14599) : in: 0  
[info] 157/093516 (14599) : end debug …  
[info] 157/093520 (14599) : start debug …  
[info] 157/093520 (14599) : in: 2877  
[info] 157/093520 (14599) : out: 0  
[info] 157/093520 (14599) : before send  
[info] 157/093520 (14599) : out: 0  
[info] 157/093520 (14599) : in: 2877  
[info] 157/093520 (14599) : end debug …

lua scripts  
core.register\_action(“file-get-oa”, { “http-res” }, function(txn)  
txn:Info(‘start debug …’)  
txn:Info('in: '… txn.res:get\_in\_len())  
txn:Info('out: '… txn.res:get\_out\_len())

```
   local json = txn.res:get()
   txn:Info( ' before send')
   txn.res:set(json)
   txn:Info(' out: '.. txn.res:get_out_len())
   txn:Info(' in: '.. txn.res:get_in_len())
   txn:Info('end debug .........')
end)

```

haproxy.cfg  
backend oafile-server  
mode http  
option http-server-close  
http-request replace-header Host ^gys.zxlm.cn$ [oa.zxlm.cn](http://oa.zxlm.cn)

acl htmltxt res.hdr(Content-Type) -m beg text application/json  
acl gys var(txn.requesthost) -m str [gys.zxlm.cn](http://gys.zxlm.cn)  
http-response lua.file-get-oa if !gys htmltxt  
http-response lua.file-get-gys if gys htmltxt

server oa\_File\_8060 10.219.8.101:8060 check

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [June 7, 2018, 9:50am UTC](https://discourse.haproxy.org/t/haproxy1-6-modify-response-body-by-lua-problem/2570/2 "2018-06-07T09:50:22Z")

</div>

Moved to help section, as you are asking for Help, rather than providing a working LUA script for others.

---

<div class="post-metadata">

**Author:** ![cnzzr](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/cnzzr/32/519_2.png) [@cnzzr](https://discourse.haproxy.org/u/cnzzr)\
**Post date:** [June 11, 2018, 8:53am UTC](https://discourse.haproxy.org/t/haproxy1-6-modify-response-body-by-lua-problem/2570/3 "2018-06-11T08:53:19Z")

</div>

Is possible config txn channel cache buffer size.
