---
title: "jetty中禁止使用chunked传输数据"
author: "everlasting_188"
date: "2015-08-26T15:42:48Z"
tags: []
categories: ["编程语言"]
slug: "jetty-chunked"
draft: false
lastmod: "2015-08-26T15:42:48Z"
id: 2238159
url: "https://everlasting-188.iteye.com/blog/2238159"
---

# [Slow transfers in Jetty with chunked transfer encoding at certain buffer size](http://stackoverflow.com/questions/9031311/slow-transfers-in-jetty-with-chunked-transfer-encoding-at-certain-buffer-size)

It seems that to get good performance with Jetty, you must either:

- When calling `setContentLength` (no chunked transfer encoding) and use a buffer for `write`that's the same size as the response buffer size.
- When using chunked transfer encoding, use a write buffer that's at least 12 bytes smaller than the response buffer size, and call `flush` after each write.

经验证没有问题，但是非chunked对服务端的性能消耗较大。

 

引用：http://stackoverflow.com/questions/9031311/slow-transfers-in-jetty-with-chunked-transfer-encoding-at-certain-buffer-size