# Posted body content compression

**URL:** <https://community.gatling.io/t/posted-body-content-compression/291>\
**Category:** Gatling (Open-Source)\
**Created:** [March 8, 2013, 10:40am UTC](https://community.gatling.io/t/posted-body-content-compression/291 "2013-03-08T10:40:38Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mathieu\_Schmitt](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Mathieu\_Schmitt](https://community.gatling.io/u/Mathieu_Schmitt)\
**Post date:** [March 8, 2013, 10:40am UTC](https://community.gatling.io/t/posted-body-content-compression/291/1 "2013-03-08T10:40:38Z")

</div>

Hi ,

It 's not possible to compress data sended by an HTTP post ?

The better way to do this should be to use byteArrayBody ?

Thks,

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [March 8, 2013, 11:06am UTC](https://community.gatling.io/t/posted-body-content-compression/291/2 "2013-03-08T11:06:43Z")

</div>

Hi,

Request compression is supported out of the box (well, it should, I never tested personally, but that’s a AHC/Netty feature that Gatling simply exposes).  
Change requestCompressionLevel is gatling.conf. Default value is -1 for disabled. 6 is a typical value (it’s Netty’s default value when enabled).

Cheers,

Stéphane

---

<div class="post-metadata">

**Author:** ![Mathieu\_Schmitt](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Mathieu\_Schmitt](https://community.gatling.io/u/Mathieu_Schmitt)\
**Post date:** [March 8, 2013, 3:34pm UTC](https://community.gatling.io/t/posted-body-content-compression/291/3 "2013-03-08T15:34:47Z")

</div>

Thks for your quick reply.

I try to enable requestCompressionLevel in gatling.conf but it doesn’t work. I try to set the header with differents values: Content-Encoding:gzip, Accept-Encoding:gzip …

I also try to use grizzly or apache but doen’t work :

Here the stacktrace with Netty :

16:27:40.062 [WARN] c.e.e.g.h.a.GatlingAsyncHandler - Request ‘POST request’ failed  
java.lang.IllegalStateException: cannot send more responses than requests  
at org.jboss.netty.handler.codec.http.HttpContentEncoder.writeRequested(HttpContentEncoder.java:100) ~[netty-3.6.1.Final.jar:na]  
at org.jboss.netty.handler.stream.ChunkedWriteHandler.flush(ChunkedWriteHandler.java:280) ~[netty-3.6.1.Final.jar:na]  
at org.jboss.netty.handler.stream.ChunkedWriteHandler.handleDownstream(ChunkedWriteHandler.java:121) ~[netty-3.6.1.Final.jar:na]  
at org.jboss.netty.channel.Channels.write(Channels.java:704) ~[netty-3.6.1.Final.jar:na]  
at org.jboss.netty.channel.Channels.write(Channels.java:671) ~[netty-3.6.1.Final.jar:na]  
at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:248) ~[netty-3.6.1.Final.jar:na]  
at com.ning.http.client.providers.netty.NettyAsyncHttpProvider.writeRequest(NettyAsyncHttpProvider.java:484) ~[async-http-client-1.7.9.jar:na]  
at com.ning.http.client.providers.netty.NettyConnectListener.operationComplete(NettyConnectListener.java:82) ~[async-http-client-1.7.9.jar:na]  
at org.jboss.netty.channel.DefaultChannelFuture.notifyListener(DefaultChannelFuture.java:427) ~[netty-3.6.1.Final.jar:na]  
at org.jboss.netty.channel.DefaultChannelFuture.notifyListeners(DefaultChannelFuture.java:418) ~[netty-3.6.1.Final.jar:na]  
at org.jboss.netty.channel.DefaultChannelFuture.setSuccess(DefaultChannelFuture.java:362) ~[netty-3.6.1.Final.jar:na]  
at org.jboss.netty.channel.socket.nio.NioWorker$RegisterTask.run(NioWorker.java:156) ~[netty-3.6.1.Final.jar:na]  
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.processTaskQueue(AbstractNioSelector.java:367) ~[netty-3.6.1.Final.jar:na]  
at org.jboss.netty.channel.socket.nio.AbstractNioSelector.run(AbstractNioSelector.java:291) ~[netty-3.6.1.Final.jar:na]  
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:88) ~[netty-3.6.1.Final.jar:na]  
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:178) ~[netty-3.6.1.Final.jar:na]  
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1110) [na:1.7.0\_09]  
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:603) [na:1.7.0\_09]  
at java.lang.Thread.run(Thread.java:722) [na:1.7.0\_09]

Regards,

Mathieu

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [March 8, 2013, 3:53pm UTC](https://community.gatling.io/t/posted-body-content-compression/291/4 "2013-03-08T15:53:28Z")

</div>

I wonder if this might be related to this issue: [https://github.com/netty/netty/issues/441](https://github.com/netty/netty/issues/441) (the error message is incorrect when the server returns BAD\_REQUEST).

Are you sure that your server supports REQUEST compression?

---

<div class="post-metadata">

**Author:** ![Mathieu\_Schmitt](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Mathieu\_Schmitt](https://community.gatling.io/u/Mathieu_Schmitt)\
**Post date:** [March 8, 2013, 4:05pm UTC](https://community.gatling.io/t/posted-body-content-compression/291/5 "2013-03-08T16:05:13Z")

</div>

Yes it should be a netty issue.

Our server support request compression. It works well at runtime, when another server post compressed request body.

Regards

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [March 8, 2013, 4:12pm UTC](https://community.gatling.io/t/posted-body-content-compression/291/6 "2013-03-08T16:12:29Z")

</div>

Do you use HTTP or HTTPS?

---

<div class="post-metadata">

**Author:** ![Mathieu\_Schmitt](https://avatars.discourse-cdn.com/v4/letter/m/fbc32d/32.png) [@Mathieu\_Schmitt](https://community.gatling.io/u/Mathieu_Schmitt)\
**Post date:** [March 8, 2013, 4:36pm UTC](https://community.gatling.io/t/posted-body-content-compression/291/7 "2013-03-08T16:36:12Z")

</div>

We use HTTP. The body content that we want to compress is xml.

We build the xml from ssp ressources. without compression it works well.

Thks

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [March 8, 2013, 4:39pm UTC](https://community.gatling.io/t/posted-body-content-compression/291/8 "2013-03-08T16:39:17Z")

</div>

Do you have a set up, or even better, a platform I could test against?

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [March 9, 2013, 10:37am UTC](https://community.gatling.io/t/posted-body-content-compression/291/9 "2013-03-09T10:37:48Z")

</div>

I’m pretty sure that the problem comes from Gatling not computing properly the Content-Length header and sending the uncompressed value.  
Will investigate next week, hopefully.

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [March 10, 2013, 6:01pm UTC](https://community.gatling.io/t/posted-body-content-compression/291/10 "2013-03-10T18:01:00Z")

</div>

I realized this is an old issue that's still open in AHC:  
[https://github.com/AsyncHttpClient/async-http-client/issues/93](https://github.com/AsyncHttpClient/async-http-client/issues/93)

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [March 15, 2013, 2:26pm UTC](https://community.gatling.io/t/posted-body-content-compression/291/11 "2013-03-15T14:26:23Z")

</div>

I’ve add a recipe to the cook book that explains how to manually compress the request body:  
[https://github.com/excilys/gatling/wiki/Compressing-Request-Body](https://github.com/excilys/gatling/wiki/Compressing-Request-Body)

Cheers,

Stéphane
